Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,6 +15,25 @@ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
| 15 |
batch_size = 512
|
| 16 |
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
def encode_database(model, df: pd.DataFrame) -> np.ndarray :
|
| 19 |
"""
|
| 20 |
Process database images and generate embeddings.
|
|
|
|
| 15 |
batch_size = 512
|
| 16 |
|
| 17 |
|
| 18 |
+
import zipfile
|
| 19 |
+
import os
|
| 20 |
+
|
| 21 |
+
def unzip_file(zip_path, extract_path):
|
| 22 |
+
# Create the target directory if it doesn't exist
|
| 23 |
+
os.makedirs(extract_path, exist_ok=True)
|
| 24 |
+
|
| 25 |
+
# Open the zip file
|
| 26 |
+
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
| 27 |
+
# Extract all contents to the specified directory
|
| 28 |
+
zip_ref.extractall(extract_path)
|
| 29 |
+
|
| 30 |
+
# Example usage
|
| 31 |
+
zip_path = "sample_evaluation.zip"
|
| 32 |
+
extract_path = "sample_evaluation"
|
| 33 |
+
unzip_file(zip_path, extract_path)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
|
| 37 |
def encode_database(model, df: pd.DataFrame) -> np.ndarray :
|
| 38 |
"""
|
| 39 |
Process database images and generate embeddings.
|