Update app.py
Browse files
app.py
CHANGED
|
@@ -9,6 +9,8 @@ import torch
|
|
| 9 |
from facenet_pytorch import MTCNN, InceptionResnetV1
|
| 10 |
import numpy as np
|
| 11 |
from PIL import Image
|
|
|
|
|
|
|
| 12 |
from transformers import AutoProcessor, LlavaOnevisionForConditionalGeneration
|
| 13 |
|
| 14 |
import cv2
|
|
@@ -141,8 +143,17 @@ def scenes_extraction(video_file: str, threshold: float, offset_frames: int, cro
|
|
| 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 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
# Detectamos las escenas
|
| 145 |
-
video_manager = VideoManager([
|
| 146 |
scene_manager = SceneManager()
|
| 147 |
scene_manager.add_detector(ContentDetector(threshold=threshold))
|
| 148 |
video_manager.start()
|
|
@@ -231,7 +242,7 @@ with gr.Blocks(title="Salamandra Vision 7B 路 ZeroGPU") as demo:
|
|
| 231 |
face_btn.click(face_image_embedding, [face_img], face_out, api_name="face_image_embedding", concurrency_limit=1)
|
| 232 |
|
| 233 |
with gr.Row():
|
| 234 |
-
video_file = gr.
|
| 235 |
threshold = gr.Slider(0.0, 100.0, value=30.0, step=1.0, label="Threshold")
|
| 236 |
offset_frames = gr.Slider(0, 30, value=5, step=1, label="Offset frames")
|
| 237 |
crop_ratio = gr.Slider(0.0, 1.0, value=1.0, step=0.05, label="Crop ratio")
|
|
|
|
| 9 |
from facenet_pytorch import MTCNN, InceptionResnetV1
|
| 10 |
import numpy as np
|
| 11 |
from PIL import Image
|
| 12 |
+
import base64
|
| 13 |
+
import tempfile
|
| 14 |
from transformers import AutoProcessor, LlavaOnevisionForConditionalGeneration
|
| 15 |
|
| 16 |
import cv2
|
|
|
|
| 143 |
# video_file es un str ya que aunque realmente el usuario subi贸 un archivo desde la UI, Gradio lo guarda temporalmente como ruta
|
| 144 |
|
| 145 |
try:
|
| 146 |
+
video_bytes = base64.b64decode(video_file)
|
| 147 |
+
|
| 148 |
+
# archivo temporal en /tmp
|
| 149 |
+
temp_video = tempfile.NamedTemporaryFile(delete=False, suffix=".mp4")
|
| 150 |
+
temp_video.write(video_bytes)
|
| 151 |
+
temp_video.flush()
|
| 152 |
+
temp_video.close()
|
| 153 |
+
|
| 154 |
+
video_path = temp_video.name
|
| 155 |
# Detectamos las escenas
|
| 156 |
+
video_manager = VideoManager([video_path])
|
| 157 |
scene_manager = SceneManager()
|
| 158 |
scene_manager.add_detector(ContentDetector(threshold=threshold))
|
| 159 |
video_manager.start()
|
|
|
|
| 242 |
face_btn.click(face_image_embedding, [face_img], face_out, api_name="face_image_embedding", concurrency_limit=1)
|
| 243 |
|
| 244 |
with gr.Row():
|
| 245 |
+
video_file = gr.Textbox(label="Texto/prompt", value="Base64 del video")
|
| 246 |
threshold = gr.Slider(0.0, 100.0, value=30.0, step=1.0, label="Threshold")
|
| 247 |
offset_frames = gr.Slider(0, 30, value=5, step=1, label="Offset frames")
|
| 248 |
crop_ratio = gr.Slider(0.0, 1.0, value=1.0, step=0.05, label="Crop ratio")
|