Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
import cv2
|
3 |
from PIL import Image, ImageDraw, ImageFont
|
@@ -15,6 +16,7 @@ device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
|
15 |
processor = Owlv2Processor.from_pretrained("google/owlv2-base-patch16")
|
16 |
model = Owlv2ForObjectDetection.from_pretrained("google/owlv2-base-patch16").to(device)
|
17 |
|
|
|
18 |
def process_video(video_path, target, progress=gr.Progress()):
|
19 |
if video_path is None:
|
20 |
return None, None, "Error: No video uploaded"
|
@@ -129,7 +131,6 @@ def load_sample_frame(video_path):
|
|
129 |
frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
130 |
return frame_rgb
|
131 |
|
132 |
-
@spaces.GPU(duration=200)
|
133 |
def gradio_app():
|
134 |
with gr.Blocks() as app:
|
135 |
gr.Markdown("# Video Object Detection with Owlv2")
|
|
|
1 |
+
import spaces
|
2 |
import gradio as gr
|
3 |
import cv2
|
4 |
from PIL import Image, ImageDraw, ImageFont
|
|
|
16 |
processor = Owlv2Processor.from_pretrained("google/owlv2-base-patch16")
|
17 |
model = Owlv2ForObjectDetection.from_pretrained("google/owlv2-base-patch16").to(device)
|
18 |
|
19 |
+
@spaces.GPU(duration=200)
|
20 |
def process_video(video_path, target, progress=gr.Progress()):
|
21 |
if video_path is None:
|
22 |
return None, None, "Error: No video uploaded"
|
|
|
131 |
frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
132 |
return frame_rgb
|
133 |
|
|
|
134 |
def gradio_app():
|
135 |
with gr.Blocks() as app:
|
136 |
gr.Markdown("# Video Object Detection with Owlv2")
|