Spaces:
Build error
Build error
temp
Browse files
app.py
CHANGED
|
@@ -15,6 +15,7 @@ import fire_network
|
|
| 15 |
import numpy as np
|
| 16 |
|
| 17 |
from PIL import Image
|
|
|
|
| 18 |
|
| 19 |
# Possible Scales for multiscale inference
|
| 20 |
scales = [2.0, 1.414, 1.0, 0.707, 0.5, 0.353, 0.25]
|
|
@@ -37,10 +38,11 @@ transform = transforms.Compose([
|
|
| 37 |
# which sf
|
| 38 |
sf_idx_ = [55, 14, 5, 4, 52, 57, 40, 9]
|
| 39 |
|
| 40 |
-
|
| 41 |
col = plt.get_cmap('tab10')
|
| 42 |
|
| 43 |
def generate_matching_superfeatures(im1, im2, scale_id=6, threshold=50):
|
|
|
|
|
|
|
| 44 |
|
| 45 |
im1_tensor = transform(im1).unsqueeze(0)
|
| 46 |
im2_tensor = transform(im2).unsqueeze(0)
|
|
@@ -82,11 +84,13 @@ def generate_matching_superfeatures(im1, im2, scale_id=6, threshold=50):
|
|
| 82 |
|
| 83 |
fin_img = []
|
| 84 |
img1rsz = np.copy(im1)
|
|
|
|
| 85 |
for j, att in enumerate(all_att_bin1):
|
| 86 |
# att = cv2.resize(att, imgz[i].shape[:2][::-1], interpolation=cv2.INTER_NEAREST)
|
| 87 |
# att = cv2.resize(att, imgz[i].shape[:2][::-1], interpolation=cv2.INTER_CUBIC)
|
| 88 |
# att = cv2.resize(att, imgz[i].shape[:2][::-1])
|
| 89 |
-
att = att.resize(
|
|
|
|
| 90 |
mask2d = zip(*np.where(att==255))
|
| 91 |
for m,n in mask2d:
|
| 92 |
col_ = col.colors[j] if j < 7 else col.colors[j+1]
|
|
@@ -96,7 +100,6 @@ def generate_matching_superfeatures(im1, im2, scale_id=6, threshold=50):
|
|
| 96 |
fin_img.append(img1rsz)
|
| 97 |
|
| 98 |
img2rsz = np.copy(im2)
|
| 99 |
-
print(img2rsz.size)
|
| 100 |
for j, att in enumerate(all_att_bin2):
|
| 101 |
# att = cv2.resize(att, imgz[i].shape[:2][::-1], interpolation=cv2.INTER_NEAREST)
|
| 102 |
# att = cv2.resize(att, imgz[i].shape[:2][::-1], interpolation=cv2.INTER_CUBIC)
|
|
|
|
| 15 |
import numpy as np
|
| 16 |
|
| 17 |
from PIL import Image
|
| 18 |
+
from skimage.transform import resize
|
| 19 |
|
| 20 |
# Possible Scales for multiscale inference
|
| 21 |
scales = [2.0, 1.414, 1.0, 0.707, 0.5, 0.353, 0.25]
|
|
|
|
| 38 |
# which sf
|
| 39 |
sf_idx_ = [55, 14, 5, 4, 52, 57, 40, 9]
|
| 40 |
|
|
|
|
| 41 |
col = plt.get_cmap('tab10')
|
| 42 |
|
| 43 |
def generate_matching_superfeatures(im1, im2, scale_id=6, threshold=50):
|
| 44 |
+
print(im1.size)
|
| 45 |
+
return
|
| 46 |
|
| 47 |
im1_tensor = transform(im1).unsqueeze(0)
|
| 48 |
im2_tensor = transform(im2).unsqueeze(0)
|
|
|
|
| 84 |
|
| 85 |
fin_img = []
|
| 86 |
img1rsz = np.copy(im1)
|
| 87 |
+
print(img1rsz.size)
|
| 88 |
for j, att in enumerate(all_att_bin1):
|
| 89 |
# att = cv2.resize(att, imgz[i].shape[:2][::-1], interpolation=cv2.INTER_NEAREST)
|
| 90 |
# att = cv2.resize(att, imgz[i].shape[:2][::-1], interpolation=cv2.INTER_CUBIC)
|
| 91 |
# att = cv2.resize(att, imgz[i].shape[:2][::-1])
|
| 92 |
+
att = att.resize(shape)
|
| 93 |
+
# att = resize(att, im1.size)
|
| 94 |
mask2d = zip(*np.where(att==255))
|
| 95 |
for m,n in mask2d:
|
| 96 |
col_ = col.colors[j] if j < 7 else col.colors[j+1]
|
|
|
|
| 100 |
fin_img.append(img1rsz)
|
| 101 |
|
| 102 |
img2rsz = np.copy(im2)
|
|
|
|
| 103 |
for j, att in enumerate(all_att_bin2):
|
| 104 |
# att = cv2.resize(att, imgz[i].shape[:2][::-1], interpolation=cv2.INTER_NEAREST)
|
| 105 |
# att = cv2.resize(att, imgz[i].shape[:2][::-1], interpolation=cv2.INTER_CUBIC)
|