Spaces:
Runtime error
Runtime error
NimaBoscarino
commited on
Commit
β’
1c9731f
1
Parent(s):
e65e057
WIP: Substra styling
Browse files
app.py
CHANGED
@@ -1,16 +1,94 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
|
3 |
+
|
4 |
+
theme = gr.themes.Default(primary_hue="blue").set(
|
5 |
+
background_fill_primary="#F9F2EA",
|
6 |
+
block_background_fill="#FFFFFF",
|
7 |
+
)
|
8 |
+
|
9 |
+
|
10 |
+
demo = gr.Blocks(theme=theme, css="""\
|
11 |
+
.gradio-container {
|
12 |
+
width: 100%;
|
13 |
+
}
|
14 |
+
|
15 |
+
.margin-top {
|
16 |
+
margin-top: 20px;
|
17 |
+
}
|
18 |
+
|
19 |
+
.white {
|
20 |
+
background-color: white;
|
21 |
+
}
|
22 |
+
|
23 |
+
.column {
|
24 |
+
border-radius: 20px;
|
25 |
+
padding: 30px;
|
26 |
+
}
|
27 |
+
|
28 |
+
.blue {
|
29 |
+
/**
|
30 |
+
background-image: url("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/substra-banner.png");
|
31 |
+
background-size: cover;
|
32 |
+
**/
|
33 |
+
background-color: #223fb3;
|
34 |
+
}
|
35 |
+
|
36 |
+
.blue p {
|
37 |
+
color: white !important;
|
38 |
+
}
|
39 |
+
|
40 |
+
.info-box {
|
41 |
+
background: transparent !important;
|
42 |
+
}
|
43 |
+
""")
|
44 |
+
|
45 |
+
with demo:
|
46 |
+
gr.HTML("""
|
47 |
+
<img src="https://raw.githubusercontent.com/substra/substra/main/Substra-logo-colour.svg" style="height: 5em;" />
|
48 |
+
""")
|
49 |
+
gr.Markdown("# Federated Learning with Substra")
|
50 |
+
with gr.Row():
|
51 |
+
with gr.Column(scale=1, elem_classes=["blue", "column"]):
|
52 |
+
gr.Markdown("Here you can run a quick simulation of Federated Learning with Substra.")
|
53 |
+
gr.Markdown("Check out the accompanying blog post to learn more.")
|
54 |
+
with gr.Box(elem_classes=["info-box"]):
|
55 |
+
gr.Markdown("""\
|
56 |
+
This space is an introduction to federated learning. \
|
57 |
+
We will create new spaces soon where you will be able to control the models, datasets and \
|
58 |
+
federation strategies.\
|
59 |
+
""")
|
60 |
+
with gr.Column(scale=3, elem_classes=["white", "column"]):
|
61 |
+
gr.Markdown("""\
|
62 |
+
Data scientists doing medical research often face a shortage of high quality and diverse data to \
|
63 |
+
effectively train models. This challenge can be overcome by securely allowing training on pro- tected \
|
64 |
+
data through (Federated Learning). Substra is a Python based Federated Learning soft- ware that \
|
65 |
+
enables researchers to easily train ML models on remote data regardless of the ML library they are \
|
66 |
+
using or the data modality they are working with.\
|
67 |
+
""")
|
68 |
+
gr.Markdown("### Here we show an example of image data located in two different hospitals.")
|
69 |
+
gr.Markdown("""\
|
70 |
+
By playing with the distribution of data in the 2 simulated hospitals, you'll be able to compare how \
|
71 |
+
the federated models compare with models trained on single datasets. The data used is from the \
|
72 |
+
Camelyon17 dataset, a commonly used benchmark in the medical world that comes from this challenge. \
|
73 |
+
The sample below shows normal cells on the left compared with cancer cells on the right.\
|
74 |
+
""")
|
75 |
+
gr.HTML("""
|
76 |
+
<img
|
77 |
+
src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/substra-tumor.png"
|
78 |
+
style="padding: 20px 150px;"
|
79 |
+
/>
|
80 |
+
""")
|
81 |
+
gr.Markdown("""\
|
82 |
+
A problem often faced by researchers is that datasets lack the necessary amount of positive samples \
|
83 |
+
(samples containing cancer tissues) that are needed to reliably classify cancer. In this interface you \
|
84 |
+
can use the slider to control the percentage of negative and positive samples in each hospital. \
|
85 |
+
Setting this slider to minimum will mean there are 0 positive samples, whereas 0.5 would mean that \
|
86 |
+
half the dataset contains slides with positive tumor samples.\
|
87 |
+
""")
|
88 |
+
|
89 |
+
with gr.Row(elem_classes=["margin-top"]):
|
90 |
+
gr.Slider()
|
91 |
+
gr.Slider()
|
92 |
+
gr.Button(value="Launch Experiment π")
|
93 |
+
|
94 |
+
demo.launch()
|