Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
| 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 |
-
#
|
| 52 |
-
class_names = [
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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,
|