Komal133 commited on
Commit
a6fedfd
·
verified ·
1 Parent(s): 2c1d06f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -42,7 +42,12 @@ transform = transforms.Compose([
42
  transforms.ToTensor(),
43
  ])
44
 
45
- # Map confidence score to severity level
 
 
 
 
 
46
  def get_severity(score):
47
  if score >= 0.9:
48
  return "Critical"
@@ -51,10 +56,11 @@ def get_severity(score):
51
  else:
52
  return "Minor"
53
 
54
- # Simple defect type mapping (no COCO labels)
55
- # Here, just return a generic "Defect" label or you can customize per your need
56
  def map_defect_type():
57
- return "Defect"
 
 
58
 
59
  # Upload annotated image to Salesforce as ContentVersion record
60
  def upload_image_to_salesforce(image, filename="detected_image.jpg", record_id=None):
 
42
  transforms.ToTensor(),
43
  ])
44
 
45
+ # Define valid picklist values for Fault_Type__c and Severity__c
46
+ # Replace these with your actual Salesforce picklist values
47
+ VALID_FAULT_TYPES = ["Crack", "Rust", "Spalling", "Deformation", "Corrosion"]
48
+ VALID_SEVERITIES = ["Minor", "Moderate", "Critical"]
49
+
50
+ # Map confidence score to severity level ensuring valid picklist values
51
  def get_severity(score):
52
  if score >= 0.9:
53
  return "Critical"
 
56
  else:
57
  return "Minor"
58
 
59
+ # Map defect to a valid picklist fault type
 
60
  def map_defect_type():
61
+ # You can add logic here to decide which fault type to return
62
+ # For now, always return the first valid fault type
63
+ return VALID_FAULT_TYPES[0]
64
 
65
  # Upload annotated image to Salesforce as ContentVersion record
66
  def upload_image_to_salesforce(image, filename="detected_image.jpg", record_id=None):