syedzaidi-kiwi commited on
Commit
86fbe19
·
verified ·
1 Parent(s): 9115c2c

Upload folder using huggingface_hub

Browse files
Files changed (5) hide show
  1. Dockerfile +12 -0
  2. README.md +2 -9
  3. app/main.py +17 -0
  4. app/model.pkl +3 -0
  5. app/requirements.txt +5 -0
Dockerfile ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ FROM python:3.10
3
+
4
+ WORKDIR /code
5
+
6
+ COPY app/requirements.txt .
7
+ RUN pip install --no-cache-dir -r requirements.txt
8
+
9
+ COPY app /code/app
10
+
11
+ EXPOSE 7860
12
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
README.md CHANGED
@@ -1,10 +1,3 @@
1
- ---
2
- title: Diabetes Api Fastapi
3
- emoji: 🔥
4
- colorFrom: blue
5
- colorTo: yellow
6
- sdk: docker
7
- pinned: false
8
- ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+ # Diabetes Prediction API using FastAPI
 
 
 
 
 
 
 
2
 
3
+ POST /predict
app/main.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ from fastapi import FastAPI
3
+ from pydantic import BaseModel
4
+ import joblib
5
+ import pandas as pd
6
+
7
+ model = joblib.load("app/model.pkl")
8
+ app = FastAPI()
9
+
10
+ class ModelInput(BaseModel):
11
+ input: list
12
+
13
+ @app.post("/predict")
14
+ def predict(data: ModelInput):
15
+ input_df = pd.DataFrame([data.input], columns=["preg", "plas", "pres", "skin", "test", "mass", "pedi", "age"])
16
+ prediction = int(model.predict(input_df)[0])
17
+ return {"prediction": prediction}
app/model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a493e8730770095a1d02381f1161cee2921db62a911918087c8386fbc15cf831
3
+ size 15769
app/requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ fastapi
2
+ uvicorn
3
+ joblib
4
+ pandas
5
+ scikit-learn