Spaces:
Sleeping
Sleeping
Shubham
commited on
Commit
Β·
6c2496c
1
Parent(s):
54566d0
Fix import error in app_gradio.py
Browse files- app_gradio.py +11 -15
app_gradio.py
CHANGED
|
@@ -7,13 +7,11 @@ from pathlib import Path
|
|
| 7 |
# Add project root to path
|
| 8 |
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
| 9 |
|
| 10 |
-
from detect_sync import
|
| 11 |
-
from SyncNetInstance_FCN import SyncNetInstance as SyncNetInstanceFCN
|
| 12 |
|
| 13 |
# Initialize model
|
| 14 |
print("Loading FCN-SyncNet model...")
|
| 15 |
-
fcn_model =
|
| 16 |
-
fcn_model.loadParameters("checkpoints/syncnet_fcn_epoch2.pth")
|
| 17 |
print("Model loaded successfully!")
|
| 18 |
|
| 19 |
def analyze_video(video_file):
|
|
@@ -32,14 +30,12 @@ def analyze_video(video_file):
|
|
| 32 |
|
| 33 |
print(f"Processing video: {video_file}")
|
| 34 |
|
| 35 |
-
# Detect offset
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
calibration_baseline=-15
|
| 42 |
-
)
|
| 43 |
|
| 44 |
# Interpret results
|
| 45 |
if offset > 0:
|
|
@@ -66,7 +62,7 @@ def analyze_video(video_file):
|
|
| 66 |
conf_text = "Low"
|
| 67 |
conf_emoji = "π΄"
|
| 68 |
|
| 69 |
-
|
| 70 |
## π Sync Detection Results
|
| 71 |
|
| 72 |
### {sync_status}
|
|
@@ -79,7 +75,7 @@ def analyze_video(video_file):
|
|
| 79 |
|
| 80 |
- **Offset:** {offset} frames
|
| 81 |
- **Confidence:** {conf_emoji} {conf:.2%} ({conf_text})
|
| 82 |
-
- **
|
| 83 |
|
| 84 |
---
|
| 85 |
|
|
@@ -98,7 +94,7 @@ def analyze_video(video_file):
|
|
| 98 |
- **Calibration:** Applied (offset=3, scale=-0.5, baseline=-15)
|
| 99 |
"""
|
| 100 |
|
| 101 |
-
return
|
| 102 |
|
| 103 |
except Exception as e:
|
| 104 |
return f"β Error processing video: {str(e)}\n\nPlease ensure the video has both audio and video tracks."
|
|
|
|
| 7 |
# Add project root to path
|
| 8 |
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
| 9 |
|
| 10 |
+
from detect_sync import load_model, detect_offset
|
|
|
|
| 11 |
|
| 12 |
# Initialize model
|
| 13 |
print("Loading FCN-SyncNet model...")
|
| 14 |
+
fcn_model = load_model("checkpoints/syncnet_fcn_epoch2.pth")
|
|
|
|
| 15 |
print("Model loaded successfully!")
|
| 16 |
|
| 17 |
def analyze_video(video_file):
|
|
|
|
| 30 |
|
| 31 |
print(f"Processing video: {video_file}")
|
| 32 |
|
| 33 |
+
# Detect offset
|
| 34 |
+
result = detect_offset(fcn_model, video_file, verbose=True)
|
| 35 |
+
|
| 36 |
+
offset = result['offset_frames']
|
| 37 |
+
conf = result['confidence']
|
| 38 |
+
proc_time = result['processing_time']
|
|
|
|
|
|
|
| 39 |
|
| 40 |
# Interpret results
|
| 41 |
if offset > 0:
|
|
|
|
| 62 |
conf_text = "Low"
|
| 63 |
conf_emoji = "π΄"
|
| 64 |
|
| 65 |
+
result_text = f"""
|
| 66 |
## π Sync Detection Results
|
| 67 |
|
| 68 |
### {sync_status}
|
|
|
|
| 75 |
|
| 76 |
- **Offset:** {offset} frames
|
| 77 |
- **Confidence:** {conf_emoji} {conf:.2%} ({conf_text})
|
| 78 |
+
- **Processing Time:** {proc_time:.2f}s
|
| 79 |
|
| 80 |
---
|
| 81 |
|
|
|
|
| 94 |
- **Calibration:** Applied (offset=3, scale=-0.5, baseline=-15)
|
| 95 |
"""
|
| 96 |
|
| 97 |
+
return result_text
|
| 98 |
|
| 99 |
except Exception as e:
|
| 100 |
return f"β Error processing video: {str(e)}\n\nPlease ensure the video has both audio and video tracks."
|