Spaces:
Sleeping
Sleeping
Commit ·
96e7aa9
1
Parent(s): 8058f4b
Testing API
Browse files- Dockerfile +20 -0
- README.md +1 -0
- app.py +30 -0
- model.pkl +3 -0
- requirements.txt +0 -0
Dockerfile
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use the official Python base image
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
+
|
| 4 |
+
# Set the working directory in the container
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Copy the requirements file into the container
|
| 8 |
+
COPY requirements.txt .
|
| 9 |
+
|
| 10 |
+
# Install the dependencies
|
| 11 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 12 |
+
|
| 13 |
+
# Copy the rest of the application files
|
| 14 |
+
COPY . .
|
| 15 |
+
|
| 16 |
+
# Expose the port that Uvicorn will run on
|
| 17 |
+
EXPOSE 7860
|
| 18 |
+
|
| 19 |
+
# Command to run the application
|
| 20 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
README.md
CHANGED
|
@@ -4,6 +4,7 @@ emoji: 🚀
|
|
| 4 |
colorFrom: pink
|
| 5 |
colorTo: purple
|
| 6 |
sdk: docker
|
|
|
|
| 7 |
pinned: false
|
| 8 |
short_description: this for testing purpose only.
|
| 9 |
---
|
|
|
|
| 4 |
colorFrom: pink
|
| 5 |
colorTo: purple
|
| 6 |
sdk: docker
|
| 7 |
+
app_file: app.py
|
| 8 |
pinned: false
|
| 9 |
short_description: this for testing purpose only.
|
| 10 |
---
|
app.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from pydantic import BaseModel
|
| 3 |
+
import joblib
|
| 4 |
+
|
| 5 |
+
app = FastAPI()
|
| 6 |
+
|
| 7 |
+
with open("model.pkl") as mdl:
|
| 8 |
+
model = joblib.load(mdl)
|
| 9 |
+
|
| 10 |
+
class InputData(BaseModel):
|
| 11 |
+
sepal_length: float
|
| 12 |
+
sepal_width: float
|
| 13 |
+
petal_length: float
|
| 14 |
+
petal_width: float
|
| 15 |
+
|
| 16 |
+
@app.get('/')
|
| 17 |
+
def home():
|
| 18 |
+
return {"Message: This is live API for tesing prediction"}
|
| 19 |
+
|
| 20 |
+
@app.post("/masala")
|
| 21 |
+
def prediction(data: InputData):
|
| 22 |
+
features = [[
|
| 23 |
+
data.sepal_length,
|
| 24 |
+
data.sepal_width,
|
| 25 |
+
data.petal_length,
|
| 26 |
+
data.petal_width
|
| 27 |
+
]]
|
| 28 |
+
|
| 29 |
+
result = model.predict(features)
|
| 30 |
+
return {"Prediction": result}
|
model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3804676371c6bb25267fdbdc0025d897a24d9cd5205bd0a77ec8b981b1faca48
|
| 3 |
+
size 19409
|
requirements.txt
ADDED
|
Binary file (102 Bytes). View file
|
|
|