Spaces:
Sleeping
Sleeping
| from fastapi import FastAPI | |
| import tensorflow as tf | |
| import joblib | |
| import json | |
| from huggingface_hub import hf_hub_download | |
| app = FastAPI(title="Equilibrium India V1") | |
| MODEL_REPO = "Vansh180/Equilibrium-India-V1" # MODEL repo (not Space) | |
| MODEL_FILENAME = "systemic_risk_model.keras" | |
| # Download model file from model repo into the container filesystem | |
| model_path = hf_hub_download( | |
| repo_id=MODEL_REPO, | |
| filename=MODEL_FILENAME, | |
| repo_type="model" | |
| ) | |
| # Load artifacts at startup | |
| model = tf.keras.models.load_model(model_path) | |
| scaler = joblib.load("scaler.pkl") | |
| with open("feature_columns.json") as f: | |
| feature_columns = json.load(f) | |
| with open("config.json") as f: | |
| config = json.load(f) | |
| def root(): | |
| return { | |
| "status": "ok", | |
| "model": "Equilibrium-India-V1", | |
| "features": feature_columns, | |
| "tickers": config.get("tickers", []), | |
| "model_repo": MODEL_REPO | |
| } | |
| def health(): | |
| return {"status": "healthy"} | |