sheikh987 commited on
Commit
718ea9a
·
verified ·
1 Parent(s): 2be1cc1

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +6 -1
main.py CHANGED
@@ -34,6 +34,11 @@ class ImageRequest(BaseModel):
34
  def load_assets():
35
  global segmentation_model, classification_model, knowledge_base, transform_segment, transform_classify
36
 
 
 
 
 
 
37
  print("--> API starting up: This may take a few minutes...")
38
 
39
  # Use /tmp for writable cache directory
@@ -132,7 +137,7 @@ async def analyze_image(request: ImageRequest):
132
  confidence, predicted_idx = torch.max(probabilities, 1)
133
  confidence_percent = confidence.item() * 100
134
 
135
- if confidence_percent < 75.0:
136
  return {"status": "Inconclusive", "message": f"Model confidence ({confidence_percent:.2f}%) is below the 75% threshold."}
137
 
138
  # Stage 3: Return result
 
34
  def load_assets():
35
  global segmentation_model, classification_model, knowledge_base, transform_segment, transform_classify
36
 
37
+ # Haddii hore loo load gareeyay, iska dhaaf
38
+ if segmentation_model is not None and classification_model is not None and knowledge_base is not None:
39
+ print("🔁 Models and knowledge base already loaded. Skipping reloading.")
40
+ return
41
+
42
  print("--> API starting up: This may take a few minutes...")
43
 
44
  # Use /tmp for writable cache directory
 
137
  confidence, predicted_idx = torch.max(probabilities, 1)
138
  confidence_percent = confidence.item() * 100
139
 
140
+ if confidence_percent < 50.0:
141
  return {"status": "Inconclusive", "message": f"Model confidence ({confidence_percent:.2f}%) is below the 75% threshold."}
142
 
143
  # Stage 3: Return result