Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,7 @@ import base64
|
|
| 7 |
import tempfile
|
| 8 |
import os
|
| 9 |
import threading
|
|
|
|
| 10 |
|
| 11 |
app = Flask(__name__)
|
| 12 |
CORS(app)
|
|
@@ -51,7 +52,8 @@ def generate_and_export_animation(prompt):
|
|
| 51 |
guidance_scale=2.0,
|
| 52 |
num_inference_steps=6
|
| 53 |
)
|
| 54 |
-
|
|
|
|
| 55 |
# Export frames to a temporary video file
|
| 56 |
with tempfile.NamedTemporaryFile(suffix='.mp4', delete=False) as temp_file:
|
| 57 |
temp_video_path = temp_file.name
|
|
@@ -70,8 +72,10 @@ def generate_and_export_animation(prompt):
|
|
| 70 |
|
| 71 |
except Exception as e:
|
| 72 |
print(f"Error generating animation: {e}")
|
| 73 |
-
return None, "Failed to generate animation"
|
| 74 |
-
|
|
|
|
|
|
|
| 75 |
def background(prompt):
|
| 76 |
with app.app_context():
|
| 77 |
temp_response = generate_and_export_animation(prompt)
|
|
|
|
| 7 |
import tempfile
|
| 8 |
import os
|
| 9 |
import threading
|
| 10 |
+
import traceback
|
| 11 |
|
| 12 |
app = Flask(__name__)
|
| 13 |
CORS(app)
|
|
|
|
| 52 |
guidance_scale=2.0,
|
| 53 |
num_inference_steps=6
|
| 54 |
)
|
| 55 |
+
print('Video frames generated')
|
| 56 |
+
|
| 57 |
# Export frames to a temporary video file
|
| 58 |
with tempfile.NamedTemporaryFile(suffix='.mp4', delete=False) as temp_file:
|
| 59 |
temp_video_path = temp_file.name
|
|
|
|
| 72 |
|
| 73 |
except Exception as e:
|
| 74 |
print(f"Error generating animation: {e}")
|
| 75 |
+
# return None, "Failed to generate animation"
|
| 76 |
+
traceback.print_exc() # Print exception details to console
|
| 77 |
+
return jsonify({"error": f"Failed to generate animation: {str(e)}"}), 500
|
| 78 |
+
|
| 79 |
def background(prompt):
|
| 80 |
with app.app_context():
|
| 81 |
temp_response = generate_and_export_animation(prompt)
|