Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -156,7 +156,7 @@ def push_report_to_salesforce(violations, score, pdf_path, pdf_file):
|
|
| 156 |
pdf_url = f"{CONFIG['PUBLIC_URL_BASE']}{os.path.basename(pdf_path)}" if pdf_path else ""
|
| 157 |
|
| 158 |
record_data = {
|
| 159 |
-
"
|
| 160 |
"Violations_Found__c": len(violations),
|
| 161 |
"Violations_Details__c": violations_text,
|
| 162 |
"Status__c": "Pending",
|
|
@@ -281,10 +281,11 @@ def gradio_interface(video_file):
|
|
| 281 |
# Format violations as a Markdown table
|
| 282 |
violation_table = "No violations detected."
|
| 283 |
if result["violations"]:
|
| 284 |
-
header = "| Violation | Timestamp | Confidence | Bounding Box | Violation Details
|
| 285 |
-
separator = "
|
| 286 |
rows = []
|
| 287 |
for v in result["violations"]:
|
|
|
|
| 288 |
violation_name = v["violation"]
|
| 289 |
if violation_name == "no_helmet":
|
| 290 |
violation_name = "no_helmet"
|
|
@@ -294,7 +295,7 @@ def gradio_interface(video_file):
|
|
| 294 |
rows.append(row)
|
| 295 |
violation_table = header + separator + "\n".join(rows)
|
| 296 |
|
| 297 |
-
# Format snapshots as a bullet list
|
| 298 |
snapshots_text = "No snapshots captured."
|
| 299 |
if result["snapshots"]:
|
| 300 |
snapshots_text = "\n".join(
|
|
@@ -321,7 +322,7 @@ interface = gr.Interface(
|
|
| 321 |
gr.Textbox(label="Compliance Score"),
|
| 322 |
gr.Markdown(label="Snapshots"),
|
| 323 |
gr.Textbox(label="Salesforce Record ID"),
|
| 324 |
-
gr.Textbox(label="URL")
|
| 325 |
],
|
| 326 |
title="Worksite Safety Violation Analyzer",
|
| 327 |
description="Upload short site videos to detect safety violations (e.g., no helmet, no harness, unsafe posture)."
|
|
|
|
| 156 |
pdf_url = f"{CONFIG['PUBLIC_URL_BASE']}{os.path.basename(pdf_path)}" if pdf_path else ""
|
| 157 |
|
| 158 |
record_data = {
|
| 159 |
+
"Compliance Score__c": score,
|
| 160 |
"Violations_Found__c": len(violations),
|
| 161 |
"Violations_Details__c": violations_text,
|
| 162 |
"Status__c": "Pending",
|
|
|
|
| 281 |
# Format violations as a Markdown table
|
| 282 |
violation_table = "No violations detected."
|
| 283 |
if result["violations"]:
|
| 284 |
+
header = "| Violation | Timestamp | Confidence | Bounding Box | Violation Details |\n"
|
| 285 |
+
separator = "|---------------|-----------|------------|--------------------------|-------------------------|\n"
|
| 286 |
rows = []
|
| 287 |
for v in result["violations"]:
|
| 288 |
+
# Simplify violation names but preserve "no_helmet" for table
|
| 289 |
violation_name = v["violation"]
|
| 290 |
if violation_name == "no_helmet":
|
| 291 |
violation_name = "no_helmet"
|
|
|
|
| 295 |
rows.append(row)
|
| 296 |
violation_table = header + separator + "\n".join(rows)
|
| 297 |
|
| 298 |
+
# Format snapshots as a bullet list with direct image links
|
| 299 |
snapshots_text = "No snapshots captured."
|
| 300 |
if result["snapshots"]:
|
| 301 |
snapshots_text = "\n".join(
|
|
|
|
| 322 |
gr.Textbox(label="Compliance Score"),
|
| 323 |
gr.Markdown(label="Snapshots"),
|
| 324 |
gr.Textbox(label="Salesforce Record ID"),
|
| 325 |
+
gr.Textbox(label="Violation Details URL")
|
| 326 |
],
|
| 327 |
title="Worksite Safety Violation Analyzer",
|
| 328 |
description="Upload short site videos to detect safety violations (e.g., no helmet, no harness, unsafe posture)."
|