Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,24 +1,18 @@
|
|
| 1 |
-
import
|
| 2 |
import joblib
|
| 3 |
import requests
|
| 4 |
from gensim.models import KeyedVectors
|
| 5 |
|
| 6 |
-
# Function to download
|
| 7 |
def download_file_from_google_drive(file_id, destination):
|
| 8 |
-
|
| 9 |
-
session = requests.Session()
|
| 10 |
-
response = session.get(URL, stream=True)
|
| 11 |
-
with open(destination, "wb") as f:
|
| 12 |
-
for chunk in response.iter_content(chunk_size=1024):
|
| 13 |
-
if chunk:
|
| 14 |
-
f.write(chunk)
|
| 15 |
|
| 16 |
-
# Download models from Google Drive
|
| 17 |
download_file_from_google_drive('1iN8Hp4cJfEZc2s4vBij7MrKksGRWWJpL', 'word2vec_model.model')
|
| 18 |
download_file_from_google_drive('19-vsY_0Gy5EbPOd9qO4mf8rjKvndJfry', 'log_reg_model.pkl')
|
| 19 |
download_file_from_google_drive('1XR_jMg2WpZPdzpiB7ZXL-iUGHA0l4S3J', 'nb_model.pkl')
|
| 20 |
|
| 21 |
-
# Load Word2Vec model
|
| 22 |
word2vec_model = KeyedVectors.load_word2vec_format('word2vec_model.model', binary=True)
|
| 23 |
|
| 24 |
# Load Logistic Regression model
|
|
@@ -69,4 +63,3 @@ iface3 = gr.Interface(fn=nb_predict,
|
|
| 69 |
iface1.launch()
|
| 70 |
iface2.launch()
|
| 71 |
iface3.launch()
|
| 72 |
-
|
|
|
|
| 1 |
+
import gdown
|
| 2 |
import joblib
|
| 3 |
import requests
|
| 4 |
from gensim.models import KeyedVectors
|
| 5 |
|
| 6 |
+
# Function to download files from Google Drive using gdown
|
| 7 |
def download_file_from_google_drive(file_id, destination):
|
| 8 |
+
gdown.download(f"https://drive.google.com/uc?export=download&id={file_id}", destination, quiet=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
# Download models from Google Drive using the file IDs
|
| 11 |
download_file_from_google_drive('1iN8Hp4cJfEZc2s4vBij7MrKksGRWWJpL', 'word2vec_model.model')
|
| 12 |
download_file_from_google_drive('19-vsY_0Gy5EbPOd9qO4mf8rjKvndJfry', 'log_reg_model.pkl')
|
| 13 |
download_file_from_google_drive('1XR_jMg2WpZPdzpiB7ZXL-iUGHA0l4S3J', 'nb_model.pkl')
|
| 14 |
|
| 15 |
+
# Load Word2Vec model (make sure it's in binary format)
|
| 16 |
word2vec_model = KeyedVectors.load_word2vec_format('word2vec_model.model', binary=True)
|
| 17 |
|
| 18 |
# Load Logistic Regression model
|
|
|
|
| 63 |
iface1.launch()
|
| 64 |
iface2.launch()
|
| 65 |
iface3.launch()
|
|
|