Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,16 +2,25 @@ import streamlit as st
|
|
2 |
from transformers import BertTokenizer, TFBertForSequenceClassification
|
3 |
import tensorflow as tf
|
4 |
import numpy as np
|
5 |
-
|
6 |
import os
|
|
|
|
|
7 |
os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"
|
8 |
|
9 |
# Paths to your models hosted on Hugging Face
|
10 |
basic_model_url = "https://huggingface.co/anshupatel4298/bert-chatbot-model/resolve/main/basic_chatbot_model.h5"
|
|
|
11 |
bert_model_name = "anshupatel4298/bert-chatbot-model/bert_model"
|
12 |
|
13 |
-
#
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
# Load BERT Model and Tokenizer
|
17 |
bert_model = TFBertForSequenceClassification.from_pretrained(bert_model_name)
|
|
|
2 |
from transformers import BertTokenizer, TFBertForSequenceClassification
|
3 |
import tensorflow as tf
|
4 |
import numpy as np
|
5 |
+
import requests
|
6 |
import os
|
7 |
+
|
8 |
+
# Ensure PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION is set to "python"
|
9 |
os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"
|
10 |
|
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 |
+
# Download the Basic Model from the URL
|
17 |
+
if not os.path.exists(local_model_path):
|
18 |
+
response = requests.get(basic_model_url)
|
19 |
+
with open(local_model_path, 'wb') as f:
|
20 |
+
f.write(response.content)
|
21 |
+
|
22 |
+
# Load Basic Model from the local file
|
23 |
+
basic_model = tf.keras.models.load_model(local_model_path)
|
24 |
|
25 |
# Load BERT Model and Tokenizer
|
26 |
bert_model = TFBertForSequenceClassification.from_pretrained(bert_model_name)
|