Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -161,7 +161,7 @@ import os
|
|
161 |
import subprocess
|
162 |
import sys
|
163 |
# Run the .bat file before launching the app
|
164 |
-
|
165 |
import PromptTrack
|
166 |
except ImportError:
|
167 |
print("PromptTrack not found. Installing...")
|
@@ -175,7 +175,7 @@ except ImportError:
|
|
175 |
|
176 |
|
177 |
from PromptTrack import PromptTracker
|
178 |
-
tracker = PromptTracker()
|
179 |
def process_video(video_path, prompt):
|
180 |
detection_threshold=0.3
|
181 |
track_thresh=0.4
|
@@ -186,12 +186,12 @@ def process_video(video_path, prompt):
|
|
186 |
output_file = video_path.split('mp4')[0]+"_mot_.json" # Tracking result
|
187 |
output_file_2 = video_path.split('mp4')[0]+"_object_detection.json" # detection results
|
188 |
video_file = video_path
|
189 |
-
|
190 |
tracker.process_mot(video_file, fixed_parc=True, track_thresh=track_thresh, match_thresh=match_thresh, frame_rate=25, max_time_lost=max_time_lost, nbr_frames_fixing=nbr_frames_fixing)
|
191 |
-
tracker.read_video_with_mot(video_file, fps=25)
|
192 |
|
193 |
|
194 |
-
output_video = "output.mp4" # Placeholder for processed video
|
195 |
output_file = "output.txt" # Placeholder for generated file
|
196 |
|
197 |
|
@@ -201,7 +201,7 @@ def process_video(video_path, prompt):
|
|
201 |
# Create an output text file with the prompt content
|
202 |
with open(output_file, "w") as f:
|
203 |
f.write(f"User Prompt: {prompt}\n")
|
204 |
-
|
205 |
return output_video, output_file
|
206 |
|
207 |
# Define Gradio interface
|
@@ -219,33 +219,3 @@ if __name__ == "__main__":
|
|
219 |
iface.launch(share=True)
|
220 |
|
221 |
|
222 |
-
'''
|
223 |
-
import gradio as gr
|
224 |
-
import shutil
|
225 |
-
import os
|
226 |
-
|
227 |
-
def process_video(video, prompt):
|
228 |
-
output_video = "output.mp4" # Placeholder for processed video
|
229 |
-
output_file = "output.txt" # Placeholder for generated file
|
230 |
-
|
231 |
-
# Copy the input video to simulate processing
|
232 |
-
shutil.copy(video.name, output_video)
|
233 |
-
|
234 |
-
# Create an output text file with the prompt content
|
235 |
-
with open(output_file, "w") as f:
|
236 |
-
f.write(f"User Prompt: {prompt}\n")
|
237 |
-
|
238 |
-
return output_video, output_file
|
239 |
-
|
240 |
-
# Define Gradio interface
|
241 |
-
iface = gr.Interface(
|
242 |
-
fn=process_video,
|
243 |
-
inputs=[gr.File(label="Upload Video"), gr.Textbox(placeholder="Enter your prompt")],
|
244 |
-
outputs=[gr.Video(), gr.File(label="Generated File")],
|
245 |
-
title="Video Processing App",
|
246 |
-
description="Upload a video and enter a prompt. The app will return the processed video and a generated file."
|
247 |
-
)
|
248 |
-
|
249 |
-
# Launch the app
|
250 |
-
if __name__ == "__main__":
|
251 |
-
iface.launch(share=True)'''
|
|
|
161 |
import subprocess
|
162 |
import sys
|
163 |
# Run the .bat file before launching the app
|
164 |
+
try:
|
165 |
import PromptTrack
|
166 |
except ImportError:
|
167 |
print("PromptTrack not found. Installing...")
|
|
|
175 |
|
176 |
|
177 |
from PromptTrack import PromptTracker
|
178 |
+
tracker = PromptTracker()
|
179 |
def process_video(video_path, prompt):
|
180 |
detection_threshold=0.3
|
181 |
track_thresh=0.4
|
|
|
186 |
output_file = video_path.split('mp4')[0]+"_mot_.json" # Tracking result
|
187 |
output_file_2 = video_path.split('mp4')[0]+"_object_detection.json" # detection results
|
188 |
video_file = video_path
|
189 |
+
tracker.detect_objects(video_file, prompt=prompt, nms_threshold=0.8, detection_threshold=detection_threshold, detector="OWL-VITV2")
|
190 |
tracker.process_mot(video_file, fixed_parc=True, track_thresh=track_thresh, match_thresh=match_thresh, frame_rate=25, max_time_lost=max_time_lost, nbr_frames_fixing=nbr_frames_fixing)
|
191 |
+
tracker.read_video_with_mot(video_file, fps=25)
|
192 |
|
193 |
|
194 |
+
"""output_video = "output.mp4" # Placeholder for processed video
|
195 |
output_file = "output.txt" # Placeholder for generated file
|
196 |
|
197 |
|
|
|
201 |
# Create an output text file with the prompt content
|
202 |
with open(output_file, "w") as f:
|
203 |
f.write(f"User Prompt: {prompt}\n")
|
204 |
+
"""
|
205 |
return output_video, output_file
|
206 |
|
207 |
# Define Gradio interface
|
|
|
219 |
iface.launch(share=True)
|
220 |
|
221 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|