Realcat commited on
Commit
1e360c3
โ€ข
1 Parent(s): 7ee27ee

update: gradio version to 3.41.2

Browse files
Files changed (4) hide show
  1. app.py +20 -6
  2. common/utils.py +1 -2
  3. env-docker.txt +2 -2
  4. pre-requirements.txt +2 -2
app.py CHANGED
@@ -7,6 +7,7 @@ from common.utils import (
7
  change_estimate_geom,
8
  run_matching,
9
  gen_examples,
 
10
  DEFAULT_RANSAC_METHOD,
11
  DEFAULT_SETTING_GEOMETRY,
12
  DEFAULT_RANSAC_REPROJ_THRESHOLD,
@@ -20,7 +21,7 @@ from common.utils import (
20
  DESCRIPTION = """
21
  # Image Matching WebUI
22
  This Space demonstrates [Image Matching WebUI](https://github.com/Vincentqyw/image-matching-webui) by vincent qin. Feel free to play with it, or duplicate to run image matching without a queue!
23
- <br/><br/>
24
  ๐Ÿ”Ž For more details about supported local features and matchers, please refer to https://github.com/Vincentqyw/image-matching-webui
25
 
26
  ๐Ÿš€ All algorithms run on CPU for inference, causing slow speeds and high latency. For faster inference, please download the [source code](https://github.com/Vincentqyw/image-matching-webui) for local deployment.
@@ -39,11 +40,20 @@ def ui_change_imagebox(choice):
39
  Returns:
40
  dict: A dictionary containing the updated value, sources, and type for the image box.
41
  """
42
- return {
43
  "value": None, # The updated value of the image box
44
- "source": choice, # The list of image sources to be displayed
45
  "__type__": "update", # The type of update for the image box
46
  }
 
 
 
 
 
 
 
 
 
 
47
 
48
 
49
  def ui_reset_state(*args):
@@ -113,7 +123,11 @@ def run(server_name="0.0.0.0", server_port=7860):
113
  interactive=True,
114
  )
115
  match_image_src = gr.Radio(
116
- ["upload", "webcam", "canvas"],
 
 
 
 
117
  label="Image Source",
118
  value="upload",
119
  )
@@ -122,14 +136,14 @@ def run(server_name="0.0.0.0", server_port=7860):
122
  label="Image 0",
123
  type="numpy",
124
  image_mode="RGB",
125
- height=300,
126
  interactive=True,
127
  )
128
  input_image1 = gr.Image(
129
  label="Image 1",
130
  type="numpy",
131
  image_mode="RGB",
132
- height=300,
133
  interactive=True,
134
  )
135
 
 
7
  change_estimate_geom,
8
  run_matching,
9
  gen_examples,
10
+ GRADIO_VERSION,
11
  DEFAULT_RANSAC_METHOD,
12
  DEFAULT_SETTING_GEOMETRY,
13
  DEFAULT_RANSAC_REPROJ_THRESHOLD,
 
21
  DESCRIPTION = """
22
  # Image Matching WebUI
23
  This Space demonstrates [Image Matching WebUI](https://github.com/Vincentqyw/image-matching-webui) by vincent qin. Feel free to play with it, or duplicate to run image matching without a queue!
24
+ <br/>
25
  ๐Ÿ”Ž For more details about supported local features and matchers, please refer to https://github.com/Vincentqyw/image-matching-webui
26
 
27
  ๐Ÿš€ All algorithms run on CPU for inference, causing slow speeds and high latency. For faster inference, please download the [source code](https://github.com/Vincentqyw/image-matching-webui) for local deployment.
 
40
  Returns:
41
  dict: A dictionary containing the updated value, sources, and type for the image box.
42
  """
43
+ ret_dict = {
44
  "value": None, # The updated value of the image box
 
45
  "__type__": "update", # The type of update for the image box
46
  }
47
+ if GRADIO_VERSION > "3":
48
+ return {
49
+ **ret_dict,
50
+ "sources": choice, # The list of image sources to be displayed
51
+ }
52
+ else:
53
+ return {
54
+ **ret_dict,
55
+ "source": choice, # The list of image sources to be displayed
56
+ }
57
 
58
 
59
  def ui_reset_state(*args):
 
123
  interactive=True,
124
  )
125
  match_image_src = gr.Radio(
126
+ (
127
+ ["upload", "webcam", "clipboard"]
128
+ if GRADIO_VERSION > "3"
129
+ else ["upload", "webcam", "canvas"]
130
+ ),
131
  label="Image Source",
132
  value="upload",
133
  )
 
136
  label="Image 0",
137
  type="numpy",
138
  image_mode="RGB",
139
+ height=300 if GRADIO_VERSION > "3" else None,
140
  interactive=True,
141
  )
142
  input_image1 = gr.Image(
143
  label="Image 1",
144
  type="numpy",
145
  image_mode="RGB",
146
+ height=300 if GRADIO_VERSION > "3" else None,
147
  interactive=True,
148
  )
149
 
common/utils.py CHANGED
@@ -25,7 +25,7 @@ DEFAULT_RANSAC_MAX_ITER = 10000
25
  DEFAULT_MIN_NUM_MATCHES = 4
26
  DEFAULT_MATCHING_THRESHOLD = 0.2
27
  DEFAULT_SETTING_GEOMETRY = "Homography"
28
-
29
 
30
  def get_model(match_conf):
31
  Model = dynamic_load(matchers, match_conf["model"]["name"])
@@ -38,7 +38,6 @@ def get_feature_model(conf):
38
  model = Model(conf["model"]).eval().to(device)
39
  return model
40
 
41
-
42
  def gen_examples():
43
  random.seed(1)
44
  example_matchers = [
 
25
  DEFAULT_MIN_NUM_MATCHES = 4
26
  DEFAULT_MATCHING_THRESHOLD = 0.2
27
  DEFAULT_SETTING_GEOMETRY = "Homography"
28
+ GRADIO_VERSION = gr.__version__.split('.')[0]
29
 
30
  def get_model(match_conf):
31
  Model = dynamic_load(matchers, match_conf["model"]["name"])
 
38
  model = Model(conf["model"]).eval().to(device)
39
  return model
40
 
 
41
  def gen_examples():
42
  random.seed(1)
43
  example_matchers = [
env-docker.txt CHANGED
@@ -1,8 +1,8 @@
1
  e2cnn==0.2.3
2
  einops==0.6.1
3
  gdown==4.7.1
4
- gradio==4.25.0
5
- gradio_client==0.15.0
6
  h5py==3.9.0
7
  imageio==2.31.1
8
  Jinja2==3.1.2
 
1
  e2cnn==0.2.3
2
  einops==0.6.1
3
  gdown==4.7.1
4
+ gradio==3.41.2
5
+ gradio_client==0.5.0
6
  h5py==3.9.0
7
  imageio==2.31.1
8
  Jinja2==3.1.2
pre-requirements.txt CHANGED
@@ -6,5 +6,5 @@ pytorch-lightning>=1.4.2
6
  omegaconf>=2.1.1
7
  einops>=0.3.0
8
  kornia>=0.6
9
- gradio==3.50.2
10
- gradio_client==0.6.1
 
6
  omegaconf>=2.1.1
7
  einops>=0.3.0
8
  kornia>=0.6
9
+ gradio==3.41.2
10
+ gradio_client==0.5.0