Subh775 commited on
Commit
0b07868
·
verified ·
1 Parent(s): 6d13504

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -81,8 +81,16 @@ def init_model():
81
 
82
  print("[INFO] Loading RF-DETR model (CPU mode)...")
83
  MODEL = RFDETRSegPreview(pretrain_weights=CHECKPOINT_PATH)
84
- MODEL.optimize_for_inference()
85
 
 
 
 
 
 
 
 
 
 
86
  return MODEL
87
  except Exception as e:
88
  print(f"[ERROR] Model initialization failed: {e}")
@@ -120,7 +128,7 @@ def annotate_segmentation(image: Image.Image, detections: sv.Detections,
120
  Args:
121
  image: Input PIL Image
122
  detections: Supervision Detections object
123
- show_labels: Whether to show "ROI" label text
124
  show_confidence: Whether to show confidence scores
125
  """
126
  try:
@@ -160,7 +168,7 @@ def annotate_segmentation(image: Image.Image, detections: sv.Detections,
160
  for conf in detections.confidence:
161
  label_parts = []
162
  if show_labels:
163
- label_parts.append("Disease")
164
  if show_confidence:
165
  label_parts.append(f"{float(conf):.2f}")
166
  labels.append(" ".join(label_parts))
@@ -327,7 +335,9 @@ def predict():
327
 
328
 
329
  if __name__ == "__main__":
330
- print("Starting disease Segmentation Server")
 
 
331
 
332
  # Warm model in background thread
333
  def warm():
 
81
 
82
  print("[INFO] Loading RF-DETR model (CPU mode)...")
83
  MODEL = RFDETRSegPreview(pretrain_weights=CHECKPOINT_PATH)
 
84
 
85
+ # Try to optimize for inference
86
+ try:
87
+ print("[INFO] Optimizing model for inference...")
88
+ MODEL.optimize_for_inference()
89
+ print("[INFO] Model optimization complete")
90
+ except Exception as e:
91
+ print(f"[WARN] optimize_for_inference() skipped/failed: {e}")
92
+
93
+ print("[INFO] Model ready for inference")
94
  return MODEL
95
  except Exception as e:
96
  print(f"[ERROR] Model initialization failed: {e}")
 
128
  Args:
129
  image: Input PIL Image
130
  detections: Supervision Detections object
131
+ show_labels: Whether to show "Tulsi" label text
132
  show_confidence: Whether to show confidence scores
133
  """
134
  try:
 
168
  for conf in detections.confidence:
169
  label_parts = []
170
  if show_labels:
171
+ label_parts.append("Disease") #class name: Disease
172
  if show_confidence:
173
  label_parts.append(f"{float(conf):.2f}")
174
  labels.append(" ".join(label_parts))
 
335
 
336
 
337
  if __name__ == "__main__":
338
+ print("\n" + "="*60)
339
+ print("Starting Tulsi Leaf Segmentation Server")
340
+ print("="*60 + "\n")
341
 
342
  # Warm model in background thread
343
  def warm():