kadirnar commited on
Commit
15ac7f4
1 Parent(s): eef646c
Files changed (1) hide show
  1. app.py +12 -9
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
- result = IS(img_1, img_2)
 
 
12
  return K.tensor_to_image(result[0])
13
 
14
 
15
  examples = [
16
- ['examples/foto1B.jpg'],
17
- ['examples/foto1A.jpg'],
18
  ]
19
 
20
 
21
  inputs = [
22
- gr.inputs.Image(type='filepath', label='Input Image'),
23
- gr.inputs.Image(type='filepath', label='Input Image'),
24
  ]
25
 
26
  outputs = [
27
- gr.outputs.Image(type='filepath', label='Output Image'),
28
 
29
  ]
30
 
@@ -34,9 +37,9 @@ demo_app = gr.Interface(
34
  fn=enhance,
35
  inputs=inputs,
36
  outputs=outputs,
37
- #title=title,
38
  examples=examples,
39
  live=True,
40
- theme='default',
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)