Spaces:
Sleeping
Sleeping
File size: 561 Bytes
55a54f0 3e93078 55a54f0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 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
@app.post("/predict")
def predict(data: InputData):
X = np.array(data.X)
effect = model.effect(X).tolist()
return {"effect": effect}
|