Update app.py
Browse files
app.py
CHANGED
|
@@ -13,6 +13,7 @@ from latex import build_pdf
|
|
| 13 |
os.makedirs("screenshots", exist_ok=True)
|
| 14 |
os.makedirs("logs", exist_ok=True)
|
| 15 |
os.makedirs("templates", exist_ok=True)
|
|
|
|
| 16 |
|
| 17 |
# Load YOLOv8 model
|
| 18 |
model = YOLO("yolov8m.pt")
|
|
@@ -135,7 +136,6 @@ def analyze_video(video_path, confidence=0.3):
|
|
| 135 |
|
| 136 |
# Generate PDF report
|
| 137 |
pdf_path = f"reports/report_{datetime.now().strftime('%Y%m%d_%H%M%S')}.pdf"
|
| 138 |
-
os.makedirs("reports", exist_ok=True)
|
| 139 |
generate_pdf_report(summary, screenshots, pdf_path)
|
| 140 |
|
| 141 |
return output_path, summary, screenshots, circle_path, pdf_path
|
|
@@ -143,8 +143,9 @@ def analyze_video(video_path, confidence=0.3):
|
|
| 143 |
css = """
|
| 144 |
.gradio-container {background-color: #f0f4f8; font-family: Arial;}
|
| 145 |
.footer {display: none !important;}
|
| 146 |
-
button {background-color: #27ae60; color: white; border-radius: 5px;}
|
| 147 |
button:hover {background-color: #219653;}
|
|
|
|
| 148 |
"""
|
| 149 |
|
| 150 |
with gr.Blocks(css=css) as iface:
|
|
@@ -160,7 +161,7 @@ with gr.Blocks(css=css) as iface:
|
|
| 160 |
with gr.Row():
|
| 161 |
with gr.Column():
|
| 162 |
video_output = gr.Video(label="Annotated Video")
|
| 163 |
-
summary_output = gr.Textbox(label="Analysis Summary")
|
| 164 |
with gr.Column():
|
| 165 |
screenshot_output = gr.Gallery(label="Incident Screenshots")
|
| 166 |
circle_output = gr.Image(label="Confidence Metric")
|
|
|
|
| 13 |
os.makedirs("screenshots", exist_ok=True)
|
| 14 |
os.makedirs("logs", exist_ok=True)
|
| 15 |
os.makedirs("templates", exist_ok=True)
|
| 16 |
+
os.makedirs("reports", exist_ok=True)
|
| 17 |
|
| 18 |
# Load YOLOv8 model
|
| 19 |
model = YOLO("yolov8m.pt")
|
|
|
|
| 136 |
|
| 137 |
# Generate PDF report
|
| 138 |
pdf_path = f"reports/report_{datetime.now().strftime('%Y%m%d_%H%M%S')}.pdf"
|
|
|
|
| 139 |
generate_pdf_report(summary, screenshots, pdf_path)
|
| 140 |
|
| 141 |
return output_path, summary, screenshots, circle_path, pdf_path
|
|
|
|
| 143 |
css = """
|
| 144 |
.gradio-container {background-color: #f0f4f8; font-family: Arial;}
|
| 145 |
.footer {display: none !important;}
|
| 146 |
+
button {background-color: #27ae60; color: white; border-radius: 5px; padding: 10px 20px;}
|
| 147 |
button:hover {background-color: #219653;}
|
| 148 |
+
.gradio-gallery, .gradio-video, .gradio-textbox {border-radius: 5px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);}
|
| 149 |
"""
|
| 150 |
|
| 151 |
with gr.Blocks(css=css) as iface:
|
|
|
|
| 161 |
with gr.Row():
|
| 162 |
with gr.Column():
|
| 163 |
video_output = gr.Video(label="Annotated Video")
|
| 164 |
+
summary_output = gr.Textbox(label="Analysis Analysis Summary")
|
| 165 |
with gr.Column():
|
| 166 |
screenshot_output = gr.Gallery(label="Incident Screenshots")
|
| 167 |
circle_output = gr.Image(label="Confidence Metric")
|