Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -149,14 +149,14 @@ def generate_image(subject_images, prompt):
|
|
| 149 |
return None, "Task timed out after 10 minutes"
|
| 150 |
|
| 151 |
# ===== GRADIO INTERFACE =====
|
| 152 |
-
def process_interface(
|
| 153 |
-
# Filter out None
|
| 154 |
-
|
| 155 |
|
| 156 |
-
if len(
|
| 157 |
return None, None, "Please upload at least 2 subject images"
|
| 158 |
|
| 159 |
-
output_path, error = generate_image(
|
| 160 |
if error:
|
| 161 |
return None, None, error
|
| 162 |
|
|
@@ -170,24 +170,24 @@ with gr.Blocks(title="Kling AI Multi-Image Generator") as app:
|
|
| 170 |
with gr.Column():
|
| 171 |
gr.Markdown("### Input Settings")
|
| 172 |
with gr.Row():
|
| 173 |
-
subject_image1 = gr.Image(type="filepath", label="Subject Image 1")
|
| 174 |
-
subject_image2 = gr.Image(type="filepath", label="Subject Image 2")
|
| 175 |
with gr.Row():
|
| 176 |
subject_image3 = gr.Image(type="filepath", label="Subject Image 3 (Optional)")
|
| 177 |
subject_image4 = gr.Image(type="filepath", label="Subject Image 4 (Optional)")
|
| 178 |
|
| 179 |
prompt_input = gr.Textbox(
|
| 180 |
label="Transformation Prompt",
|
| 181 |
-
placeholder="Describe how to combine these images
|
| 182 |
)
|
| 183 |
|
| 184 |
generate_btn = gr.Button("Generate", variant="primary")
|
| 185 |
|
| 186 |
-
gr.Markdown("### Requirements")
|
| 187 |
gr.Markdown("""
|
| 188 |
-
- **
|
| 189 |
- Max 4 images total
|
| 190 |
-
- Max size per image
|
| 191 |
- Formats: JPG, PNG
|
| 192 |
- Min dimensions: 300x300px
|
| 193 |
""")
|
|
@@ -195,17 +195,13 @@ with gr.Blocks(title="Kling AI Multi-Image Generator") as app:
|
|
| 195 |
with gr.Column():
|
| 196 |
gr.Markdown("### Output")
|
| 197 |
output_image = gr.Image(label="Generated Image", interactive=False, height=400)
|
| 198 |
-
output_file = gr.File(label="Download Result"
|
| 199 |
status_output = gr.Textbox(label="Status", interactive=False)
|
| 200 |
|
|
|
|
| 201 |
generate_btn.click(
|
| 202 |
fn=process_interface,
|
| 203 |
-
inputs=[
|
| 204 |
-
subject_image1,
|
| 205 |
-
subject_image2,
|
| 206 |
-
subject_image3,
|
| 207 |
-
subject_image4
|
| 208 |
-
]), prompt_input],
|
| 209 |
outputs=[output_image, output_file, status_output]
|
| 210 |
)
|
| 211 |
|
|
|
|
| 149 |
return None, "Task timed out after 10 minutes"
|
| 150 |
|
| 151 |
# ===== GRADIO INTERFACE =====
|
| 152 |
+
def process_interface(subject_image1, subject_image2, subject_image3, subject_image4, prompt):
|
| 153 |
+
# Filter out None/empty images
|
| 154 |
+
subject_images = [img for img in [subject_image1, subject_image2, subject_image3, subject_image4] if img]
|
| 155 |
|
| 156 |
+
if len(subject_images) < 2:
|
| 157 |
return None, None, "Please upload at least 2 subject images"
|
| 158 |
|
| 159 |
+
output_path, error = generate_image(subject_images, prompt)
|
| 160 |
if error:
|
| 161 |
return None, None, error
|
| 162 |
|
|
|
|
| 170 |
with gr.Column():
|
| 171 |
gr.Markdown("### Input Settings")
|
| 172 |
with gr.Row():
|
| 173 |
+
subject_image1 = gr.Image(type="filepath", label="Subject Image 1 *")
|
| 174 |
+
subject_image2 = gr.Image(type="filepath", label="Subject Image 2 *")
|
| 175 |
with gr.Row():
|
| 176 |
subject_image3 = gr.Image(type="filepath", label="Subject Image 3 (Optional)")
|
| 177 |
subject_image4 = gr.Image(type="filepath", label="Subject Image 4 (Optional)")
|
| 178 |
|
| 179 |
prompt_input = gr.Textbox(
|
| 180 |
label="Transformation Prompt",
|
| 181 |
+
placeholder="Describe how to combine these images"
|
| 182 |
)
|
| 183 |
|
| 184 |
generate_btn = gr.Button("Generate", variant="primary")
|
| 185 |
|
| 186 |
+
gr.Markdown("### Requirements (* = required)")
|
| 187 |
gr.Markdown("""
|
| 188 |
+
- **At least 2 subject images** (marked with *)
|
| 189 |
- Max 4 images total
|
| 190 |
+
- Max size: 10MB per image
|
| 191 |
- Formats: JPG, PNG
|
| 192 |
- Min dimensions: 300x300px
|
| 193 |
""")
|
|
|
|
| 195 |
with gr.Column():
|
| 196 |
gr.Markdown("### Output")
|
| 197 |
output_image = gr.Image(label="Generated Image", interactive=False, height=400)
|
| 198 |
+
output_file = gr.File(label="Download Result")
|
| 199 |
status_output = gr.Textbox(label="Status", interactive=False)
|
| 200 |
|
| 201 |
+
# Modified inputs to accept individual components
|
| 202 |
generate_btn.click(
|
| 203 |
fn=process_interface,
|
| 204 |
+
inputs=[subject_image1, subject_image2, subject_image3, subject_image4, prompt_input],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
outputs=[output_image, output_file, status_output]
|
| 206 |
)
|
| 207 |
|