Spaces:
Sleeping
Sleeping
Download app.py from ankitt6174/for-testing: direct link, hf CLI and curl.
- Browser
- Download file 747 Bytes
-
https://huggingface.co/spaces/ankitt6174/for-testing/resolve/main/app.py
- Command line
-
hf download hf://spaces/ankitt6174/for-testing/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ankitt6174/for-testing/resolve/main/app.py
747 Bytes
| 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 | |
| def home(): | |
| return {"Message: This is live API for tesing prediction"} | |
| 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])} |