Spaces:
Runtime error
Runtime error
import numpy as np | |
from tensorflow.keras.models import load_model | |
from huggingface_hub import hf_hub_download | |
# π― Change to your actual model repo and filename | |
REPO_ID = "Sukumar2005/rnn_models" | |
FILENAME = "/content/drive/MyDrive/model.keras" # replace with actual model file name | |
def download_model(repo_id: str, filename: str, revision: str = None): | |
"""Download model from Hugging Face hub.""" | |
local_path = hf_hub_download( | |
repo_id=repo_id, | |
filename=filename, | |
revision=revision | |
) | |
return local_path | |
def load_rnn_model(model_path: str): | |
return load_model(model_path) | |
def predict_next(model, a: int, b: int, c: int): | |
x = np.array([a, b, c], dtype=float).reshape((1, 3, 1)) | |
return float(model.predict(x)[0][0]) | |
def main(): | |
# π¦ Download | |
print("Downloading model...") | |
model_path = download_model(REPO_ID, FILENAME) | |
print("Model downloaded to:", model_path) | |
# βοΈ Load | |
model = load_rnn_model(model_path) | |
print("Model loaded!") | |
# π§ͺ Test prediction | |
test_input = [10, 11, 12] | |
print(f"Input: {test_input}") | |
next_val = predict_next(model, *test_input) | |
print(f"Predicted next value: {next_val:.2f}") | |
if __name__ == "__main__": | |
main() | |