Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,6 @@
|
|
| 2 |
import os
|
| 3 |
import json
|
| 4 |
from typing import Dict, List, Optional, Tuple, Union, Any
|
| 5 |
-
import io
|
| 6 |
|
| 7 |
import gradio as gr
|
| 8 |
import spaces
|
|
@@ -138,10 +137,11 @@ def face_image_embedding(image: Image.Image) -> List[float] | None:
|
|
| 138 |
return None
|
| 139 |
|
| 140 |
@spaces.GPU
|
| 141 |
-
def scenes_extraction(video_file:
|
|
|
|
|
|
|
| 142 |
# Detectamos las escenas
|
| 143 |
-
|
| 144 |
-
video_manager = VideoManager([video_path])
|
| 145 |
scene_manager = SceneManager()
|
| 146 |
scene_manager.add_detector(ContentDetector(threshold=threshold))
|
| 147 |
video_manager.start()
|
|
@@ -226,7 +226,7 @@ with gr.Blocks(title="Salamandra Vision 7B 路 ZeroGPU") as demo:
|
|
| 226 |
face_btn.click(face_image_embedding, [face_img], face_out, api_name="face_image_embedding", concurrency_limit=1)
|
| 227 |
|
| 228 |
with gr.Row():
|
| 229 |
-
video_file = gr.Video(label="Sube un v铆deo"
|
| 230 |
threshold = gr.Slider(0.0, 100.0, value=30.0, step=1.0, label="Threshold")
|
| 231 |
offset_frames = gr.Slider(0, 30, value=5, step=1, label="Offset frames")
|
| 232 |
crop_ratio = gr.Slider(0.0, 1.0, value=1.0, step=0.05, label="Crop ratio")
|
|
|
|
| 2 |
import os
|
| 3 |
import json
|
| 4 |
from typing import Dict, List, Optional, Tuple, Union, Any
|
|
|
|
| 5 |
|
| 6 |
import gradio as gr
|
| 7 |
import spaces
|
|
|
|
| 137 |
return None
|
| 138 |
|
| 139 |
@spaces.GPU
|
| 140 |
+
def scenes_extraction(video_file: str, threshold: float, offset_frames: int, crop_ratio: float) -> Tuple[List[Image.Image], List[Dict]] | None:
|
| 141 |
+
# video_file es un str ya que aunque realmente el usuario subi贸 un archivo desde la UI, Gradio lo guarda temporalmente como ruta
|
| 142 |
+
|
| 143 |
# Detectamos las escenas
|
| 144 |
+
video_manager = VideoManager([video_file])
|
|
|
|
| 145 |
scene_manager = SceneManager()
|
| 146 |
scene_manager.add_detector(ContentDetector(threshold=threshold))
|
| 147 |
video_manager.start()
|
|
|
|
| 226 |
face_btn.click(face_image_embedding, [face_img], face_out, api_name="face_image_embedding", concurrency_limit=1)
|
| 227 |
|
| 228 |
with gr.Row():
|
| 229 |
+
video_file = gr.Video(label="Sube un v铆deo")
|
| 230 |
threshold = gr.Slider(0.0, 100.0, value=30.0, step=1.0, label="Threshold")
|
| 231 |
offset_frames = gr.Slider(0, 30, value=5, step=1, label="Offset frames")
|
| 232 |
crop_ratio = gr.Slider(0.0, 1.0, value=1.0, step=0.05, label="Crop ratio")
|