Spaces:
Runtime error
Runtime error
File size: 1,248 Bytes
f3b0904 f7d8c03 f3b0904 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
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()
|