chaithrar970 commited on
Commit
b5ac0f9
·
verified ·
1 Parent(s): 3da3f24

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -5
app.py CHANGED
@@ -1,12 +1,22 @@
1
  import gradio as gr
2
  import joblib
3
- import gdown
4
  from gensim.models import KeyedVectors
5
 
6
- # Download models from Google Drive using their file IDs
7
- gdown.download("https://drive.google.com/uc?export=download&id=1iN8Hp4cJfEZc2s4vBij7MrKksGRWWJpL", "word2vec_model.model", quiet=False)
8
- gdown.download("https://drive.google.com/uc?export=download&id=19-vsY_0Gy5EbPOd9qO4mf8rjKvndJfry", "log_reg_model.pkl", quiet=False)
9
- gdown.download("https://drive.google.com/uc?export=download&id=1XR_jMg2WpZPdzpiB7ZXL-iUGHA0l4S3J", "nb_model.pkl", quiet=False)
 
 
 
 
 
 
 
 
 
 
10
 
11
  # Load Word2Vec model
12
  word2vec_model = KeyedVectors.load_word2vec_format('word2vec_model.model', binary=True)
@@ -59,3 +69,4 @@ iface3 = gr.Interface(fn=nb_predict,
59
  iface1.launch()
60
  iface2.launch()
61
  iface3.launch()
 
 
1
  import gradio as gr
2
  import joblib
3
+ import requests
4
  from gensim.models import KeyedVectors
5
 
6
+ # Function to download models using requests
7
+ def download_file_from_google_drive(file_id, destination):
8
+ URL = f"https://drive.google.com/uc?export=download&id={file_id}"
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)
 
69
  iface1.launch()
70
  iface2.launch()
71
  iface3.launch()
72
+