Update app.py
Browse files
app.py
CHANGED
@@ -7,13 +7,9 @@ import io
|
|
7 |
|
8 |
pipeline = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0")
|
9 |
|
10 |
-
def generate_image(
|
11 |
-
if
|
12 |
-
|
13 |
-
pil_image = Image.open(io.BytesIO(uploaded_file)).convert("RGB")
|
14 |
-
else:
|
15 |
-
pil_image = uploaded_file.convert("RGB")
|
16 |
-
|
17 |
init_image = load_image(pil_image).convert("RGB")
|
18 |
prompt = f"generate image of how this person would look after {surgery_option} also use this additional information {additional_info}"
|
19 |
image = pipeline(prompt, image=init_image).images[0]
|
@@ -26,7 +22,7 @@ surgery_options = ["Facelift", "Rhinoplasty", "Chin Augmentation"]
|
|
26 |
iface = gr.Interface(
|
27 |
fn=generate_image,
|
28 |
inputs=[
|
29 |
-
gr.Image(type="
|
30 |
gr.Dropdown(surgery_options, label="Select Surgery Option"),
|
31 |
gr.Textbox(label="Additional Information")
|
32 |
],
|
@@ -36,3 +32,4 @@ iface = gr.Interface(
|
|
36 |
)
|
37 |
|
38 |
iface.launch()
|
|
|
|
7 |
|
8 |
pipeline = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0")
|
9 |
|
10 |
+
def generate_image(uploaded_image, surgery_option, additional_info):
|
11 |
+
if uploaded_image is not None:
|
12 |
+
pil_image = uploaded_image.convert("RGB")
|
|
|
|
|
|
|
|
|
13 |
init_image = load_image(pil_image).convert("RGB")
|
14 |
prompt = f"generate image of how this person would look after {surgery_option} also use this additional information {additional_info}"
|
15 |
image = pipeline(prompt, image=init_image).images[0]
|
|
|
22 |
iface = gr.Interface(
|
23 |
fn=generate_image,
|
24 |
inputs=[
|
25 |
+
gr.Image(type="pil", label="Upload an Image"),
|
26 |
gr.Dropdown(surgery_options, label="Select Surgery Option"),
|
27 |
gr.Textbox(label="Additional Information")
|
28 |
],
|
|
|
32 |
)
|
33 |
|
34 |
iface.launch()
|
35 |
+
|