xValentim commited on
Commit
35f858f
·
1 Parent(s): 8e89b86
Files changed (4) hide show
  1. Dockerfile +11 -0
  2. main.py +34 -0
  3. my_model.pkl +3 -0
  4. requirements.txt +4 -0
Dockerfile ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+
3
+ WORKDIR /code
4
+
5
+ COPY ./requirements.txt /code/requirements.txt
6
+
7
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
+
9
+ COPY . .
10
+
11
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
main.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ import pickle
3
+ import uvicorn
4
+ import pandas as pd
5
+
6
+ app = FastAPI()
7
+
8
+
9
+ # Function to load pickle file
10
+ def load_pickle(filename):
11
+ with open(filename, 'rb') as file:
12
+ data = pickle.load(file)
13
+ return data
14
+
15
+ # Load pickle file
16
+ ml_components = load_pickle('my_model.pkl')
17
+
18
+ # Components in the pickle file
19
+ ml_model = ml_components['model']
20
+
21
+ #Endpoints
22
+ #Root endpoints
23
+ @app.get("/")
24
+ def root():
25
+ return {"API": "An API for Sepsis Prediction."}
26
+
27
+ @app.get('/Predict_Sepsis')
28
+ async def predict(data: dict):
29
+
30
+ data = pd.DataFrame(data)
31
+
32
+ model_output = ml_model.predict(data)]
33
+ print('pred', model_output)
34
+ return model_output
my_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d6499bfeaa6d38119806ad1b37d129385745eeb4c1b6ab471eebf6806cf43d4a
3
+ size 172733
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ fastapi[all]
2
+ uvicorn[standard]
3
+ scikit-learn==1.2.2
4
+ pandas