Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
use kornia.io to load image and preprocess
#2
by
edgarriba
- opened
app.py
CHANGED
@@ -8,20 +8,17 @@ from kornia_moons.feature import *
|
|
8 |
import gradio as gr
|
9 |
|
10 |
def load_torch_image(fname):
|
11 |
-
img = K.
|
12 |
-
img =
|
|
|
13 |
return img
|
|
|
14 |
def inference(file1,file2):
|
15 |
fname1 = file1.name
|
16 |
-
fname2 = file2.name
|
17 |
-
im1 = cv2.imread(fname1)
|
18 |
-
im1re = cv2.resize(im1, (700, 700))
|
19 |
-
im2 = cv2.imread(fname2)
|
20 |
-
im2re = cv2.resize(im2, (700, 700))
|
21 |
img1 = load_torch_image(im1re)
|
22 |
img2 = load_torch_image(im2re)
|
23 |
|
24 |
-
|
25 |
matcher = KF.LoFTR(pretrained='outdoor')
|
26 |
|
27 |
input_dict = {"image0": K.color.rgb_to_grayscale(img1), # LofTR works on grayscale images only
|
|
|
8 |
import gradio as gr
|
9 |
|
10 |
def load_torch_image(fname):
|
11 |
+
img: Tensor = K.io.load_image(fname, K.io.ImageLoadType.RGB32)
|
12 |
+
img = img[None] # 1xCxHxW / fp32 / [0, 1]
|
13 |
+
img = K.geometry.resize(img, (700, 700))
|
14 |
return img
|
15 |
+
|
16 |
def inference(file1,file2):
|
17 |
fname1 = file1.name
|
18 |
+
fname2 = file2.name
|
|
|
|
|
|
|
|
|
19 |
img1 = load_torch_image(im1re)
|
20 |
img2 = load_torch_image(im2re)
|
21 |
|
|
|
22 |
matcher = KF.LoFTR(pretrained='outdoor')
|
23 |
|
24 |
input_dict = {"image0": K.color.rgb_to_grayscale(img1), # LofTR works on grayscale images only
|