Spaces:
Sleeping
Sleeping
Muhammad Waqas
commited on
Commit
·
ab345d8
1
Parent(s):
74a0792
Added: Generate image to video
Browse files
app.py
CHANGED
|
@@ -14,7 +14,6 @@ from PIL import Image
|
|
| 14 |
from werkzeug.utils import secure_filename
|
| 15 |
import urllib.parse
|
| 16 |
import urllib.request
|
| 17 |
-
import time
|
| 18 |
|
| 19 |
# Load environment variables from the .env file
|
| 20 |
load_dotenv()
|
|
@@ -331,7 +330,7 @@ def image_to_video():
|
|
| 331 |
except ValueError as e:
|
| 332 |
return jsonify({'error': str(e)}), 400
|
| 333 |
|
| 334 |
-
|
| 335 |
# Wait for workflow execution to complete
|
| 336 |
last_ping = time.time() # Track the last ping time
|
| 337 |
PING_INTERVAL = 30 # Send a ping every 30 seconds
|
|
@@ -341,12 +340,12 @@ def image_to_video():
|
|
| 341 |
message = json.loads(ws.recv())
|
| 342 |
if message.get('type') == 'executing' and message['data']['node'] is None and message['data']['prompt_id'] == prompt_id:
|
| 343 |
break
|
| 344 |
-
|
| 345 |
# Send a ping if PING_INTERVAL has passed
|
| 346 |
if time.time() - last_ping > PING_INTERVAL:
|
| 347 |
ws.send('ping')
|
| 348 |
last_ping = time.time()
|
| 349 |
-
|
| 350 |
# Fetch the complete history for the provided prompt_id
|
| 351 |
history = get_history(prompt_id, token).get(prompt_id, {})
|
| 352 |
# print(f"History for prompt {prompt_id}: {history}")
|
|
@@ -388,4 +387,4 @@ def image_to_video():
|
|
| 388 |
return response
|
| 389 |
|
| 390 |
if __name__ == '__main__':
|
| 391 |
-
app.run(host='0.0.0.0', port=7860, debug=True)
|
|
|
|
| 14 |
from werkzeug.utils import secure_filename
|
| 15 |
import urllib.parse
|
| 16 |
import urllib.request
|
|
|
|
| 17 |
|
| 18 |
# Load environment variables from the .env file
|
| 19 |
load_dotenv()
|
|
|
|
| 330 |
except ValueError as e:
|
| 331 |
return jsonify({'error': str(e)}), 400
|
| 332 |
|
| 333 |
+
|
| 334 |
# Wait for workflow execution to complete
|
| 335 |
last_ping = time.time() # Track the last ping time
|
| 336 |
PING_INTERVAL = 30 # Send a ping every 30 seconds
|
|
|
|
| 340 |
message = json.loads(ws.recv())
|
| 341 |
if message.get('type') == 'executing' and message['data']['node'] is None and message['data']['prompt_id'] == prompt_id:
|
| 342 |
break
|
| 343 |
+
|
| 344 |
# Send a ping if PING_INTERVAL has passed
|
| 345 |
if time.time() - last_ping > PING_INTERVAL:
|
| 346 |
ws.send('ping')
|
| 347 |
last_ping = time.time()
|
| 348 |
+
|
| 349 |
# Fetch the complete history for the provided prompt_id
|
| 350 |
history = get_history(prompt_id, token).get(prompt_id, {})
|
| 351 |
# print(f"History for prompt {prompt_id}: {history}")
|
|
|
|
| 387 |
return response
|
| 388 |
|
| 389 |
if __name__ == '__main__':
|
| 390 |
+
app.run(host='0.0.0.0', port=7860, debug=True)
|