Spaces:
Running
Running
Bugfix: stop caching heatmap in localization
Browse files- localization.py +6 -3
localization.py
CHANGED
|
@@ -73,7 +73,7 @@ def gen_image_batch(image_url, image_size=224, pixel_size=10):
|
|
| 73 |
|
| 74 |
return image_batch, masks
|
| 75 |
|
| 76 |
-
|
| 77 |
def get_heatmap(image_url, text, pixel_size=10, iterations=3):
|
| 78 |
tokenizer = get_tokenizer()
|
| 79 |
model = get_model()
|
|
@@ -139,7 +139,7 @@ def app():
|
|
| 139 |
|
| 140 |
MAX_ITER = 1
|
| 141 |
|
| 142 |
-
col1, col2 = st.
|
| 143 |
|
| 144 |
with col2:
|
| 145 |
pixel_size = st.selectbox("Pixel Size", options=range(10, 26, 5), index=2)
|
|
@@ -174,7 +174,10 @@ def app():
|
|
| 174 |
gc.collect()
|
| 175 |
|
| 176 |
elif image_url:
|
| 177 |
-
image = requests.get(
|
|
|
|
|
|
|
|
|
|
| 178 |
image = Image.open(image).convert("RGB")
|
| 179 |
with col1:
|
| 180 |
st.image(image)
|
|
|
|
| 73 |
|
| 74 |
return image_batch, masks
|
| 75 |
|
| 76 |
+
|
| 77 |
def get_heatmap(image_url, text, pixel_size=10, iterations=3):
|
| 78 |
tokenizer = get_tokenizer()
|
| 79 |
model = get_model()
|
|
|
|
| 139 |
|
| 140 |
MAX_ITER = 1
|
| 141 |
|
| 142 |
+
col1, col2 = st.columns([3, 1])
|
| 143 |
|
| 144 |
with col2:
|
| 145 |
pixel_size = st.selectbox("Pixel Size", options=range(10, 26, 5), index=2)
|
|
|
|
| 174 |
gc.collect()
|
| 175 |
|
| 176 |
elif image_url:
|
| 177 |
+
image = requests.get(
|
| 178 |
+
image_url,
|
| 179 |
+
stream=True,
|
| 180 |
+
).raw
|
| 181 |
image = Image.open(image).convert("RGB")
|
| 182 |
with col1:
|
| 183 |
st.image(image)
|