Spaces:
Sleeping
Sleeping
File size: 747 Bytes
96e7aa9 6c58f4c 96e7aa9 c356a26 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
from fastapi import FastAPI
from pydantic import BaseModel
import joblib
app = FastAPI()
try:
model = joblib.load("model.pkl")
print("Model loaded successfully.")
except Exception as e:
print(f"Error loading model: {e}")
model = None
class InputData(BaseModel):
sepal_length: float
sepal_width: float
petal_length: float
petal_width: float
@app.get('/')
def home():
return {"Message: This is live API for tesing prediction"}
@app.post("/masala")
def prediction(data: InputData):
features = [[
data.sepal_length,
data.sepal_width,
data.petal_length,
data.petal_width
]]
result = model.predict(features)
print(result)
return {"Prediction": int(result[0])} |