Spaces:
Running
Running
Add prompt input field
Browse files
app.py
CHANGED
|
@@ -350,13 +350,16 @@ def download_video(url: str) -> str:
|
|
| 350 |
return None
|
| 351 |
|
| 352 |
|
| 353 |
-
def process(api_key: str, image_path: str):
|
| 354 |
if not api_key or not api_key.strip():
|
| 355 |
gr.Warning("Please enter your API Key")
|
| 356 |
return None
|
| 357 |
if not image_path:
|
| 358 |
gr.Warning("Please upload an image")
|
| 359 |
return None
|
|
|
|
|
|
|
|
|
|
| 360 |
|
| 361 |
try:
|
| 362 |
gr.Info("Uploading image...")
|
|
@@ -364,7 +367,10 @@ def process(api_key: str, image_path: str):
|
|
| 364 |
|
| 365 |
gr.Info("Processing...")
|
| 366 |
payload = {
|
| 367 |
-
"
|
|
|
|
|
|
|
|
|
|
| 368 |
}
|
| 369 |
result = call_api(api_key, MODEL_ENDPOINT, payload)
|
| 370 |
request_id = result.get("id")
|
|
@@ -454,6 +460,11 @@ with gr.Blocks(css=CUSTOM_CSS, title="Seedream v4 Edit - WaveSpeed") as demo:
|
|
| 454 |
source="upload",
|
| 455 |
elem_classes=["upload-area"]
|
| 456 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 457 |
submit_btn = gr.Button("Process", variant="primary", elem_classes="primary-btn")
|
| 458 |
|
| 459 |
# Right Column - Output
|
|
@@ -485,7 +496,7 @@ with gr.Blocks(css=CUSTOM_CSS, title="Seedream v4 Edit - WaveSpeed") as demo:
|
|
| 485 |
# Event binding
|
| 486 |
submit_btn.click(
|
| 487 |
fn=process,
|
| 488 |
-
inputs=[api_key_input, image_input],
|
| 489 |
outputs=output_image,
|
| 490 |
)
|
| 491 |
|
|
|
|
| 350 |
return None
|
| 351 |
|
| 352 |
|
| 353 |
+
def process(api_key: str, image_path: str, prompt: str):
|
| 354 |
if not api_key or not api_key.strip():
|
| 355 |
gr.Warning("Please enter your API Key")
|
| 356 |
return None
|
| 357 |
if not image_path:
|
| 358 |
gr.Warning("Please upload an image")
|
| 359 |
return None
|
| 360 |
+
if not prompt or not prompt.strip():
|
| 361 |
+
gr.Warning("Please enter a prompt")
|
| 362 |
+
return None
|
| 363 |
|
| 364 |
try:
|
| 365 |
gr.Info("Uploading image...")
|
|
|
|
| 367 |
|
| 368 |
gr.Info("Processing...")
|
| 369 |
payload = {
|
| 370 |
+
"images": [image_url],
|
| 371 |
+
"prompt": prompt.strip(),
|
| 372 |
+
"enable_base64_output": False,
|
| 373 |
+
"enable_sync_mode": False,
|
| 374 |
}
|
| 375 |
result = call_api(api_key, MODEL_ENDPOINT, payload)
|
| 376 |
request_id = result.get("id")
|
|
|
|
| 460 |
source="upload",
|
| 461 |
elem_classes=["upload-area"]
|
| 462 |
)
|
| 463 |
+
prompt_input = gr.Textbox(
|
| 464 |
+
label="Prompt",
|
| 465 |
+
placeholder="Describe how to edit the image...",
|
| 466 |
+
lines=3
|
| 467 |
+
)
|
| 468 |
submit_btn = gr.Button("Process", variant="primary", elem_classes="primary-btn")
|
| 469 |
|
| 470 |
# Right Column - Output
|
|
|
|
| 496 |
# Event binding
|
| 497 |
submit_btn.click(
|
| 498 |
fn=process,
|
| 499 |
+
inputs=[api_key_input, image_input, prompt_input],
|
| 500 |
outputs=output_image,
|
| 501 |
)
|
| 502 |
|