Spaces:
Build error
Build error
emirhanbilgic
commited on
Commit
•
ef101b1
1
Parent(s):
c87da46
hiding unnecessary inputs
Browse files
app.py
CHANGED
@@ -104,28 +104,36 @@ def get_negative_prompt(gender):
|
|
104 |
else: # Random
|
105 |
return "(deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime, mutated hands and fingers:1.4), (deformed, distorted, disfigured:1.3), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, disconnected limbs, mutation, mutated, ugly, disgusting, amputation"
|
106 |
|
107 |
-
|
108 |
-
|
109 |
-
if
|
110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
|
112 |
-
|
113 |
-
|
|
|
|
|
114 |
|
115 |
negative_prompt = get_negative_prompt(gender)
|
116 |
-
|
117 |
baby_image_path = morph_faces(face_image_1, face_image_2)
|
118 |
|
119 |
def generate_images(faceid_embeds, num_outputs=1):
|
120 |
images = ip_model.generate(
|
121 |
-
prompt=
|
122 |
negative_prompt=negative_prompt,
|
123 |
faceid_embeds=faceid_embeds,
|
124 |
num_samples=num_outputs,
|
125 |
-
width=
|
126 |
-
height=
|
127 |
-
num_inference_steps=
|
128 |
-
seed=
|
129 |
)
|
130 |
return images
|
131 |
|
@@ -141,15 +149,11 @@ gr_interface = gr.Interface(
|
|
141 |
inputs=[
|
142 |
gr.Image(type="filepath", label="First Face Image"),
|
143 |
gr.Image(type="filepath", label="Second Face Image"),
|
144 |
-
gr.Textbox(
|
145 |
-
gr.Dropdown(choices=["Boy", "Girl", "Random"], value="Boy", label="Gender")
|
146 |
-
gr.Slider(256, 1024, value=768, step=64, label="Width"),
|
147 |
-
gr.Slider(256, 1024, value=768, step=64, label="Height"),
|
148 |
-
gr.Slider(1, 200, value=30, step=1, label="Number of Inference Steps"),
|
149 |
-
gr.Number(value=None, label="Random Seed")
|
150 |
],
|
151 |
outputs=gr.Image(label="Generated Image"),
|
152 |
-
title="Face Morphing and Image Generation with Stable Diffusion"
|
153 |
)
|
154 |
|
155 |
gr_interface.launch(share=True)
|
|
|
104 |
else: # Random
|
105 |
return "(deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime, mutated hands and fingers:1.4), (deformed, distorted, disfigured:1.3), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, disconnected limbs, mutation, mutated, ugly, disgusting, amputation"
|
106 |
|
107 |
+
def construct_prompt(base_prompt, additional_prompt, gender):
|
108 |
+
full_prompt = base_prompt
|
109 |
+
if gender == "Boy":
|
110 |
+
full_prompt += ", male child, boy"
|
111 |
+
elif gender == "Girl":
|
112 |
+
full_prompt += ", female child, girl"
|
113 |
+
|
114 |
+
if additional_prompt:
|
115 |
+
full_prompt += ", " + additional_prompt
|
116 |
+
|
117 |
+
return full_prompt
|
118 |
|
119 |
+
@spaces.GPU(duration = 40)
|
120 |
+
def generate_image(face_image_1, face_image_2, additional_prompt, gender):
|
121 |
+
base_prompt = "portrait of a 6 y.o. child, 8k, HD, happy, perfect eyes, cute"
|
122 |
+
full_prompt = construct_prompt(base_prompt, additional_prompt, gender)
|
123 |
|
124 |
negative_prompt = get_negative_prompt(gender)
|
|
|
125 |
baby_image_path = morph_faces(face_image_1, face_image_2)
|
126 |
|
127 |
def generate_images(faceid_embeds, num_outputs=1):
|
128 |
images = ip_model.generate(
|
129 |
+
prompt=full_prompt,
|
130 |
negative_prompt=negative_prompt,
|
131 |
faceid_embeds=faceid_embeds,
|
132 |
num_samples=num_outputs,
|
133 |
+
width=768,
|
134 |
+
height=768,
|
135 |
+
num_inference_steps=40,
|
136 |
+
seed=None
|
137 |
)
|
138 |
return images
|
139 |
|
|
|
149 |
inputs=[
|
150 |
gr.Image(type="filepath", label="First Face Image"),
|
151 |
gr.Image(type="filepath", label="Second Face Image"),
|
152 |
+
gr.Textbox(label="Prompt"),
|
153 |
+
gr.Dropdown(choices=["Boy", "Girl", "Random"], value="Boy", label="Gender")
|
|
|
|
|
|
|
|
|
154 |
],
|
155 |
outputs=gr.Image(label="Generated Image"),
|
156 |
+
title="Face Morphing and Image Generation with Stable Diffusion",
|
157 |
)
|
158 |
|
159 |
gr_interface.launch(share=True)
|