File size: 745 Bytes
4a7650f
 
7638e59
 
 
4a7650f
 
 
 
 
 
 
1ae33da
7638e59
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Import convention
import streamlit as st
from diffusers import DiffusionPipeline
import matplotlib.pyplot as plt
import torch

organ = st.selectbox('Organ', ['Brain', 'Thorax'], index=None)
modality = st.selectbox('Modality', ['Magnetic Resonance Imaging', 'Computed Tomography'], index=None)
style = st.selectbox('Style', ['Picasso', 'Van Gogh'], index=None)

prompt_lst = [organ, modality, style]
if None not in prompt_lst:
    prompt = ','.join(prompt_lst) 
    print(prompt)

    pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, variant="fp16")
    pipe.to("cuda")

    prompt += " high resolution, photorealistic"
    image = pipe(prompt=prompt).images[0]
    st.image(image)