Instructions to use shalev396/eu-stock-forecasting with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use shalev396/eu-stock-forecasting with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://shalev396/eu-stock-forecasting") - Notebooks
- Google Colab
- Kaggle
Download handler.py from shalev396/eu-stock-forecasting: direct link, hf CLI and curl.
- Browser
- Download file 1.05 kB
-
https://huggingface.co/shalev396/eu-stock-forecasting/resolve/main/handler.py
- Command line
-
hf download hf://shalev396/eu-stock-forecasting/handler.py
-
curl -L -o handler.py https://huggingface.co/shalev396/eu-stock-forecasting/resolve/main/handler.py
1.05 kB
| """Hugging Face Inference Endpoints entry point — deploy this repo as a CPU API. | |
| Request body: {"inputs": {"cutoff": "1997-10-01", "horizon": 30, "index": "DAX"}} | |
| (also accepted: {"inputs": "1997-10-01", "parameters": {"horizon": 30, "index": "DAX"}} | |
| or {"inputs": ["1997-10-01", 30, "DAX"]}). Response: the `Predictor.predict` JSON dict. | |
| """ | |
| import sys | |
| from pathlib import Path | |
| HERE = Path(__file__).resolve().parent | |
| sys.path.insert(0, str(HERE)) | |
| import model as M # noqa: E402 | |
| class EndpointHandler: | |
| def __init__(self, path: str = ""): | |
| self.predictor = M.load(path or HERE, "cuda" if M.cuda_available() else "cpu") | |
| def __call__(self, data: dict): | |
| inputs = data.pop("inputs", data) | |
| parameters = data.pop("parameters", None) or {} | |
| if isinstance(inputs, dict): | |
| return self.predictor.predict(**inputs, **parameters) | |
| if isinstance(inputs, (list, tuple)): | |
| return self.predictor.predict(*inputs, **parameters) | |
| return self.predictor.predict(inputs, **parameters) | |