Yasser Babaouamer commited on
Commit
5d9efa5
·
1 Parent(s): fa3093c

Added the new 2 classes model

Browse files
Files changed (2) hide show
  1. app.py +6 -8
  2. olive_cls_2c.pt +3 -0
app.py CHANGED
@@ -21,7 +21,7 @@ from deepforest import main
21
  # ------------------------
22
  # Configuration
23
  # ------------------------
24
- YOLO_MODEL_PATH = "yolov8_olive_cls_best.pt"
25
  DEVICE = os.environ.get("DEVICE", "cpu") # 'cpu' or 'cuda'
26
 
27
  def read_imagefile(file_bytes) -> Image.Image:
@@ -204,8 +204,8 @@ async def analyze(image: UploadFile = File(...), conf: float = Form(0.25), iou:
204
 
205
  color_map = {
206
  "healthy": (4, 189, 44),
207
- "stressed": (192, 217, 4),
208
- "dead": (255, 54, 54),
209
  "unknown": (128, 128, 128),
210
  }
211
 
@@ -248,19 +248,17 @@ async def analyze(image: UploadFile = File(...), conf: float = Form(0.25), iou:
248
  states_filled = states.fillna("unknown").astype(str).str.lower()
249
  total_trees = int(len(states_filled))
250
  healthy_trees = int((states_filled == "healthy").sum())
251
- stressed_trees = int((states_filled == "stressed").sum())
252
- dead_trees = int((states_filled == "dead").sum())
253
  except Exception:
254
  total_trees = len(df_pred) if df_pred is not None else 0
255
- healthy_trees = stressed_trees = dead_trees = 0
256
 
257
  img_b64 = base64.b64encode(buf.getvalue()).decode("ascii")
258
  return JSONResponse(content={
259
  "image": img_b64,
260
  "total_trees_count": total_trees,
261
  "healthy_trees_count": healthy_trees,
262
- "stressed_trees_count": stressed_trees,
263
- "dead_trees_count": dead_trees,
264
  })
265
 
266
  except Exception as e:
 
21
  # ------------------------
22
  # Configuration
23
  # ------------------------
24
+ YOLO_MODEL_PATH = "olive_cls_2c.pt"
25
  DEVICE = os.environ.get("DEVICE", "cpu") # 'cpu' or 'cuda'
26
 
27
  def read_imagefile(file_bytes) -> Image.Image:
 
204
 
205
  color_map = {
206
  "healthy": (4, 189, 44),
207
+ "dry": (192, 217, 4),
208
+ # "dead": (255, 54, 54),
209
  "unknown": (128, 128, 128),
210
  }
211
 
 
248
  states_filled = states.fillna("unknown").astype(str).str.lower()
249
  total_trees = int(len(states_filled))
250
  healthy_trees = int((states_filled == "healthy").sum())
251
+ dry_trees = int((states_filled == "dry").sum())
 
252
  except Exception:
253
  total_trees = len(df_pred) if df_pred is not None else 0
254
+ healthy_trees = dry_trees = 0
255
 
256
  img_b64 = base64.b64encode(buf.getvalue()).decode("ascii")
257
  return JSONResponse(content={
258
  "image": img_b64,
259
  "total_trees_count": total_trees,
260
  "healthy_trees_count": healthy_trees,
261
+ "dry_trees_count": dry_trees
 
262
  })
263
 
264
  except Exception as e:
olive_cls_2c.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:89b07b1971e5431a3e7cee676c3c1eab420666a9e1a3b31cf9feb3bf2e034b84
3
+ size 2965505