Papizee commited on
Commit
d7dffb3
·
verified ·
1 Parent(s): 501fd60

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -5,7 +5,6 @@ from tensorflow.keras.preprocessing import image
5
  import numpy as np
6
  from PIL import Image
7
  import io
8
- import os
9
 
10
  app = FastAPI(title="OralScan Model API")
11
 
@@ -35,7 +34,7 @@ async def predict(file: UploadFile = File(...)):
35
  contents = await file.read()
36
  img = Image.open(io.BytesIO(contents)).convert("RGB")
37
 
38
- # Resize to 224x224 (what MobileNetV2 expects)
39
  img = img.resize((224, 224))
40
 
41
  # Preprocess
@@ -48,8 +47,12 @@ async def predict(file: UploadFile = File(...)):
48
  predicted_class = int(np.argmax(predictions[0]))
49
  confidence = float(np.max(predictions[0]) * 100)
50
 
51
- # Change these class names to match your actual 3 classes
52
- class_names = ["Healthy", "Mild Condition", "Severe Condition"]
 
 
 
 
53
 
54
  return {
55
  "predicted_class": predicted_class,
 
5
  import numpy as np
6
  from PIL import Image
7
  import io
 
8
 
9
  app = FastAPI(title="OralScan Model API")
10
 
 
34
  contents = await file.read()
35
  img = Image.open(io.BytesIO(contents)).convert("RGB")
36
 
37
+ # Resize to 224x224
38
  img = img.resize((224, 224))
39
 
40
  # Preprocess
 
47
  predicted_class = int(np.argmax(predictions[0]))
48
  confidence = float(np.max(predictions[0]) * 100)
49
 
50
+ # Your actual class names
51
+ class_names = [
52
+ "Oral Homogenous Leukoplakia",
53
+ "Oral Non-Homogenous Leukoplakia",
54
+ "Other Oral White Lesions"
55
+ ]
56
 
57
  return {
58
  "predicted_class": predicted_class,