Update app.py
Browse files
app.py
CHANGED
|
@@ -6,6 +6,7 @@ import numpy as np
|
|
| 6 |
import cv2
|
| 7 |
import requests
|
| 8 |
from fastapi import FastAPI, File, UploadFile, HTTPException
|
|
|
|
| 9 |
|
| 10 |
os.environ["KERAS_BACKEND"] = "jax"
|
| 11 |
import keras
|
|
@@ -17,7 +18,15 @@ IMG_SIZE = 256
|
|
| 17 |
THRESHOLD = 0.05 # ideally derived from healthy images [file:1]
|
| 18 |
|
| 19 |
# βββ Load model once at startup βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
app = FastAPI()
|
| 23 |
|
|
|
|
| 6 |
import cv2
|
| 7 |
import requests
|
| 8 |
from fastapi import FastAPI, File, UploadFile, HTTPException
|
| 9 |
+
from huggingface_hub import hf_hub_download # NEW
|
| 10 |
|
| 11 |
os.environ["KERAS_BACKEND"] = "jax"
|
| 12 |
import keras
|
|
|
|
| 18 |
THRESHOLD = 0.05 # ideally derived from healthy images [file:1]
|
| 19 |
|
| 20 |
# βββ Load model once at startup βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 21 |
+
MODEL_REPO = "sairamv1/TeethCariesDetection_CNNAutoencoder"
|
| 22 |
+
MODEL_FILENAME = "autoencoder.keras" # or whatever file you uploaded
|
| 23 |
+
|
| 24 |
+
local_model_path = hf_hub_download(
|
| 25 |
+
repo_id=MODEL_REPO,
|
| 26 |
+
filename=MODEL_FILENAME,
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
MODEL = keras.saving.load_model(local_model_path)
|
| 30 |
|
| 31 |
app = FastAPI()
|
| 32 |
|