Aadityaramrame commited on
Commit
ef1d02f
·
verified ·
1 Parent(s): be5bad9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -26,22 +26,27 @@ async def root():
26
  @app.post("/predict")
27
  async def predict(file: UploadFile = File(...)):
28
  try:
 
29
  image = Image.open(file.file).convert("RGB").resize((224, 224))
30
  img_array = np.expand_dims(np.array(image) / 255.0, axis=0)
31
 
 
32
  prediction = model.predict(img_array)
33
  predicted_class = int(np.argmax(prediction))
34
  confidence = float(np.max(prediction))
35
 
36
- # 🔹 Map class index to cancer type name
37
  classes = [
 
38
  "Eosinophil",
 
 
39
  "Lymphocyte",
40
  "Monocyte",
41
  "Neutrophil",
42
- "Cancerous Cell",
43
- "Unknown"
44
  ]
 
45
  label = classes[predicted_class]
46
 
47
  return JSONResponse(
 
26
  @app.post("/predict")
27
  async def predict(file: UploadFile = File(...)):
28
  try:
29
+ # Load and preprocess image
30
  image = Image.open(file.file).convert("RGB").resize((224, 224))
31
  img_array = np.expand_dims(np.array(image) / 255.0, axis=0)
32
 
33
+ # Predict
34
  prediction = model.predict(img_array)
35
  predicted_class = int(np.argmax(prediction))
36
  confidence = float(np.max(prediction))
37
 
38
+ # 🔹 Map class index to cell type
39
  classes = [
40
+ "Basophil",
41
  "Eosinophil",
42
+ "Erythroblast",
43
+ "Immature Granulocyte (IG)",
44
  "Lymphocyte",
45
  "Monocyte",
46
  "Neutrophil",
47
+ "Platelet"
 
48
  ]
49
+
50
  label = classes[predicted_class]
51
 
52
  return JSONResponse(