Spaces:
Runtime error
Runtime error
Update app.py
Browse files41 unmodified lines424344454647482 unmodified lines5152535455565758596041 unmodified linestransforms.ToTensor(),])# Map confidence score to severity leveldef get_severity(score):if score >= 0.9:return "Critical"2 unmodified lineselse:return "Minor"# Simple defect type mapping (no COCO labels)# Here, just return a generic "Defect" label or you can customize per your needdef map_defect_type():return "Defect"# Upload annotated image to Salesforce as ContentVersion recorddef upload_image_to_salesforce(image, filename="detected_image.jpg", record_id=None):41 unmodified lines4243444546474849505152532 unmodified lines565758596061626364656641 unmodified linestransforms.ToTensor(),])# Define valid picklist values for Fault_Type__c and Severity__c# Replace these with your actual Salesforce picklist valuesVALID_FAULT_TYPES = ["Crack", "Rust", "Spalling", "Deformation", "Corrosion"]VALID_SEVERITIES = ["Minor", "Moderate", "Critical"]# Map confidence score to severity level ensuring valid picklist valuesdef get_severity(score):if score >= 0.9:return "Critical"2 unmodified lineselse:return "Minor"# Map defect to a valid picklist fault typedef map_defect_type():# You can add logic here to decide which fault type to return# For now, always return the first valid fault typereturn VALID_FAULT_TYPES[0]# Upload annotated image to Salesforce as ContentVersion recorddef upload_image_to_salesforce(image, filename="detected_image.jpg", record_id=None):
app.py+10-4