Spaces:
Sleeping
Sleeping
Muhammad Waqas
commited on
Commit
·
5fa4d82
1
Parent(s):
d468814
Added: Generate image to video
Browse files
app.py
CHANGED
|
@@ -24,7 +24,7 @@ load_dotenv()
|
|
| 24 |
app = Flask(__name__)
|
| 25 |
|
| 26 |
# Increase timeout limit
|
| 27 |
-
WSGIRequestHandler.timeout = 3600
|
| 28 |
|
| 29 |
ALLOWED_EXTENSIONS = {'jpg', 'jpeg', 'png', 'webp'} # Define supported image types
|
| 30 |
|
|
@@ -517,23 +517,20 @@ def image_to_video():
|
|
| 517 |
|
| 518 |
|
| 519 |
# Wait for workflow execution to complete
|
| 520 |
-
|
| 521 |
-
|
| 522 |
|
| 523 |
# Wait for workflow execution to complete
|
| 524 |
while True:
|
| 525 |
-
|
| 526 |
-
if
|
| 527 |
-
|
| 528 |
-
|
| 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 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
|
| 538 |
# Fetch the history of the workflow
|
| 539 |
history = get_history(prompt_id, token).get(prompt_id, {})
|
|
|
|
| 24 |
app = Flask(__name__)
|
| 25 |
|
| 26 |
# Increase timeout limit
|
| 27 |
+
# WSGIRequestHandler.timeout = 3600
|
| 28 |
|
| 29 |
ALLOWED_EXTENSIONS = {'jpg', 'jpeg', 'png', 'webp'} # Define supported image types
|
| 30 |
|
|
|
|
| 517 |
|
| 518 |
|
| 519 |
# Wait for workflow execution to complete
|
| 520 |
+
last_ping = time.time()
|
| 521 |
+
PING_INTERVAL = 30
|
| 522 |
|
| 523 |
# Wait for workflow execution to complete
|
| 524 |
while True:
|
| 525 |
+
message = json.loads(ws.recv())
|
| 526 |
+
if message.get('type') == 'executing' and message['data']['node'] is None \
|
| 527 |
+
and message['data']['prompt_id'] == prompt_id:
|
| 528 |
+
break
|
|
|
|
|
|
|
|
|
|
| 529 |
|
| 530 |
# Send a ping if PING_INTERVAL has passed
|
| 531 |
+
if time.time() - last_ping > PING_INTERVAL:
|
| 532 |
+
ws.send('ping')
|
| 533 |
+
last_ping = time.time()
|
| 534 |
|
| 535 |
# Fetch the history of the workflow
|
| 536 |
history = get_history(prompt_id, token).get(prompt_id, {})
|