Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,11 @@ pipeline = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-re
|
|
9 |
|
10 |
def generate_image(uploaded_file, surgery_option, additional_info):
|
11 |
if uploaded_file is not None:
|
12 |
-
|
|
|
|
|
|
|
|
|
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]
|
@@ -17,17 +21,17 @@ def generate_image(uploaded_file, surgery_option, additional_info):
|
|
17 |
else:
|
18 |
return "No image uploaded."
|
19 |
|
20 |
-
surgery_options = ["
|
21 |
|
22 |
iface = gr.Interface(
|
23 |
fn=generate_image,
|
24 |
inputs=[
|
25 |
-
gr.Image(type="
|
26 |
gr.Dropdown(surgery_options, label="Select Surgery Option"),
|
27 |
gr.Textbox(label="Additional Information")
|
28 |
],
|
29 |
outputs=gr.Image(type="pil", label="Generated Image"),
|
30 |
-
title="
|
31 |
description="Visualize the results of a surgical procedure before it happens."
|
32 |
)
|
33 |
|
|
|
9 |
|
10 |
def generate_image(uploaded_file, surgery_option, additional_info):
|
11 |
if uploaded_file is not None:
|
12 |
+
if isinstance(uploaded_file, bytes):
|
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]
|
|
|
21 |
else:
|
22 |
return "No image uploaded."
|
23 |
|
24 |
+
surgery_options = ["Facelift", "Rhinoplasty", "Chin Augmentation"]
|
25 |
|
26 |
iface = gr.Interface(
|
27 |
fn=generate_image,
|
28 |
inputs=[
|
29 |
+
gr.Image(type="auto", label="Upload an Image"),
|
30 |
gr.Dropdown(surgery_options, label="Select Surgery Option"),
|
31 |
gr.Textbox(label="Additional Information")
|
32 |
],
|
33 |
outputs=gr.Image(type="pil", label="Generated Image"),
|
34 |
+
title="AI.HAIR - Version of Plastic Surgery by Bulut",
|
35 |
description="Visualize the results of a surgical procedure before it happens."
|
36 |
)
|
37 |
|