Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -223,9 +223,10 @@ def process_clip_from_file_sync(prompt, frames, fps, video_path, id):
|
|
223 |
return None
|
224 |
|
225 |
# Function to capture video frames
|
226 |
-
def analyze_stream(prompt,
|
227 |
global stop_capture
|
228 |
stop_capture = False
|
|
|
229 |
|
230 |
|
231 |
cap = cv2.VideoCapture(stream or WEBCAM)
|
@@ -341,33 +342,13 @@ def stop_capture_func():
|
|
341 |
|
342 |
# Gradio interface
|
343 |
with gr.Blocks(title="Conntour", fill_height=True) as demo:
|
344 |
-
with gr.
|
345 |
-
with gr.
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
stop_btn = gr.Button("Stop")
|
352 |
-
start_btn.click(analyze_video_file, inputs=[prompt, video, chatbot], outputs=[chatbot], queue=True)
|
353 |
stop_btn.click(stop_capture_func)
|
354 |
-
with gr.Tab("Alerts"):
|
355 |
-
with gr.Row():
|
356 |
-
stream = gr.Textbox(label="Video Source", value="https://streamapi2.eu.loclx.io/video_feed/101 OR rtsp://admin:[email protected]:5678/Streaming/Channels/101")
|
357 |
-
with gr.Column():
|
358 |
-
chatbot = gr.Chatbot(label="Events", bubble_full_width=False, avatar_images=AVATARS)
|
359 |
-
prompt = gr.Textbox(label="Enter your prompt alert")
|
360 |
-
start_btn = gr.Button("Start")
|
361 |
-
stop_btn = gr.Button("Stop")
|
362 |
-
start_btn.click(analyze_stream, inputs=[prompt, stream, chatbot], outputs=[chatbot], queue=True)
|
363 |
-
stop_btn.click(stop_capture_func)
|
364 |
-
# Add new API endpoint (without UI components)
|
365 |
-
with gr.Row(visible=False) as hidden_api:
|
366 |
-
api_prompt = gr.Textbox(label="Prompt")
|
367 |
-
api_video = gr.Textbox(label="Prompt")
|
368 |
-
api_output = gr.JSON(label="Captured Events")
|
369 |
-
api_btn = gr.Button("Analyze Video File")
|
370 |
-
|
371 |
-
api_btn.click(analyze_video_file_sync, inputs=[api_prompt, api_video], outputs=[api_output])
|
372 |
|
373 |
demo.launch(favicon_path='favicon.ico', auth=(user_name, password))
|
|
|
223 |
return None
|
224 |
|
225 |
# Function to capture video frames
|
226 |
+
def analyze_stream(prompt, chatbot):
|
227 |
global stop_capture
|
228 |
stop_capture = False
|
229 |
+
stream = "rtsp://FRefgrWt:Fgh342!23$@[email protected]:554/Streaming/channels/101"
|
230 |
|
231 |
|
232 |
cap = cv2.VideoCapture(stream or WEBCAM)
|
|
|
342 |
|
343 |
# Gradio interface
|
344 |
with gr.Blocks(title="Conntour", fill_height=True) as demo:
|
345 |
+
with gr.Row():
|
346 |
+
with gr.Column():
|
347 |
+
chatbot = gr.Chatbot(label="Events", bubble_full_width=False, avatar_images=AVATARS, height=700)
|
348 |
+
prompt = gr.Textbox(label="Enter your prompt alert")
|
349 |
+
start_btn = gr.Button("Start")
|
350 |
+
stop_btn = gr.Button("Stop")
|
351 |
+
start_btn.click(analyze_stream, inputs=[prompt, chatbot], outputs=[chatbot], queue=True)
|
|
|
|
|
352 |
stop_btn.click(stop_capture_func)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
353 |
|
354 |
demo.launch(favicon_path='favicon.ico', auth=(user_name, password))
|