jainvrushab commited on
Commit
c7aae05
·
verified ·
1 Parent(s): 717ec5d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -54,11 +54,13 @@ def predict(image):
54
  for i in range(len(model_all.names)):
55
  count = class_counts_all[i]
56
  avg_conf = np.mean(class_confidences_all[i]) if class_confidences_all[i] else 0
57
- output += f"{model_all.names[i]}: {count} detections (Avg. Confidence: {avg_conf:.2f})\n"
 
58
 
59
  # Add number plate detection results from the second model
60
- avg_np_conf = np.mean(np_confidences) if np_confidences else 0
61
- output += f"Number Plates : {np_count} detections (Avg. Confidence: {avg_np_conf:.2f})\n"
 
62
 
63
  return im, output
64
 
@@ -75,4 +77,4 @@ iface = gr.Interface(
75
  )
76
 
77
  # Launch the interface
78
- iface.launch(share='True')
 
54
  for i in range(len(model_all.names)):
55
  count = class_counts_all[i]
56
  avg_conf = np.mean(class_confidences_all[i]) if class_confidences_all[i] else 0
57
+ if count > 0: # Only print classes with detections
58
+ output += f"{model_all.names[i]}: {count} detections (Avg. Confidence: {avg_conf:.2f})\n"
59
 
60
  # Add number plate detection results from the second model
61
+ if np_count > 0: # Only print number plate detection if there are any
62
+ avg_np_conf = np.mean(np_confidences) if np_confidences else 0
63
+ output += f"Number Plates: {np_count} detections (Avg. Confidence: {avg_np_conf:.2f})\n"
64
 
65
  return im, output
66
 
 
77
  )
78
 
79
  # Launch the interface
80
+ iface.launch(share=True)