Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- 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 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
)
|
| 122 |
-
|
| 123 |
-
|
| 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 |
-
|
| 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 |
|