himanishprak23 Kumarkishalaya commited on
Commit
835a881
1 Parent(s): f18bb84

Update app.py (#4)

Browse files

- Update app.py (cec9e44158e28dd2781d257f02d0646a74bca584)


Co-authored-by: Kumar Kishalaya <Kumarkishalaya@users.noreply.huggingface.co>

Files changed (1) hide show
  1. app.py +7 -9
app.py CHANGED
@@ -4,15 +4,8 @@ from tensorflow.keras.models import load_model
4
  import pickle
5
  import json
6
  import keras
 
7
 
8
- custom_objects = {
9
- 'LSTM': keras.layers.LSTM,
10
- }
11
- # Load model
12
- model_lstm = load_model('seq2seq_model.h5', custom_objects=custom_objects, compile=False)
13
-
14
- # Recompile the model
15
- model_lstm.compile(optimizer='adam', loss='sparse_categorical_crossentropy')
16
 
17
  # Define the model repository and tokenizer checkpoint
18
  model_checkpoint = "himanishprak23/neural_machine_translation"
@@ -26,7 +19,12 @@ tokenizer_nmt = AutoTokenizer.from_pretrained(tokenizer_checkpoint)
26
  model_nmt = TFAutoModelForSeq2SeqLM.from_pretrained(model_checkpoint)
27
 
28
  # Loading models, tokenizer & variables for trained LSTM translation model.
29
- model_lstm = model_lstm
 
 
 
 
 
30
  with open('eng_tokenizer.pkl', 'rb') as file:
31
  eng_tokenizer = pickle.load(file)
32
  with open('hin_tokenizer.pkl', 'rb') as file:
 
4
  import pickle
5
  import json
6
  import keras
7
+ from huggingface_hub import hf_hub_download
8
 
 
 
 
 
 
 
 
 
9
 
10
  # Define the model repository and tokenizer checkpoint
11
  model_checkpoint = "himanishprak23/neural_machine_translation"
 
19
  model_nmt = TFAutoModelForSeq2SeqLM.from_pretrained(model_checkpoint)
20
 
21
  # Loading models, tokenizer & variables for trained LSTM translation model.
22
+ repo_id = "Kumarkishalaya/lstm-eng-to-hin"
23
+ lstm_filename = "seq2seq_model.h5"
24
+ lstm_model_path = hf_hub_download(repo_id=repo_id, filename=lstm_filename)
25
+
26
+ model_lstm = load_model(lstm_model_path)
27
+
28
  with open('eng_tokenizer.pkl', 'rb') as file:
29
  eng_tokenizer = pickle.load(file)
30
  with open('hin_tokenizer.pkl', 'rb') as file: