Spaces:
Sleeping
Sleeping
Fix syntax error in verify_video endpoint and ensure challenge endpoint exists
Browse files
app.py
CHANGED
|
@@ -291,51 +291,33 @@ def verify_image():
|
|
| 291 |
|
| 292 |
@app.route('/verify/video', methods=['POST'])
|
| 293 |
def verify_video():
|
| 294 |
-
|
| 295 |
-
Verify video for deepfake/manipulation
|
| 296 |
-
|
| 297 |
-
Accepts:
|
| 298 |
-
- multipart/form-data with 'video' file
|
| 299 |
-
- JSON with 'video_url' (URL to video)
|
| 300 |
-
"""
|
| 301 |
try:
|
| 302 |
-
# Check for file upload
|
| 303 |
if 'video' in request.files:
|
| 304 |
file = request.files['video']
|
| 305 |
-
|
| 306 |
if file.filename == '':
|
| 307 |
return jsonify({'error': 'No file selected'}), 400
|
| 308 |
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
# Save to temp file
|
| 313 |
-
filename = secure_filename(file.filename)
|
| 314 |
-
temp_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
|
| 315 |
file.save(temp_path)
|
| 316 |
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
finally:
|
| 320 |
-
# Cleanup temp file
|
| 321 |
-
if os.path.exists(temp_path):
|
| 322 |
-
os.remove(temp_path)
|
| 323 |
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
data = request.get_json()
|
| 327 |
-
|
| 328 |
-
if 'video_url' in data:
|
| 329 |
-
result = engine.verify_video(data['video_url'])
|
| 330 |
-
else:
|
| 331 |
-
return jsonify({'error': 'No video provided'}), 400
|
| 332 |
-
else:
|
| 333 |
-
return jsonify({'error': 'Invalid request format'}), 400
|
| 334 |
-
|
| 335 |
-
return jsonify(result.to_dict())
|
| 336 |
-
|
| 337 |
except Exception as e:
|
|
|
|
| 338 |
return jsonify({'error': str(e)}), 500
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 339 |
|
| 340 |
|
| 341 |
@app.route('/challenge/evaluate', methods=['POST'])
|
|
|
|
| 291 |
|
| 292 |
@app.route('/verify/video', methods=['POST'])
|
| 293 |
def verify_video():
|
| 294 |
+
temp_path = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 295 |
try:
|
|
|
|
| 296 |
if 'video' in request.files:
|
| 297 |
file = request.files['video']
|
|
|
|
| 298 |
if file.filename == '':
|
| 299 |
return jsonify({'error': 'No file selected'}), 400
|
| 300 |
|
| 301 |
+
# Save temporary file
|
| 302 |
+
temp_path = "temp_video.mp4"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 303 |
file.save(temp_path)
|
| 304 |
|
| 305 |
+
result = engine.verify_video(temp_path)
|
| 306 |
+
return jsonify(result.to_dict())
|
|
|
|
|
|
|
|
|
|
|
|
|
| 307 |
|
| 308 |
+
return jsonify({'error': 'No video provided'}), 400
|
| 309 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 310 |
except Exception as e:
|
| 311 |
+
print(f"[Video] Error: {e}")
|
| 312 |
return jsonify({'error': str(e)}), 500
|
| 313 |
+
finally:
|
| 314 |
+
# Cleanup
|
| 315 |
+
import os
|
| 316 |
+
if temp_path and os.path.exists(temp_path):
|
| 317 |
+
try:
|
| 318 |
+
os.remove(temp_path)
|
| 319 |
+
except:
|
| 320 |
+
pass
|
| 321 |
|
| 322 |
|
| 323 |
@app.route('/challenge/evaluate', methods=['POST'])
|