Spaces:
Sleeping
Sleeping
Muhammad Waqas commited on
Commit ·
d468814
1
Parent(s): 65fdcb1
Added: Generate image to video
Browse files
app.py
CHANGED
|
@@ -515,8 +515,6 @@ def image_to_video():
|
|
| 515 |
# Queue the prompt and wait for completion
|
| 516 |
prompt_id = queue_prompt(workflow, token)
|
| 517 |
|
| 518 |
-
return jsonify({'prompt_id': prompt_id, 'message': 'Prompt queued successfully', 'get_video_url': f'https://gosign-de-comfyui-api.hf.space/get_video/{prompt_id}'}), 202
|
| 519 |
-
|
| 520 |
|
| 521 |
# Wait for workflow execution to complete
|
| 522 |
# last_ping = time.time()
|
|
@@ -524,10 +522,13 @@ def image_to_video():
|
|
| 524 |
|
| 525 |
# Wait for workflow execution to complete
|
| 526 |
while True:
|
| 527 |
-
|
| 528 |
-
if
|
| 529 |
-
|
| 530 |
-
|
|
|
|
|
|
|
|
|
|
| 531 |
|
| 532 |
# Send a ping if PING_INTERVAL has passed
|
| 533 |
# if time.time() - last_ping > PING_INTERVAL:
|
|
@@ -583,11 +584,10 @@ def image_to_video():
|
|
| 583 |
return jsonify({'error': str(e)}), 500
|
| 584 |
|
| 585 |
finally:
|
| 586 |
-
pass
|
| 587 |
# Always delete the image if it was saved
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
|
| 591 |
|
| 592 |
|
| 593 |
if __name__ == '__main__':
|
|
|
|
| 515 |
# Queue the prompt and wait for completion
|
| 516 |
prompt_id = queue_prompt(workflow, token)
|
| 517 |
|
|
|
|
|
|
|
| 518 |
|
| 519 |
# Wait for workflow execution to complete
|
| 520 |
# last_ping = time.time()
|
|
|
|
| 522 |
|
| 523 |
# Wait for workflow execution to complete
|
| 524 |
while True:
|
| 525 |
+
out = ws.recv()
|
| 526 |
+
if isinstance(out, str):
|
| 527 |
+
message = json.loads(out)
|
| 528 |
+
if message['type'] == 'executing':
|
| 529 |
+
data = message['data']
|
| 530 |
+
if data['node'] is None and data['prompt_id'] == prompt_id:
|
| 531 |
+
break # Execution is done
|
| 532 |
|
| 533 |
# Send a ping if PING_INTERVAL has passed
|
| 534 |
# if time.time() - last_ping > PING_INTERVAL:
|
|
|
|
| 584 |
return jsonify({'error': str(e)}), 500
|
| 585 |
|
| 586 |
finally:
|
|
|
|
| 587 |
# Always delete the image if it was saved
|
| 588 |
+
if image_path and os.path.exists(image_path):
|
| 589 |
+
os.remove(image_path)
|
| 590 |
+
print(f"Deleted temporary image: {image_path}", flush=True)
|
| 591 |
|
| 592 |
|
| 593 |
if __name__ == '__main__':
|