edit main
Browse files
main.py
CHANGED
|
@@ -1,29 +1,3 @@
|
|
| 1 |
-
<<<<<<< HEAD
|
| 2 |
-
from fastapi import FastAPI, File, UploadFile, HTTPException
|
| 3 |
-
from prediction import prediction , calculate_calories
|
| 4 |
-
|
| 5 |
-
# prediction_model = prediction("best.pt" , "10.jpg")
|
| 6 |
-
# print(prediction_model)
|
| 7 |
-
|
| 8 |
-
app = FastAPI()
|
| 9 |
-
@app.get("/")
|
| 10 |
-
async def read_root():
|
| 11 |
-
return {"message": "Food Model API"}
|
| 12 |
-
|
| 13 |
-
@app.post("/predict")
|
| 14 |
-
async def predict(file: UploadFile = File(...)):
|
| 15 |
-
if file.content_type.startswith('image'):
|
| 16 |
-
test_image = await file.read()
|
| 17 |
-
predictions = prediction("best.pt" , test_image)
|
| 18 |
-
calories = calculate_calories(predictions)
|
| 19 |
-
return {"predictions": predictions, "calories": calories}
|
| 20 |
-
else:
|
| 21 |
-
raise HTTPException(status_code=415, detail="Unsupported file type")
|
| 22 |
-
|
| 23 |
-
if __name__ == "__main__":
|
| 24 |
-
import uvicorn
|
| 25 |
-
uvicorn.run(app, host="localhost", port=8000)
|
| 26 |
-
=======
|
| 27 |
from fastapi import FastAPI, File, UploadFile, HTTPException , Request
|
| 28 |
from prediction import prediction , calculate_calories
|
| 29 |
from predictBody import predictBody
|
|
@@ -64,4 +38,3 @@ async def predict(file: UploadFile = File(...)):
|
|
| 64 |
if __name__ == "__main__":
|
| 65 |
import uvicorn
|
| 66 |
uvicorn.run(app, host="localhost", port=8000)
|
| 67 |
-
>>>>>>> c87f885 (adding RFM measurement)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from fastapi import FastAPI, File, UploadFile, HTTPException , Request
|
| 2 |
from prediction import prediction , calculate_calories
|
| 3 |
from predictBody import predictBody
|
|
|
|
| 38 |
if __name__ == "__main__":
|
| 39 |
import uvicorn
|
| 40 |
uvicorn.run(app, host="localhost", port=8000)
|
|
|