BeeBasic commited on
Commit
e0e8fcf
·
verified ·
1 Parent(s): ea8f787
Files changed (3) hide show
  1. Dockerfile +10 -0
  2. app.py +24 -0
  3. requirements.txt +5 -0
Dockerfile ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10
2
+
3
+ WORKDIR /code
4
+
5
+ COPY requirements.txt .
6
+ RUN pip install --no-cache-dir -r requirements.txt
7
+
8
+ COPY . .
9
+
10
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, Request
2
+ import joblib
3
+
4
+ app = FastAPI(title="Food Surplus Predictor")
5
+
6
+ # Load model from Hugging Face model repo
7
+ model = joblib.load("https://huggingface.co/BeeBasic/food-for-all/resolve/main/best_model.joblib")
8
+
9
+ @app.post("/predict")
10
+ async def predict(request: Request):
11
+ data = await request.json()
12
+
13
+ canteens = data.get("canteens", [])
14
+ ngos = data.get("ngos", [])
15
+
16
+ total_surplus = sum(item["surplus"] for item in canteens)
17
+ total_need = sum(item["requirement"] for item in ngos)
18
+ balance = total_surplus - total_need
19
+
20
+ return {
21
+ "total_surplus": total_surplus,
22
+ "total_need": total_need,
23
+ "balance": balance
24
+ }
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ fastapi
2
+ uvicorn
3
+ joblib
4
+ requests
5
+ scikit-learn