Spaces:
Sleeping
Sleeping
Download app.py from nataliegref/test-IF-api: direct link, hf CLI and curl.
- Browser
- Download file 561 Bytes
-
https://huggingface.co/spaces/nataliegref/test-IF-api/resolve/main/app.py
- Command line
-
hf download hf://spaces/nataliegref/test-IF-api/app.py
-
curl -L -o app.py https://huggingface.co/spaces/nataliegref/test-IF-api/resolve/main/app.py
561 Bytes
| from fastapi import FastAPI | |
| from pydantic import BaseModel | |
| import numpy as np | |
| import pickle | |
| from huggingface_hub import hf_hub_download | |
| app = FastAPI() | |
| # Download your model pickle from the Hub on startup | |
| model_path = hf_hub_download(repo_id="nataliegref/test-model", filename="trained_causal_model_v2.pkl") | |
| with open(model_path, "rb") as f: | |
| model = pickle.load(f) | |
| class InputData(BaseModel): | |
| X: list | |
| def predict(data: InputData): | |
| X = np.array(data.X) | |
| effect = model.effect(X).tolist() | |
| return {"effect": effect} | |