Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -158,7 +158,7 @@ def downsample_video(video_path):
|
|
| 158 |
"""
|
| 159 |
vidcap = cv2.VideoCapture(video_path)
|
| 160 |
total_frames = int(vidcap.get(cv2.CAP_PROP_FRAME_COUNT))
|
| 161 |
-
fps = vidcap.get(cv2.CAP_PROP_FPS)
|
| 162 |
frames = []
|
| 163 |
frame_indices = np.linspace(0, total_frames - 1, 10, dtype=int)
|
| 164 |
for i in frame_indices:
|
|
@@ -228,7 +228,9 @@ def generate_image(model_name: str, text: str, image: Image.Image,
|
|
| 228 |
time.sleep(0.01)
|
| 229 |
yield buffer, buffer
|
| 230 |
|
| 231 |
-
@spaces.
|
|
|
|
|
|
|
| 232 |
def generate_video(model_name: str, text: str, video_path: str,
|
| 233 |
max_new_tokens: int = 1024,
|
| 234 |
temperature: float = 0.6,
|
|
@@ -309,6 +311,12 @@ video_examples = [
|
|
| 309 |
["explain the video in detail.", "videos/2.mp4"]
|
| 310 |
]
|
| 311 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
# Added CSS to style the output area as a "Canvas"
|
| 313 |
css = """
|
| 314 |
.submit-btn {
|
|
@@ -354,6 +362,10 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
| 354 |
system_prompt = gr.Textbox(label="System Prompt", value=default_system_prompt, visible=False)
|
| 355 |
text_input = gr.Textbox(label="Query Input", value="Detect animal")
|
| 356 |
submit_btn = gr.Button(value="Submit", elem_classes="submit-btn")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 357 |
with gr.Column():
|
| 358 |
model_output_text = gr.Textbox(label="Model Output Text")
|
| 359 |
parsed_boxes = gr.Textbox(label="Parsed Boxes")
|
|
|
|
| 158 |
"""
|
| 159 |
vidcap = cv2.VideoCapture(video_path)
|
| 160 |
total_frames = int(vidcap.get(cv2.CAP_PROP_FRAME_COUNT))
|
| 161 |
+
fps fps = vidcap.get(cv2.CAP_PROP_FPS)
|
| 162 |
frames = []
|
| 163 |
frame_indices = np.linspace(0, total_frames - 1, 10, dtype=int)
|
| 164 |
for i in frame_indices:
|
|
|
|
| 228 |
time.sleep(0.01)
|
| 229 |
yield buffer, buffer
|
| 230 |
|
| 231 |
+
@spaces.G “
|
| 232 |
+
|
| 233 |
+
PU
|
| 234 |
def generate_video(model_name: str, text: str, video_path: str,
|
| 235 |
max_new_tokens: int = 1024,
|
| 236 |
temperature: float = 0.6,
|
|
|
|
| 311 |
["explain the video in detail.", "videos/2.mp4"]
|
| 312 |
]
|
| 313 |
|
| 314 |
+
# Define examples for object detection
|
| 315 |
+
object_detection_examples = [
|
| 316 |
+
["Detect Spider-Man T-shirt.", "images/22.png"],
|
| 317 |
+
["Detect Green Car.", "images/11.png"]
|
| 318 |
+
]
|
| 319 |
+
|
| 320 |
# Added CSS to style the output area as a "Canvas"
|
| 321 |
css = """
|
| 322 |
.submit-btn {
|
|
|
|
| 362 |
system_prompt = gr.Textbox(label="System Prompt", value=default_system_prompt, visible=False)
|
| 363 |
text_input = gr.Textbox(label="Query Input", value="Detect animal")
|
| 364 |
submit_btn = gr.Button(value="Submit", elem_classes="submit-btn")
|
| 365 |
+
gr.Examples(
|
| 366 |
+
examples=object_detection_examples,
|
| 367 |
+
inputs=[text_input, input_img]
|
| 368 |
+
)
|
| 369 |
with gr.Column():
|
| 370 |
model_output_text = gr.Textbox(label="Model Output Text")
|
| 371 |
parsed_boxes = gr.Textbox(label="Parsed Boxes")
|