Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -32,6 +32,22 @@ 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 :
|
@@ -59,8 +75,8 @@ def encode_database(model, df: pd.DataFrame) -> np.ndarray :
|
|
59 |
|
60 |
# Load model and configurations
|
61 |
def load_model():
|
62 |
-
model = Model(model_name="ViTamin-L-384", pretrained=
|
63 |
-
|
64 |
model.eval()
|
65 |
return model
|
66 |
|
@@ -161,6 +177,8 @@ demo = gr.Interface(
|
|
161 |
title="Compositional Image Retrieval",
|
162 |
description="Select an image and enter a text query to find the most similar image.",
|
163 |
examples=[
|
|
|
|
|
164 |
["sample_evaluation/images/455007.png", "Discard chair in the beginning, then proceed to bring car into play."],
|
165 |
["sample_evaluation/images/612311.png", "Get rid of train initially, and then follow up by including snowboard."]
|
166 |
]
|
|
|
32 |
extract_path = "sample_evaluation"
|
33 |
unzip_file(zip_path, extract_path)
|
34 |
|
35 |
+
import requests
|
36 |
+
|
37 |
+
def download_file(url, output_file):
|
38 |
+
response = requests.get(url, stream=True)
|
39 |
+
response.raise_for_status() # Raises an HTTPError if the status is 4xx, 5xx
|
40 |
+
|
41 |
+
with open(output_file, 'wb') as file:
|
42 |
+
for chunk in response.iter_content(chunk_size=8192):
|
43 |
+
if chunk:
|
44 |
+
file.write(chunk)
|
45 |
+
|
46 |
+
# Example usage
|
47 |
+
url = "https://huggingface.co/safinal/compositional-retrieval/resolve/main/weights.pth"
|
48 |
+
output_file = "weights.pth"
|
49 |
+
download_file(url, output_file)
|
50 |
+
|
51 |
|
52 |
|
53 |
def encode_database(model, df: pd.DataFrame) -> np.ndarray :
|
|
|
75 |
|
76 |
# Load model and configurations
|
77 |
def load_model():
|
78 |
+
model = Model(model_name="ViTamin-L-384", pretrained=None)
|
79 |
+
model.load("weights.pth")
|
80 |
model.eval()
|
81 |
return model
|
82 |
|
|
|
177 |
title="Compositional Image Retrieval",
|
178 |
description="Select an image and enter a text query to find the most similar image.",
|
179 |
examples=[
|
180 |
+
["sample_evaluation/images/261684.png", "Bring cow into the picture, and then follow up with removing bench."],
|
181 |
+
["sample_evaluation/images/283700.png", "add bowl and bench and remove shoe and elephant"],
|
182 |
["sample_evaluation/images/455007.png", "Discard chair in the beginning, then proceed to bring car into play."],
|
183 |
["sample_evaluation/images/612311.png", "Get rid of train initially, and then follow up by including snowboard."]
|
184 |
]
|