Naveenkumar1546 commited on
Commit
852922e
·
verified ·
1 Parent(s): 6ee9ea3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -4
app.py CHANGED
@@ -65,11 +65,16 @@ def detect_objects(image_path):
65
 
66
  # thermal_service.py
67
 
68
- from ultralytics import YOLO
69
-
70
- thermal_model = YOLO("models/thermal_model.pt")
 
 
 
71
 
72
  def detect_thermal_anomalies(image_path):
 
 
73
  results = thermal_model(image_path)
74
  flagged = []
75
  for r in results:
@@ -101,4 +106,10 @@ def send_to_salesforce(payload):
101
  "Confidence_Score__c": max([d["score"] for d in payload["detections"]], default=0)
102
  }
103
  headers = {"Content-Type": "application/json"}
104
- requests.post(SALESFORCE_WEBHOOK_URL, json=summary, headers=headers)
 
 
 
 
 
 
 
65
 
66
  # thermal_service.py
67
 
68
+ try:
69
+ from ultralytics import YOLO
70
+ thermal_model = YOLO("models/thermal_model.pt")
71
+ except Exception as e:
72
+ thermal_model = None
73
+ print("⚠️ Thermal model could not be loaded:", e)
74
 
75
  def detect_thermal_anomalies(image_path):
76
+ if not thermal_model:
77
+ return []
78
  results = thermal_model(image_path)
79
  flagged = []
80
  for r in results:
 
106
  "Confidence_Score__c": max([d["score"] for d in payload["detections"]], default=0)
107
  }
108
  headers = {"Content-Type": "application/json"}
109
+ try:
110
+ response = requests.post(SALESFORCE_WEBHOOK_URL, json=summary, headers=headers)
111
+ response.raise_for_status()
112
+ except requests.exceptions.RequestException as e:
113
+ print("❌ Error sending to Salesforce:", e)
114
+
115
+