anshupatel4298 commited on
Commit
731ae2f
1 Parent(s): e553524

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -11,7 +11,7 @@ os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"
11
  # Paths to your models hosted on Hugging Face
12
  basic_model_url = "https://huggingface.co/anshupatel4298/bert-chatbot-model/resolve/main/basic_chatbot_model.h5"
13
  local_model_path = "basic_chatbot_model.h5"
14
- bert_model_name = "anshupatel4298/bert-chatbot-model/bert_model"
15
 
16
  # Define the model architecture that matches the original one
17
  def create_model():
@@ -55,8 +55,10 @@ if st.button("Send"):
55
  if user_input:
56
  if model_choice == "Basic Model":
57
  # Preprocess input for basic model
58
- tokenized_input = tf.keras.preprocessing.text.Tokenizer().texts_to_sequences([user_input])
59
- input_data = tf.keras.preprocessing.sequence.pad_sequences(tokenized_input, maxlen=MAX_SEQUENCE_LENGTH)
 
 
60
  prediction = basic_model.predict(input_data)
61
  response = np.argmax(prediction, axis=-1)[0]
62
  else:
 
11
  # Paths to your models hosted on Hugging Face
12
  basic_model_url = "https://huggingface.co/anshupatel4298/bert-chatbot-model/resolve/main/basic_chatbot_model.h5"
13
  local_model_path = "basic_chatbot_model.h5"
14
+ bert_model_name = "anshupatel4298/bert-chatbot-model"
15
 
16
  # Define the model architecture that matches the original one
17
  def create_model():
 
55
  if user_input:
56
  if model_choice == "Basic Model":
57
  # Preprocess input for basic model
58
+ tokenizer = tf.keras.preprocessing.text.Tokenizer(num_words=1825)
59
+ tokenizer.fit_on_texts([user_input])
60
+ tokenized_input = tokenizer.texts_to_sequences([user_input])
61
+ input_data = tf.keras.preprocessing.sequence.pad_sequences(tokenized_input, maxlen=1825) # Ensure padding to match the input shape
62
  prediction = basic_model.predict(input_data)
63
  response = np.argmax(prediction, axis=-1)[0]
64
  else: