Spaces:
Build error
Build error
temp
Browse files
app.py
CHANGED
@@ -74,6 +74,7 @@ def generate_matching_superfeatures(im1, im2, scale_id=6, threshold=50):
|
|
74 |
att_heat = np.array(attns1[0,i,:,:].numpy(), dtype=np.float32)
|
75 |
att_heat = np.uint8(att_heat / np.max(att_heat[:]) * 255.0)
|
76 |
att_heat_bin = np.where(att_heat>threshold, 255, 0)
|
|
|
77 |
all_att_bin1.append(att_heat_bin)
|
78 |
|
79 |
att_heat = np.array(attns2[0,i,:,:].numpy(), dtype=np.float32)
|
@@ -84,7 +85,8 @@ def generate_matching_superfeatures(im1, im2, scale_id=6, threshold=50):
|
|
84 |
|
85 |
fin_img = []
|
86 |
img1rsz = np.copy(im1_cv)
|
87 |
-
print(
|
|
|
88 |
for j, att in enumerate(all_att_bin1):
|
89 |
att = cv2.resize(att, im1.size, interpolation=cv2.INTER_NEAREST)
|
90 |
# att = cv2.resize(att, imgz[i].shape[:2][::-1], interpolation=cv2.INTER_CUBIC)
|
@@ -99,7 +101,7 @@ def generate_matching_superfeatures(im1, im2, scale_id=6, threshold=50):
|
|
99 |
img1rsz[m,n, :] = col_[::-1]
|
100 |
fin_img.append(img1rsz)
|
101 |
|
102 |
-
img2rsz = np.copy(
|
103 |
for j, att in enumerate(all_att_bin2):
|
104 |
att = cv2.resize(att, im2.size, interpolation=cv2.INTER_NEAREST)
|
105 |
# att = cv2.resize(att, imgz[i].shape[:2][::-1], interpolation=cv2.INTER_CUBIC)
|
@@ -124,10 +126,10 @@ def generate_matching_superfeatures(im1, im2, scale_id=6, threshold=50):
|
|
124 |
plt.tight_layout()
|
125 |
# fig.suptitle("Matching SFs", fontsize=16)
|
126 |
|
127 |
-
fig.canvas.draw()
|
128 |
-
# Now we can save it to a numpy array.
|
129 |
-
data = np.frombuffer(fig.canvas.tostring_rgb(), dtype=np.uint8)
|
130 |
-
data = data.reshape(fig.canvas.get_width_height()[::-1] + (3,))
|
131 |
return fig
|
132 |
|
133 |
|
@@ -137,6 +139,13 @@ description = "TBD"
|
|
137 |
article = "<p style='text-align: center'><a href='https://github.com/naver/fire' target='_blank'>Original Github Repo</a></p>"
|
138 |
|
139 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
iface = gr.Interface(
|
141 |
fn=generate_matching_superfeatures,
|
142 |
inputs=[
|
@@ -150,6 +159,7 @@ iface = gr.Interface(
|
|
150 |
title=title,
|
151 |
description=description,
|
152 |
article=article,
|
|
|
153 |
examples=[["chateau_1.png", "chateau_2.png", 6, 50]],
|
154 |
)
|
155 |
iface.launch()
|
|
|
74 |
att_heat = np.array(attns1[0,i,:,:].numpy(), dtype=np.float32)
|
75 |
att_heat = np.uint8(att_heat / np.max(att_heat[:]) * 255.0)
|
76 |
att_heat_bin = np.where(att_heat>threshold, 255, 0)
|
77 |
+
print(att_heat_bin)
|
78 |
all_att_bin1.append(att_heat_bin)
|
79 |
|
80 |
att_heat = np.array(attns2[0,i,:,:].numpy(), dtype=np.float32)
|
|
|
85 |
|
86 |
fin_img = []
|
87 |
img1rsz = np.copy(im1_cv)
|
88 |
+
print(im1.size)
|
89 |
+
print(img1rsz.shape)
|
90 |
for j, att in enumerate(all_att_bin1):
|
91 |
att = cv2.resize(att, im1.size, interpolation=cv2.INTER_NEAREST)
|
92 |
# att = cv2.resize(att, imgz[i].shape[:2][::-1], interpolation=cv2.INTER_CUBIC)
|
|
|
101 |
img1rsz[m,n, :] = col_[::-1]
|
102 |
fin_img.append(img1rsz)
|
103 |
|
104 |
+
img2rsz = np.copy(im2_cv)
|
105 |
for j, att in enumerate(all_att_bin2):
|
106 |
att = cv2.resize(att, im2.size, interpolation=cv2.INTER_NEAREST)
|
107 |
# att = cv2.resize(att, imgz[i].shape[:2][::-1], interpolation=cv2.INTER_CUBIC)
|
|
|
126 |
plt.tight_layout()
|
127 |
# fig.suptitle("Matching SFs", fontsize=16)
|
128 |
|
129 |
+
# fig.canvas.draw()
|
130 |
+
# # Now we can save it to a numpy array.
|
131 |
+
# data = np.frombuffer(fig.canvas.tostring_rgb(), dtype=np.uint8)
|
132 |
+
# data = data.reshape(fig.canvas.get_width_height()[::-1] + (3,))
|
133 |
return fig
|
134 |
|
135 |
|
|
|
139 |
article = "<p style='text-align: center'><a href='https://github.com/naver/fire' target='_blank'>Original Github Repo</a></p>"
|
140 |
|
141 |
|
142 |
+
# css = ".output-image, .input-image {height: 40rem !important; width: 100% !important;}"
|
143 |
+
# css = "@media screen and (max-width: 600px) { .output_image, .input_image {height:20rem !important; width: 100% !important;} }"
|
144 |
+
# css = ".output_image, .input_image {height: 600px !important}"
|
145 |
+
css = ".input_image {height: 600px !important} .output_image, {height: 1200px !important}"
|
146 |
+
# css = ".output-image, .input-image {height: 40rem !important; width: 100% !important;}"
|
147 |
+
|
148 |
+
|
149 |
iface = gr.Interface(
|
150 |
fn=generate_matching_superfeatures,
|
151 |
inputs=[
|
|
|
159 |
title=title,
|
160 |
description=description,
|
161 |
article=article,
|
162 |
+
css=css,
|
163 |
examples=[["chateau_1.png", "chateau_2.png", 6, 50]],
|
164 |
)
|
165 |
iface.launch()
|