arpannookala commited on
Commit
6db8e2c
·
1 Parent(s): a61b64b

change app and rew

Browse files
Files changed (1) hide show
  1. app.py +7 -40
app.py CHANGED
@@ -21,9 +21,9 @@ nltk.download('omw-1.4')
21
  import gdown
22
  import zipfile
23
  import os
24
- import shutil
25
  # Function to download and extract folder
26
- def download_and_extract_gdrive_finetuned(file_id, destination, extract_to):
27
  # Download the zip file
28
  gdown.download(f"https://drive.google.com/uc?id={file_id}", destination, quiet=False)
29
 
@@ -32,61 +32,28 @@ def download_and_extract_gdrive_finetuned(file_id, destination, extract_to):
32
  zip_ref.extractall(extract_to)
33
  os.remove(destination) # Clean up the downloaded zip file
34
 
35
- def download_and_extract_gdrive(file_id, destination, extract_to):
36
- # Download the zip file
37
- gdown.download(f"https://drive.google.com/uc?id={file_id}", destination, quiet=False)
38
-
39
- # Use a temporary directory for extraction
40
- temp_dir = "./temp_extract"
41
- os.makedirs(temp_dir, exist_ok=True)
42
-
43
- with zipfile.ZipFile(destination, 'r') as zip_ref:
44
- zip_ref.extractall(temp_dir)
45
-
46
- # Ensure files are moved correctly
47
- if not os.path.exists(extract_to):
48
- os.makedirs(extract_to, exist_ok=True)
49
-
50
- for item in os.listdir(temp_dir):
51
- item_path = os.path.join(temp_dir, item)
52
- shutil.move(item_path, os.path.join(extract_to, item))
53
-
54
- # Cleanup
55
- shutil.rmtree(temp_dir)
56
- os.remove(destination)
57
-
58
-
59
  # Download and extract LanceDB and fine-tuned model
60
  st.info("Downloading and setting up necessary data. This might take a while...")
61
 
62
  download_and_extract_gdrive(
63
  file_id="1Qnb8bs_NXWlhDwGoswOgsp2DiLBMbfSY", # Replace with the actual Google Drive file ID
64
- destination="lancedb_directory_main",
65
  extract_to="./"
66
  )
67
 
68
- download_and_extract_gdrive_finetuned(
69
  file_id="1_9VVuN_P3zsTBYzg0lAeh4ghd9zhXS3w", # Replace with the actual Google Drive file ID
70
- destination="finetuned_all_minilm_l6_v2",
71
  extract_to="./"
72
  )
73
  # # --------------------------- Load the LanceDB Table and Models --------------------------- #
74
- # Validate extracted files
75
- expected_files = [
76
- "enhanced_papers_pretrained_1.lance",
77
- "enhanced_papers_pretrained_2.lance",
78
- "enhanced_papers_finetuned.lance"
79
- ]
80
- for file in expected_files:
81
- file_path = os.path.join("./lancedb_directory_main", file)
82
- if not os.path.isfile(file_path):
83
- raise FileNotFoundError(f"Expected file is missing: {file_path}")
84
  # Connect to LanceDB
85
  DB_PATH = "./lancedb_directory_main"
86
  TABLE_NAME_1 = "enhanced_papers_pretrained_1"
87
  TABLE_NAME_2 = "enhanced_papers_pretrained_2"
88
  TABLE_NAME_3 = "enhanced_papers_finetuned"
89
- os.makedirs(DB_PATH, exist_ok=True)
90
  db = lancedb.connect(DB_PATH)
91
  table1 = db.open_table(TABLE_NAME_1)
92
  table2 = db.open_table(TABLE_NAME_2)
 
21
  import gdown
22
  import zipfile
23
  import os
24
+
25
  # Function to download and extract folder
26
+ def download_and_extract_gdrive(file_id, destination, extract_to):
27
  # Download the zip file
28
  gdown.download(f"https://drive.google.com/uc?id={file_id}", destination, quiet=False)
29
 
 
32
  zip_ref.extractall(extract_to)
33
  os.remove(destination) # Clean up the downloaded zip file
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  # Download and extract LanceDB and fine-tuned model
36
  st.info("Downloading and setting up necessary data. This might take a while...")
37
 
38
  download_and_extract_gdrive(
39
  file_id="1Qnb8bs_NXWlhDwGoswOgsp2DiLBMbfSY", # Replace with the actual Google Drive file ID
40
+ destination="lancedb_directory_main.zip",
41
  extract_to="./"
42
  )
43
 
44
+ download_and_extract_gdrive(
45
  file_id="1_9VVuN_P3zsTBYzg0lAeh4ghd9zhXS3w", # Replace with the actual Google Drive file ID
46
+ destination="finetuned_all_minilm_l6_v2.zip",
47
  extract_to="./"
48
  )
49
  # # --------------------------- Load the LanceDB Table and Models --------------------------- #
50
+
 
 
 
 
 
 
 
 
 
51
  # Connect to LanceDB
52
  DB_PATH = "./lancedb_directory_main"
53
  TABLE_NAME_1 = "enhanced_papers_pretrained_1"
54
  TABLE_NAME_2 = "enhanced_papers_pretrained_2"
55
  TABLE_NAME_3 = "enhanced_papers_finetuned"
56
+
57
  db = lancedb.connect(DB_PATH)
58
  table1 = db.open_table(TABLE_NAME_1)
59
  table2 = db.open_table(TABLE_NAME_2)