Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -354,7 +354,10 @@ def on_video_upload_change(video_file, use_blip):
|
|
| 354 |
"""Handle video upload and store video info for toggling"""
|
| 355 |
global current_video_file, blip_generated_name, original_filename, current_video_url
|
| 356 |
|
|
|
|
|
|
|
| 357 |
if not video_file:
|
|
|
|
| 358 |
current_video_file = None
|
| 359 |
blip_generated_name = ""
|
| 360 |
original_filename = ""
|
|
@@ -365,9 +368,7 @@ def on_video_upload_change(video_file, use_blip):
|
|
| 365 |
current_video_file = video_file
|
| 366 |
current_video_url = None # Clear URL when uploading file
|
| 367 |
|
| 368 |
-
|
| 369 |
-
print(f"DEBUG: video_file type: {type(video_file)}")
|
| 370 |
-
print(f"DEBUG: video_file attributes: {dir(video_file)}")
|
| 371 |
|
| 372 |
# Generate original filename FIRST - try multiple ways
|
| 373 |
original_filename = "uploaded_video" # Default fallback
|
|
@@ -404,6 +405,7 @@ def on_video_upload_change(video_file, use_blip):
|
|
| 404 |
# Generate BLIP name
|
| 405 |
blip_generated_name = ""
|
| 406 |
if use_blip:
|
|
|
|
| 407 |
frames, _ = read_video_frames(video_file, 999, -1, 480)
|
| 408 |
if len(frames) > 0:
|
| 409 |
frame = frames[len(frames) // 2]
|
|
@@ -413,11 +415,12 @@ def on_video_upload_change(video_file, use_blip):
|
|
| 413 |
# Return appropriate name based on BLIP setting
|
| 414 |
final_name = blip_generated_name if (use_blip and blip_generated_name) else original_filename
|
| 415 |
print(f"DEBUG: Final name returned: '{final_name}' (BLIP: {use_blip})")
|
|
|
|
| 416 |
return final_name, "", "Video uploaded successfully!" # Clear URL when video uploaded
|
| 417 |
|
| 418 |
except Exception as e:
|
| 419 |
error_msg = f"Upload processing failed: {str(e)}"
|
| 420 |
-
print(error_msg)
|
| 421 |
return "uploaded_video", gr.update(), error_msg
|
| 422 |
|
| 423 |
def on_video_url_change(url, use_blip):
|
|
@@ -694,4 +697,4 @@ if __name__ == "__main__":
|
|
| 694 |
server_name="0.0.0.0",
|
| 695 |
server_port=7860,
|
| 696 |
show_error=True
|
| 697 |
-
)
|
|
|
|
| 354 |
"""Handle video upload and store video info for toggling"""
|
| 355 |
global current_video_file, blip_generated_name, original_filename, current_video_url
|
| 356 |
|
| 357 |
+
print(f"DEBUG: Upload handler called with video_file: {video_file}")
|
| 358 |
+
|
| 359 |
if not video_file:
|
| 360 |
+
print("DEBUG: No video file - clearing state")
|
| 361 |
current_video_file = None
|
| 362 |
blip_generated_name = ""
|
| 363 |
original_filename = ""
|
|
|
|
| 368 |
current_video_file = video_file
|
| 369 |
current_video_url = None # Clear URL when uploading file
|
| 370 |
|
| 371 |
+
print(f"DEBUG: Processing upload - video_file type: {type(video_file)}")
|
|
|
|
|
|
|
| 372 |
|
| 373 |
# Generate original filename FIRST - try multiple ways
|
| 374 |
original_filename = "uploaded_video" # Default fallback
|
|
|
|
| 405 |
# Generate BLIP name
|
| 406 |
blip_generated_name = ""
|
| 407 |
if use_blip:
|
| 408 |
+
print("DEBUG: Starting BLIP processing...")
|
| 409 |
frames, _ = read_video_frames(video_file, 999, -1, 480)
|
| 410 |
if len(frames) > 0:
|
| 411 |
frame = frames[len(frames) // 2]
|
|
|
|
| 415 |
# Return appropriate name based on BLIP setting
|
| 416 |
final_name = blip_generated_name if (use_blip and blip_generated_name) else original_filename
|
| 417 |
print(f"DEBUG: Final name returned: '{final_name}' (BLIP: {use_blip})")
|
| 418 |
+
print(f"DEBUG: Returning - filename: '{final_name}', clear URL: '', status: 'success'")
|
| 419 |
return final_name, "", "Video uploaded successfully!" # Clear URL when video uploaded
|
| 420 |
|
| 421 |
except Exception as e:
|
| 422 |
error_msg = f"Upload processing failed: {str(e)}"
|
| 423 |
+
print(f"DEBUG ERROR: {error_msg}")
|
| 424 |
return "uploaded_video", gr.update(), error_msg
|
| 425 |
|
| 426 |
def on_video_url_change(url, use_blip):
|
|
|
|
| 697 |
server_name="0.0.0.0",
|
| 698 |
server_port=7860,
|
| 699 |
show_error=True
|
| 700 |
+
)
|