Spaces:
Build error
Build error
edits
Browse files
app.py
CHANGED
@@ -147,6 +147,7 @@ def generate_matching_superfeatures(im1, im2, Imagenet_model=False, scale_id=6,
|
|
147 |
sf_idx_ = np.random.randint(256, size=n_sf_ids)
|
148 |
else:
|
149 |
sf_idx_ = map(int, sf_ids.strip().split(','))
|
|
|
150 |
|
151 |
if only_matching:
|
152 |
if random_mode:
|
@@ -238,7 +239,23 @@ def generate_matching_superfeatures(im1, im2, Imagenet_model=False, scale_id=6,
|
|
238 |
# # Now we can save it to a numpy array.
|
239 |
# data = np.frombuffer(fig.canvas.tostring_rgb(), dtype=np.uint8)
|
240 |
# data = data.reshape(fig.canvas.get_width_height()[::-1] + (3,))
|
241 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
|
243 |
|
244 |
# GRADIO APP
|
@@ -259,11 +276,13 @@ iface = gr.Interface(
|
|
259 |
gr.inputs.Checkbox(default=False, label="Show random (matching) SFs"),
|
260 |
gr.inputs.Textbox(lines=1, default="", label="...or show specific SF IDs:", optional=True),
|
261 |
gr.inputs.Checkbox(default=True, label="Show only matching SFs"),
|
|
|
262 |
],
|
263 |
outputs=[
|
264 |
gr.outputs.Image(type="plot", label="First Image SFs"),
|
265 |
gr.outputs.Image(type="plot", label="Second Image SFs"),
|
266 |
-
gr.outputs.
|
|
|
267 |
# outputs=gr.outputs.Image(shape=(1024,2048), type="plot"),
|
268 |
title=title,
|
269 |
theme='peach',
|
|
|
147 |
sf_idx_ = np.random.randint(256, size=n_sf_ids)
|
148 |
else:
|
149 |
sf_idx_ = map(int, sf_ids.strip().split(','))
|
150 |
+
n_sf_ids = len(sf_idx_)
|
151 |
|
152 |
if only_matching:
|
153 |
if random_mode:
|
|
|
239 |
# # Now we can save it to a numpy array.
|
240 |
# data = np.frombuffer(fig.canvas.tostring_rgb(), dtype=np.uint8)
|
241 |
# data = data.reshape(fig.canvas.get_width_height()[::-1] + (3,))
|
242 |
+
|
243 |
+
|
244 |
+
|
245 |
+
f = lambda m,c: plt.plot([],[],marker=m, color=c, ls="none")[0]
|
246 |
+
handles = [f("s", col[i]) for i in range(n_sf_ids)]
|
247 |
+
labels = sf_idx_
|
248 |
+
legend = plt.legend(handles, sf_idx_, loc=3, framealpha=1, frameon=False)
|
249 |
+
|
250 |
+
def export_legend(legend, filename="legend.png"):
|
251 |
+
fig = legend.figure
|
252 |
+
fig.canvas.draw()
|
253 |
+
# bbox = legend.get_window_extent().transformed(fig.dpi_scale_trans.inverted())
|
254 |
+
# fig.savefig(filename, dpi="figure", bbox_inches=bbox)
|
255 |
+
return fig
|
256 |
+
|
257 |
+
return fig1, fig2, export_legend(legend)
|
258 |
+
# ','.join(map(str, sf_idx_))
|
259 |
|
260 |
|
261 |
# GRADIO APP
|
|
|
276 |
gr.inputs.Checkbox(default=False, label="Show random (matching) SFs"),
|
277 |
gr.inputs.Textbox(lines=1, default="", label="...or show specific SF IDs:", optional=True),
|
278 |
gr.inputs.Checkbox(default=True, label="Show only matching SFs"),
|
279 |
+
|
280 |
],
|
281 |
outputs=[
|
282 |
gr.outputs.Image(type="plot", label="First Image SFs"),
|
283 |
gr.outputs.Image(type="plot", label="Second Image SFs"),
|
284 |
+
gr.outputs.Image(type="plot", label="SF legend")],
|
285 |
+
# gr.outputs.Textbox(label="SFs")],
|
286 |
# outputs=gr.outputs.Image(shape=(1024,2048), type="plot"),
|
287 |
title=title,
|
288 |
theme='peach',
|