Mahmoud7 commited on
Commit
ff5c136
·
1 Parent(s): bd0b66e

Upload 4 files

Browse files
Files changed (4) hide show
  1. Dockerfile +13 -0
  2. main.py +35 -0
  3. model.pkl +3 -0
  4. requirements.txt +6 -0
Dockerfile ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+
3
+ COPY requirements.txt app/requirements.txt
4
+
5
+ WORKDIR /app
6
+
7
+ RUN pip install -r requirements.txt
8
+
9
+ COPY . /app
10
+
11
+ EXPOSE 8008
12
+
13
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8008"]
main.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This is a sample Python script.
2
+
3
+ # Press Shift+F10 to execute it or replace it with your code.
4
+ # Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
5
+
6
+
7
+ import uvicorn
8
+ from fastapi import FastAPI
9
+ from pydantic import BaseModel
10
+ import pickle
11
+ import pandas as pd
12
+
13
+ app = FastAPI()
14
+
15
+ class scoring_item(BaseModel):
16
+ battery_power: float
17
+ px_height: float
18
+ px_width: float
19
+ ram: float
20
+
21
+ with open("model.pkl", "rb") as f:
22
+ model = pickle.load(f)
23
+
24
+ @app.post('/predict')
25
+ def scoring_endpoint(item:scoring_item):
26
+ df = pd.DataFrame([item.dict().values()], columns=item.dict().keys())
27
+ ypred = model.predict(df)
28
+ return int(ypred)
29
+
30
+ """@app.get('/Welcome')
31
+ def get_name(name: str):
32
+ return {'Brace yourself, ': f'{name}'}"""
33
+
34
+ """if __name__ == '__main__':
35
+ uvicorn.run(app, host='127.0.0.1',port=8000)"""
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:13949eb60106fe82814d1b26629538574af418d3951fcc090b7fb87ab2e11031
3
+ size 1002952
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ pandas==1.4.2
2
+ uvicorn==0.18.3
3
+ pydantic==1.10.2
4
+ pickle-mixin==1.0.2
5
+ fastapi==0.85.1
6
+ scikit-learn==1.1.2