Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -368,7 +368,8 @@ def process_image(image):
|
|
| 368 |
processed_frame = preprocess_frame(frame)
|
| 369 |
start_time = time.time()
|
| 370 |
results = yolo_model.predict(processed_frame)
|
| 371 |
-
|
|
|
|
| 372 |
processing_time = time.time() - start_time
|
| 373 |
logger.info(f"Image processing completed in {processing_time:.2f} seconds")
|
| 374 |
|
|
@@ -424,7 +425,7 @@ def process_image(image):
|
|
| 424 |
if salesforce_errors:
|
| 425 |
status_message += f" Salesforce logging errors: {', '.join(salesforce_errors)}"
|
| 426 |
|
| 427 |
-
return
|
| 428 |
except Exception as e:
|
| 429 |
logger.error(f"Image processing error: {e}")
|
| 430 |
return None, f"Error processing image: {str(e)}", None, recent_violations
|
|
@@ -447,8 +448,9 @@ def process_rtsp_stream():
|
|
| 447 |
for frame, timestamp in capture_rtsp_frames(RTSP_URL, max_frames=10):
|
| 448 |
processed_frame = preprocess_frame(frame)
|
| 449 |
results = yolo_model.predict(processed_frame)
|
| 450 |
-
|
| 451 |
-
|
|
|
|
| 452 |
|
| 453 |
# Log violations if detected
|
| 454 |
for result in results:
|
|
@@ -514,7 +516,7 @@ with gr.Blocks() as demo:
|
|
| 514 |
|
| 515 |
with gr.Row():
|
| 516 |
with gr.Column():
|
| 517 |
-
image_output = gr.Image(label="Processed Image
|
| 518 |
with gr.Column():
|
| 519 |
image_status = gr.Textbox(label="Image Processing Status")
|
| 520 |
|
|
|
|
| 368 |
processed_frame = preprocess_frame(frame)
|
| 369 |
start_time = time.time()
|
| 370 |
results = yolo_model.predict(processed_frame)
|
| 371 |
+
# Skip drawing bounding boxes as per request; return the original frame
|
| 372 |
+
# annotated_frame = draw_bounding_boxes(frame.copy(), results)
|
| 373 |
processing_time = time.time() - start_time
|
| 374 |
logger.info(f"Image processing completed in {processing_time:.2f} seconds")
|
| 375 |
|
|
|
|
| 425 |
if salesforce_errors:
|
| 426 |
status_message += f" Salesforce logging errors: {', '.join(salesforce_errors)}"
|
| 427 |
|
| 428 |
+
return frame, status_message, generate_pdf_report(), recent_violations
|
| 429 |
except Exception as e:
|
| 430 |
logger.error(f"Image processing error: {e}")
|
| 431 |
return None, f"Error processing image: {str(e)}", None, recent_violations
|
|
|
|
| 448 |
for frame, timestamp in capture_rtsp_frames(RTSP_URL, max_frames=10):
|
| 449 |
processed_frame = preprocess_frame(frame)
|
| 450 |
results = yolo_model.predict(processed_frame)
|
| 451 |
+
# Skip drawing bounding boxes as per request; append the original frame
|
| 452 |
+
# annotated_frame = draw_bounding_boxes(frame.copy(), results)
|
| 453 |
+
frames.append(frame)
|
| 454 |
|
| 455 |
# Log violations if detected
|
| 456 |
for result in results:
|
|
|
|
| 516 |
|
| 517 |
with gr.Row():
|
| 518 |
with gr.Column():
|
| 519 |
+
image_output = gr.Image(label="Processed Image")
|
| 520 |
with gr.Column():
|
| 521 |
image_status = gr.Textbox(label="Image Processing Status")
|
| 522 |
|