roy214 commited on
Commit
369238a
·
verified ·
1 Parent(s): a570ac2

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +10 -13
src/streamlit_app.py CHANGED
@@ -113,22 +113,19 @@ model = CLIPModel.from_pretrained(
113
  ).to("cpu").eval()
114
 
115
 
116
- # Load FAISS index + id_map
117
- index_path = hf_hub_download(
118
- repo_id=model_repo,
119
- filename="faiss_index.bin",
120
- token=hf_token
121
- )
122
- mapping_path = hf_hub_download(
123
- repo_id=model_repo,
124
- filename="id_map.json",
125
- token=hf_token
126
- )
127
  index = faiss.read_index(index_path)
128
 
129
- # Load processor
130
  processor = CLIPProcessor.from_pretrained(
131
- model_repo,
132
  use_auth_token=hf_token
133
  )
134
 
 
113
  ).to("cpu").eval()
114
 
115
 
116
+ index_path = os.path.join(model_dir, "faiss_index.bin")
117
+ mapping_path = os.path.join(model_dir, "id_map.json")
118
+
119
+ # Kiểm tra file tồn tại
120
+ assert os.path.isfile(index_path), f"Không tìm thấy {index_path}"
121
+ assert os.path.isfile(mapping_path), f"Không tìm thấy {mapping_path}"
122
+
123
+ # Load index
 
 
 
124
  index = faiss.read_index(index_path)
125
 
126
+ # 4. Load processor cũng từ thư mục local
127
  processor = CLIPProcessor.from_pretrained(
128
+ model_dir,
129
  use_auth_token=hf_token
130
  )
131