Sukumar2005 commited on
Commit
f3b0904
·
verified ·
1 Parent(s): b8912a0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -0
app.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ from tensorflow.keras.models import load_model
3
+ from huggingface_hub import hf_hub_download
4
+
5
+ # 🎯 Change to your actual model repo and filename
6
+ REPO_ID = "Sukumar2005/rnn_models"
7
+ FILENAME = "rnn_next_number.h5" # replace with actual model file name
8
+
9
+ def download_model(repo_id: str, filename: str, revision: str = None):
10
+ """Download model from Hugging Face hub."""
11
+ local_path = hf_hub_download(
12
+ repo_id=repo_id,
13
+ filename=filename,
14
+ revision=revision
15
+ )
16
+ return local_path
17
+
18
+ def load_rnn_model(model_path: str):
19
+ return load_model(model_path)
20
+
21
+ def predict_next(model, a: int, b: int, c: int):
22
+ x = np.array([a, b, c], dtype=float).reshape((1, 3, 1))
23
+ return float(model.predict(x)[0][0])
24
+
25
+ def main():
26
+ # 📦 Download
27
+ print("Downloading model...")
28
+ model_path = download_model(REPO_ID, FILENAME)
29
+ print("Model downloaded to:", model_path)
30
+
31
+ # ⚙️ Load
32
+ model = load_rnn_model(model_path)
33
+ print("Model loaded!")
34
+
35
+ # 🧪 Test prediction
36
+ test_input = [10, 11, 12]
37
+ print(f"Input: {test_input}")
38
+ next_val = predict_next(model, *test_input)
39
+ print(f"Predicted next value: {next_val:.2f}")
40
+
41
+ if __name__ == "__main__":
42
+ main()