Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
added ImageStitcher parameters
Browse files
app.py
CHANGED
@@ -1,14 +1,16 @@
|
|
1 |
import gradio as gr
|
2 |
import kornia as K
|
3 |
-
from
|
4 |
-
|
5 |
-
|
6 |
-
def enhance(file):
|
7 |
-
# load the image using the rust backend
|
8 |
-
img: Tensor = K.io.load_image(file.name, K.io.ImageLoadType.RGB32)
|
9 |
-
img = img[None] # 1xCxHxW / fp32 / [0, 1]
|
10 |
-
return K.utils.tensor_to_image(img)
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
examples = [
|
14 |
['examples/foto1B.jpg'],
|
@@ -16,17 +18,23 @@ examples = [
|
|
16 |
]
|
17 |
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
examples=examples,
|
26 |
-
# title=title,
|
27 |
-
# description=description,
|
28 |
-
# article=article,
|
29 |
-
live=True
|
30 |
)
|
31 |
-
|
32 |
-
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import kornia as K
|
3 |
+
from skimage import io
|
4 |
+
from kornia.contrib import ImageStitcher
|
5 |
+
import kornia.feature as KF
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
def enhance(file_1, file_2):
|
8 |
+
img_1 = K.image_to_tensor(io.imread(file_1), False).float() / 255.
|
9 |
+
img_2 = K.image_to_tensor(io.imread(file_2), False).float() / 255.
|
10 |
+
IS = ImageStitcher(KF.LoFTR(pretrained='outdoor'), estimator='ransac')
|
11 |
+
result = IS(img_1, img_2)
|
12 |
+
return K.tensor_to_image(result[0])
|
13 |
+
|
14 |
|
15 |
examples = [
|
16 |
['examples/foto1B.jpg'],
|
|
|
18 |
]
|
19 |
|
20 |
|
21 |
+
inputs = [
|
22 |
+
gr.inputs.Image(type='file', label='Input Image'),
|
23 |
+
gr.inputs.Image(type='file', label='Input Image'),
|
24 |
+
]
|
25 |
+
|
26 |
+
outputs = [
|
27 |
+
gr.outputs.Image(type='file', label='Output Image'),
|
28 |
+
|
29 |
+
]
|
30 |
+
|
31 |
+
title = "Image Stitching using Kornia and LoFTR"
|
32 |
+
|
33 |
+
demo_app = gr.Interface(
|
34 |
+
fn=enhance,
|
35 |
+
inputs=inputs,
|
36 |
+
outputs=outputs,
|
37 |
+
title=title,
|
38 |
examples=examples,
|
|
|
|
|
|
|
|
|
39 |
)
|
40 |
+
demo_app.launch()
|
|