Spaces:
Paused
Paused
added diffusion model
Browse files
app.py
CHANGED
@@ -1,5 +1,8 @@
|
|
1 |
# Import convention
|
2 |
import streamlit as st
|
|
|
|
|
|
|
3 |
|
4 |
organ = st.selectbox('Organ', ['Brain', 'Thorax'], index=None)
|
5 |
modality = st.selectbox('Modality', ['Magnetic Resonance Imaging', 'Computed Tomography'], index=None)
|
@@ -8,4 +11,11 @@ style = st.selectbox('Style', ['Picasso', 'Van Gogh'], index=None)
|
|
8 |
prompt_lst = [organ, modality, style]
|
9 |
if None not in prompt_lst:
|
10 |
prompt = ','.join(prompt_lst)
|
11 |
-
print(prompt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# Import convention
|
2 |
import streamlit as st
|
3 |
+
from diffusers import DiffusionPipeline
|
4 |
+
import matplotlib.pyplot as plt
|
5 |
+
import torch
|
6 |
|
7 |
organ = st.selectbox('Organ', ['Brain', 'Thorax'], index=None)
|
8 |
modality = st.selectbox('Modality', ['Magnetic Resonance Imaging', 'Computed Tomography'], index=None)
|
|
|
11 |
prompt_lst = [organ, modality, style]
|
12 |
if None not in prompt_lst:
|
13 |
prompt = ','.join(prompt_lst)
|
14 |
+
print(prompt)
|
15 |
+
|
16 |
+
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, variant="fp16")
|
17 |
+
pipe.to("cuda")
|
18 |
+
|
19 |
+
prompt += " high resolution, photorealistic"
|
20 |
+
image = pipe(prompt=prompt).images[0]
|
21 |
+
st.image(image)
|