nataliegref commited on
Commit
55a54f0
·
1 Parent(s): e006a97
Files changed (2) hide show
  1. README.md +5 -5
  2. app.py +22 -0
README.md CHANGED
@@ -1,10 +1,10 @@
1
  ---
2
- title: Test IF Api
3
- emoji: 🐠
4
- colorFrom: pink
5
- colorTo: pink
6
  sdk: docker
7
- pinned: false
8
  ---
9
 
10
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: test-if-api
3
+ emoji:
4
+ colorFrom: blue
5
+ colorTo: green
6
  sdk: docker
7
+ app_file: app.py
8
  ---
9
 
10
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py CHANGED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from pydantic import BaseModel
3
+ import numpy as np
4
+ import pickle
5
+ from huggingface_hub import hf_hub_download
6
+
7
+ app = FastAPI()
8
+
9
+ # Download your model pickle from the Hub on startup
10
+ model_path = hf_hub_download(repo_id="ProjectsByIF/test_model", filename="trained_causal_model_v2.pkl")
11
+
12
+ with open(model_path, "rb") as f:
13
+ model = pickle.load(f)
14
+
15
+ class InputData(BaseModel):
16
+ X: list
17
+
18
+ @app.post("/predict")
19
+ def predict(data: InputData):
20
+ X = np.array(data.X)
21
+ effect = model.effect(X).tolist()
22
+ return {"effect": effect}