Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
update
Browse files
app.py
CHANGED
@@ -3,28 +3,31 @@ 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 |
-
|
|
|
|
|
12 |
return K.tensor_to_image(result[0])
|
13 |
|
14 |
|
15 |
examples = [
|
16 |
-
['examples/foto1B.jpg'
|
17 |
-
|
18 |
]
|
19 |
|
20 |
|
21 |
inputs = [
|
22 |
-
gr.inputs.Image(type='
|
23 |
-
gr.inputs.Image(type='
|
24 |
]
|
25 |
|
26 |
outputs = [
|
27 |
-
gr.outputs.Image(type='
|
28 |
|
29 |
]
|
30 |
|
@@ -34,9 +37,9 @@ demo_app = gr.Interface(
|
|
34 |
fn=enhance,
|
35 |
inputs=inputs,
|
36 |
outputs=outputs,
|
37 |
-
|
38 |
examples=examples,
|
39 |
live=True,
|
40 |
-
theme='
|
41 |
)
|
42 |
-
demo_app.launch()
|
|
|
3 |
from skimage import io
|
4 |
from kornia.contrib import ImageStitcher
|
5 |
import kornia.feature as KF
|
6 |
+
import torch
|
7 |
|
8 |
def enhance(file_1, file_2):
|
9 |
img_1 = K.image_to_tensor(io.imread(file_1), False).float() / 255.
|
10 |
img_2 = K.image_to_tensor(io.imread(file_2), False).float() / 255.
|
11 |
IS = ImageStitcher(KF.LoFTR(pretrained='outdoor'), estimator='ransac')
|
12 |
+
with torch.no_grad():
|
13 |
+
result = IS(img_1, img_2)
|
14 |
+
|
15 |
return K.tensor_to_image(result[0])
|
16 |
|
17 |
|
18 |
examples = [
|
19 |
+
['examples/foto1B.jpg',
|
20 |
+
'examples/foto1A.jpg'],
|
21 |
]
|
22 |
|
23 |
|
24 |
inputs = [
|
25 |
+
gr.inputs.Image(type='file', label='Input Image'),
|
26 |
+
gr.inputs.Image(type='file', label='Input Image'),
|
27 |
]
|
28 |
|
29 |
outputs = [
|
30 |
+
gr.outputs.Image(type='file', label='Output Image'),
|
31 |
|
32 |
]
|
33 |
|
|
|
37 |
fn=enhance,
|
38 |
inputs=inputs,
|
39 |
outputs=outputs,
|
40 |
+
title=title,
|
41 |
examples=examples,
|
42 |
live=True,
|
43 |
+
theme='huggingface',
|
44 |
)
|
45 |
+
demo_app.launch(debug=True)
|