from fastapi import FastAPI, HTTPException from app.model import IrisModel, IrisInput, IrisPrediction app = FastAPI(title="Iris Classification API", version="1.0.0") # Initialize model model = IrisModel() from fastapi.responses import HTMLResponse @app.get("/", response_class=HTMLResponse) def read_root(): return """
Enter the measurements of the iris flower to predict its species.
You can also access this model via the API.
curl -X POST "https://nipun-ml-deploy-app.hf.space/predict" \
-H "Content-Type: application/json" \
-d '{"sepal_length": 5.1, "sepal_width": 3.5, "petal_length": 1.4, "petal_width": 0.2}'
import requests
url = "https://nipun-ml-deploy-app.hf.space/predict"
data = {
"sepal_length": 5.1,
"sepal_width": 3.5,
"petal_length": 1.4,
"petal_width": 0.2
}
response = requests.post(url, json=data)
print(response.json())
fetch("https://nipun-ml-deploy-app.hf.space/predict", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
sepal_length: 5.1,
sepal_width: 3.5,
petal_length: 1.4,
petal_width: 0.2
})
})
.then(response => response.json())
.then(data => console.log(data));