Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
|
@@ -10,6 +10,8 @@ from projects.DL_CatDog.DL_CatDog import preprocess_image, read_image, model_DL_
|
|
| 10 |
from projects.ML_StudentPerformance.ML_StudentPerformace import predict_student_performance, create_custom_data, form1
|
| 11 |
from projects.ML_DiabetesPrediction.ML_DiabetesPrediction import model_ML_DiabetesPrediction, form2
|
| 12 |
|
|
|
|
|
|
|
| 13 |
app = FastAPI()
|
| 14 |
|
| 15 |
# Add CORS middleware
|
|
@@ -21,6 +23,7 @@ app.add_middleware(
|
|
| 21 |
allow_headers=["*"],
|
| 22 |
)
|
| 23 |
|
|
|
|
| 24 |
# Health check route
|
| 25 |
@app.get("/api/working")
|
| 26 |
def home():
|
|
@@ -39,7 +42,7 @@ async def predict_DL_CatDog(file: UploadFile = File(...)):
|
|
| 39 |
return JSONResponse(content={"ok": -1, "message": f"Something went wrong! {str(e)}"}, status_code=500)
|
| 40 |
|
| 41 |
# Classification route for DL_PlantDisease
|
| 42 |
-
pipe = pipeline("image-classification", model="wambugu71/crop_leaf_diseases_vit")
|
| 43 |
@app.post("/api/classify")
|
| 44 |
async def classify_image(file: UploadFile = File(...)):
|
| 45 |
try:
|
|
|
|
| 10 |
from projects.ML_StudentPerformance.ML_StudentPerformace import predict_student_performance, create_custom_data, form1
|
| 11 |
from projects.ML_DiabetesPrediction.ML_DiabetesPrediction import model_ML_DiabetesPrediction, form2
|
| 12 |
|
| 13 |
+
os.environ['HF_HOME'] = './mycache'
|
| 14 |
+
|
| 15 |
app = FastAPI()
|
| 16 |
|
| 17 |
# Add CORS middleware
|
|
|
|
| 23 |
allow_headers=["*"],
|
| 24 |
)
|
| 25 |
|
| 26 |
+
|
| 27 |
# Health check route
|
| 28 |
@app.get("/api/working")
|
| 29 |
def home():
|
|
|
|
| 42 |
return JSONResponse(content={"ok": -1, "message": f"Something went wrong! {str(e)}"}, status_code=500)
|
| 43 |
|
| 44 |
# Classification route for DL_PlantDisease
|
| 45 |
+
pipe = pipeline("image-classification", model="wambugu71/crop_leaf_diseases_vit", cache_dir="./mycache")
|
| 46 |
@app.post("/api/classify")
|
| 47 |
async def classify_image(file: UploadFile = File(...)):
|
| 48 |
try:
|