Upload server.py with huggingface_hub
Browse files
server.py
CHANGED
|
@@ -79,7 +79,8 @@ def generate():
|
|
| 79 |
from diffusers.utils import export_to_video
|
| 80 |
|
| 81 |
data = request.get_json(force=True)
|
| 82 |
-
|
|
|
|
| 83 |
params = data.get("parameters", {})
|
| 84 |
|
| 85 |
# Diffusion Forcing params - defaults for ~10s video
|
|
@@ -135,6 +136,10 @@ def generate():
|
|
| 135 |
"format": "mp4",
|
| 136 |
"frames": len(output),
|
| 137 |
"duration": duration,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
})
|
| 139 |
except Exception as e:
|
| 140 |
tb = traceback.format_exc()
|
|
@@ -142,6 +147,12 @@ def generate():
|
|
| 142 |
print(f"[video-long] TRACEBACK:\n{tb}", flush=True)
|
| 143 |
return jsonify({"error": str(e), "traceback": tb, "success": False}), 200
|
| 144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
if __name__ == "__main__":
|
| 146 |
load_model()
|
| 147 |
app.run(host="0.0.0.0", port=8000)
|
|
|
|
| 79 |
from diffusers.utils import export_to_video
|
| 80 |
|
| 81 |
data = request.get_json(force=True)
|
| 82 |
+
# Support both HF format (inputs) and backend format (prompt)
|
| 83 |
+
prompt = data.get("inputs", "") or data.get("prompt", "")
|
| 84 |
params = data.get("parameters", {})
|
| 85 |
|
| 86 |
# Diffusion Forcing params - defaults for ~10s video
|
|
|
|
| 136 |
"format": "mp4",
|
| 137 |
"frames": len(output),
|
| 138 |
"duration": duration,
|
| 139 |
+
"success": True,
|
| 140 |
+
"video_base64": video_b64,
|
| 141 |
+
"duration_seconds": duration,
|
| 142 |
+
"model": "skyreels-v2-df-1.3b",
|
| 143 |
})
|
| 144 |
except Exception as e:
|
| 145 |
tb = traceback.format_exc()
|
|
|
|
| 147 |
print(f"[video-long] TRACEBACK:\n{tb}", flush=True)
|
| 148 |
return jsonify({"error": str(e), "traceback": tb, "success": False}), 200
|
| 149 |
|
| 150 |
+
# Also add /api/generate-video route for backend compatibility
|
| 151 |
+
@app.route("/api/generate-video", methods=["POST"])
|
| 152 |
+
def api_generate_video():
|
| 153 |
+
"""Handle the backend's /api/generate-video format by forwarding to generate()"""
|
| 154 |
+
return generate()
|
| 155 |
+
|
| 156 |
if __name__ == "__main__":
|
| 157 |
load_model()
|
| 158 |
app.run(host="0.0.0.0", port=8000)
|