Spaces:
Build error
Build error
Warvito
commited on
Commit
·
f50c1ac
1
Parent(s):
1d1c1e7
Try Update app
Browse files- app.py +41 -6
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -76,6 +76,11 @@ def sample_fn(
|
|
| 76 |
return x_hat.numpy()
|
| 77 |
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
def create_videos_and_file(
|
| 80 |
gender_radio,
|
| 81 |
age_slider,
|
|
@@ -171,13 +176,18 @@ def unrest_randomise():
|
|
| 171 |
# TEXT
|
| 172 |
title = "Generating Brain Imaging with Diffusion Models"
|
| 173 |
description = """
|
| 174 |
-
<center><b>WORK IN PROGRESS. DO NOT SHARE.</b></center>
|
| 175 |
<center><a href="https://arxiv.org/">[PAPER]</a> <a href="https://academictorrents.com/details/63aeb864bbe2115ded0aa0d7d36334c026f0660b">[DATASET]</a></center>
|
| 176 |
|
| 177 |
<details>
|
| 178 |
-
<summary>Instructions</summary>
|
| 179 |
-
|
| 180 |
-
With this app, you can generate synthetic brain images with one click!<br />You have
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
</details>
|
| 182 |
|
| 183 |
"""
|
|
@@ -186,7 +196,8 @@ article = """
|
|
| 186 |
Checkout our dataset with [100K synthetic brain](https://academictorrents.com/details/63aeb864bbe2115ded0aa0d7d36334c026f0660b)! 🧠🧠🧠
|
| 187 |
|
| 188 |
App made by [Walter Hugo Lopez Pinaya](https://twitter.com/warvito) from [AMIGO](https://amigos.ai/)
|
| 189 |
-
<center><img src="https://
|
|
|
|
| 190 |
"""
|
| 191 |
|
| 192 |
demo = gr.Blocks()
|
|
@@ -280,6 +291,21 @@ with demo:
|
|
| 280 |
unrest_brain_number,
|
| 281 |
],
|
| 282 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 283 |
|
| 284 |
with gr.Column():
|
| 285 |
with gr.Box():
|
|
@@ -336,5 +362,14 @@ with demo:
|
|
| 336 |
],
|
| 337 |
)
|
| 338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 339 |
# demo.launch(share=True, enable_queue=True)
|
| 340 |
-
demo.launch(enable_queue=True)
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
return x_hat.numpy()
|
| 77 |
|
| 78 |
|
| 79 |
+
def sample_with_text_fn(text_prompt):
|
| 80 |
+
# Not implemented
|
| 81 |
+
pass
|
| 82 |
+
|
| 83 |
+
|
| 84 |
def create_videos_and_file(
|
| 85 |
gender_radio,
|
| 86 |
age_slider,
|
|
|
|
| 176 |
# TEXT
|
| 177 |
title = "Generating Brain Imaging with Diffusion Models"
|
| 178 |
description = """
|
|
|
|
| 179 |
<center><a href="https://arxiv.org/">[PAPER]</a> <a href="https://academictorrents.com/details/63aeb864bbe2115ded0aa0d7d36334c026f0660b">[DATASET]</a></center>
|
| 180 |
|
| 181 |
<details>
|
| 182 |
+
<summary><b>Instructions</b></summary>
|
| 183 |
+
|
| 184 |
+
<p style="margin-top: -3px;">With this app, you can generate synthetic brain images with one click!<br />You have several ways to set how your generated brain will look like:<br /></p>
|
| 185 |
+
<ul style="margin-top: -20px;margin-bottom: -15px;">
|
| 186 |
+
<li style="margin-bottom: -10px;margin-left: 20px;">Use the "<i>Inputs</i>" tab to create well-behaved brains using the same value ranges that our <br />models learned as described in paper linked above</li>
|
| 187 |
+
<li style="margin-left: 20px;">Use the "<i>Unrestricted Inputs</i>" tab to generate the wildest brains!</li>
|
| 188 |
+
<li style="margin-left: 20px;">Use the "<i>Text prompt</i>" tab to generate brains based on text descriptions (Coming soon).</li>
|
| 189 |
+
</ul>
|
| 190 |
+
<p>After customisation, just hit "<i>Generate</i>" and wait a few seconds.<br />The generated brain will also be available for download, and you can use your favourite Nifti Viewer to check it.<br />Note: if are having problems with the videos, try our app using chrome. <b>Enjoy!<b><p>
|
| 191 |
</details>
|
| 192 |
|
| 193 |
"""
|
|
|
|
| 196 |
Checkout our dataset with [100K synthetic brain](https://academictorrents.com/details/63aeb864bbe2115ded0aa0d7d36334c026f0660b)! 🧠🧠🧠
|
| 197 |
|
| 198 |
App made by [Walter Hugo Lopez Pinaya](https://twitter.com/warvito) from [AMIGO](https://amigos.ai/)
|
| 199 |
+
<center><img src="https://raw.githubusercontent.com/Warvito/public_images/master/assets/Footer_1.png" alt="Project by amigos.ai" style="width:450px;"></center>
|
| 200 |
+
<center><img src="https://raw.githubusercontent.com/Warvito/public_images/master/assets/Footer_2.png" alt="Acknowledgements" style="width:750px;"></center>
|
| 201 |
"""
|
| 202 |
|
| 203 |
demo = gr.Blocks()
|
|
|
|
| 291 |
unrest_brain_number,
|
| 292 |
],
|
| 293 |
)
|
| 294 |
+
with gr.TabItem("Text prompt"):
|
| 295 |
+
text_prompt = gr.Textbox("Coming soon... Follow me on twitter to get latest updates.", show_label=False, interactive=False)
|
| 296 |
+
submit_text_btn = gr.Button("Generate", variant="primary", )
|
| 297 |
+
gr.Examples(
|
| 298 |
+
examples=[
|
| 299 |
+
["32 years old | Normal appearance brain"],
|
| 300 |
+
["T2 weighted | Male | 50 years old | There are a few T2 hyperintensities in the deep white matter of the frontal lobes"],
|
| 301 |
+
["Minor small vessel change"],
|
| 302 |
+
["T1 weighted | There is a mild to moderate arachnoid cyst within the anterior left middle cranial fossa"],
|
| 303 |
+
],
|
| 304 |
+
inputs=[
|
| 305 |
+
text_prompt
|
| 306 |
+
],
|
| 307 |
+
)
|
| 308 |
+
|
| 309 |
|
| 310 |
with gr.Column():
|
| 311 |
with gr.Box():
|
|
|
|
| 362 |
],
|
| 363 |
)
|
| 364 |
|
| 365 |
+
# submit_text_btn.click(
|
| 366 |
+
# fn=sample_with_text_fn,
|
| 367 |
+
# inputs=[text_prompt],
|
| 368 |
+
# outputs=[axial_sample_plot, sagittal_sample_plot, coronal_sample_plot],
|
| 369 |
+
# )
|
| 370 |
+
|
| 371 |
# demo.launch(share=True, enable_queue=True)
|
| 372 |
+
# demo.launch(enable_queue=True)
|
| 373 |
+
demo.queue()
|
| 374 |
+
demo.launch()
|
| 375 |
+
|
requirements.txt
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
einops>=0.3.2
|
| 2 |
-
gradio==3.
|
| 3 |
mediapy==1.0.3
|
| 4 |
mlflow
|
| 5 |
nibabel
|
|
|
|
| 1 |
einops>=0.3.2
|
| 2 |
+
gradio==3.3b1
|
| 3 |
mediapy==1.0.3
|
| 4 |
mlflow
|
| 5 |
nibabel
|