Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ model = Owlv2ForObjectDetection.from_pretrained("google/owlv2-base-patch16").to(
|
|
15 |
def detect_objects_in_frame(image, target):
|
16 |
draw = ImageDraw.Draw(image)
|
17 |
texts = [[target]]
|
18 |
-
inputs = processor(text=texts, images=image, return_tensors="pt").to(device)
|
19 |
outputs = model(**inputs)
|
20 |
|
21 |
target_sizes = torch.Tensor([image.size[::-1]])
|
@@ -98,7 +98,7 @@ def gradio_app():
|
|
98 |
target_input = gr.Textbox(label="Target Object")
|
99 |
output_video = gr.Video(label="Output Video")
|
100 |
error_output = gr.Textbox(label="Error Messages", visible=False)
|
101 |
-
sample_video_frame = gr.Image(value=load_sample_frame("Drone Video of African Wildlife Wild Botswan.
|
102 |
use_sample_button = gr.Button("Use Sample Video")
|
103 |
|
104 |
video_path = gr.State(None)
|
@@ -115,7 +115,7 @@ def gradio_app():
|
|
115 |
outputs=[output_video, error_output])
|
116 |
|
117 |
def use_sample_video():
|
118 |
-
sample_video_path = "Drone Video of African Wildlife Wild Botswan.
|
119 |
return process_and_update(sample_video_path, "animal")
|
120 |
|
121 |
use_sample_button.click(use_sample_video,
|
|
|
15 |
def detect_objects_in_frame(image, target):
|
16 |
draw = ImageDraw.Draw(image)
|
17 |
texts = [[target]]
|
18 |
+
inputs = processor(text=texts, images=image, return_tensors="pt", padding=True).to(device)
|
19 |
outputs = model(**inputs)
|
20 |
|
21 |
target_sizes = torch.Tensor([image.size[::-1]])
|
|
|
98 |
target_input = gr.Textbox(label="Target Object")
|
99 |
output_video = gr.Video(label="Output Video")
|
100 |
error_output = gr.Textbox(label="Error Messages", visible=False)
|
101 |
+
sample_video_frame = gr.Image(value=load_sample_frame("Drone Video of African Wildlife Wild Botswan.webm"), label="Sample Video Frame")
|
102 |
use_sample_button = gr.Button("Use Sample Video")
|
103 |
|
104 |
video_path = gr.State(None)
|
|
|
115 |
outputs=[output_video, error_output])
|
116 |
|
117 |
def use_sample_video():
|
118 |
+
sample_video_path = "Drone Video of African Wildlife Wild Botswan.webm"
|
119 |
return process_and_update(sample_video_path, "animal")
|
120 |
|
121 |
use_sample_button.click(use_sample_video,
|