Muhammad Waqas commited on
Commit
5fa4d82
·
1 Parent(s): d468814

Added: Generate image to video

Browse files
Files changed (1) hide show
  1. app.py +10 -13
app.py CHANGED
@@ -24,7 +24,7 @@ load_dotenv()
24
  app = Flask(__name__)
25
 
26
  # Increase timeout limit
27
- WSGIRequestHandler.timeout = 3600 # Set to 60 minutes
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
- # last_ping = time.time()
521
- # PING_INTERVAL = 30
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:
535
- # ws.send('ping')
536
- # last_ping = time.time()
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, {})