junaid17 commited on
Commit
6b7260e
·
verified ·
1 Parent(s): 25bfc41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -19
app.py CHANGED
@@ -1,19 +1,22 @@
1
- from fastapi import FastAPI, UploadFile, File, HTTPException
2
- from predict_helper import predict_image
3
- from PIL import Image
4
-
5
- app = FastAPI(title="Car Damage Detection API", version="1.0")
6
-
7
- @app.get("/")
8
- def read_root():
9
- return {"status": "API is running"}
10
-
11
- @app.post("/predict")
12
- async def predict(image: UploadFile = File(...)):
13
- try:
14
- img = Image.open(image.file)
15
- except Exception:
16
- raise HTTPException(status_code=400, detail="Invalid image file")
17
-
18
- prediction = predict_image(img)
19
- return prediction
 
 
 
 
1
+ from fastapi import FastAPI, UploadFile, File, HTTPException
2
+ from PIL import Image
3
+ from predict_helper import predict_damage
4
+
5
+ app = FastAPI(
6
+ title="Car Damage Detection API",
7
+ version="1.0"
8
+ )
9
+
10
+ @app.get("/")
11
+ def health():
12
+ return {"status": "API is running"}
13
+
14
+ @app.post("/predict_damage")
15
+ async def predict(image: UploadFile = File(...)):
16
+ try:
17
+ img = Image.open(image.file)
18
+ except Exception:
19
+ raise HTTPException(status_code=400, detail="Invalid image file")
20
+
21
+ result = predict_damage(img)
22
+ return result