ZhengPeng7 commited on
Commit
9e4d313
·
1 Parent(s): 9db9764

Update the order of model options by the superiority and popularity of them.

Browse files
Files changed (2) hide show
  1. app.py +11 -7
  2. app_local.py +11 -7
app.py CHANGED
@@ -74,12 +74,12 @@ class ImagePreprocessor():
74
  usage_to_weights_file = {
75
  'General': 'BiRefNet',
76
  'General-HR': 'BiRefNet_HR',
 
 
 
77
  'General-reso_512': 'BiRefNet-reso_512',
78
  'General-Lite': 'BiRefNet_lite',
79
  'General-Lite-2K': 'BiRefNet_lite-2K',
80
- 'Matting': 'BiRefNet-matting',
81
- 'Matting-HR': 'BiRefNet_HR-matting',
82
- 'Portrait': 'BiRefNet-portrait',
83
  'DIS': 'BiRefNet-DIS5K',
84
  'HRSOD': 'BiRefNet-HRSOD',
85
  'COD': 'BiRefNet-COD',
@@ -175,7 +175,11 @@ def predict(images, resolution, weights_file):
175
  examples = [[_] for _ in glob('examples/*')][:]
176
  # Add the option of resolution in a text box.
177
  for idx_example, example in enumerate(examples):
178
- examples[idx_example].append('1024x1024')
 
 
 
 
179
  examples.append(examples[-1].copy())
180
  examples[-1][1] = '512x512'
181
 
@@ -212,7 +216,7 @@ tab_text = gr.Interface(
212
  ],
213
  outputs=ImageSlider(label="BiRefNet's prediction", type="pil"),
214
  examples=examples_url,
215
- api_name="text",
216
  description=descriptions+'\nTab-URL is partially modified from https://huggingface.co/spaces/not-lain/background-removal, thanks to this great work!',
217
  )
218
 
@@ -230,8 +234,8 @@ tab_batch = gr.Interface(
230
 
231
  demo = gr.TabbedInterface(
232
  [tab_image, tab_text, tab_batch],
233
- ['image', 'text', 'batch'],
234
- title="BiRefNet demo for subject extraction (general / matting / salient / camouflaged / portrait).",
235
  )
236
 
237
  if __name__ == "__main__":
 
74
  usage_to_weights_file = {
75
  'General': 'BiRefNet',
76
  'General-HR': 'BiRefNet_HR',
77
+ 'Matting-HR': 'BiRefNet_HR-matting',
78
+ 'Matting': 'BiRefNet-matting',
79
+ 'Portrait': 'BiRefNet-portrait',
80
  'General-reso_512': 'BiRefNet-reso_512',
81
  'General-Lite': 'BiRefNet_lite',
82
  'General-Lite-2K': 'BiRefNet_lite-2K',
 
 
 
83
  'DIS': 'BiRefNet-DIS5K',
84
  'HRSOD': 'BiRefNet-HRSOD',
85
  'COD': 'BiRefNet-COD',
 
175
  examples = [[_] for _ in glob('examples/*')][:]
176
  # Add the option of resolution in a text box.
177
  for idx_example, example in enumerate(examples):
178
+ if 'My_' in example_resolution:
179
+ example_resolution = '2048x2048'
180
+ else:
181
+ example_resolution = '1024x1024'
182
+ examples[idx_example].append(example_resolution)
183
  examples.append(examples[-1].copy())
184
  examples[-1][1] = '512x512'
185
 
 
216
  ],
217
  outputs=ImageSlider(label="BiRefNet's prediction", type="pil"),
218
  examples=examples_url,
219
+ api_name="URL",
220
  description=descriptions+'\nTab-URL is partially modified from https://huggingface.co/spaces/not-lain/background-removal, thanks to this great work!',
221
  )
222
 
 
234
 
235
  demo = gr.TabbedInterface(
236
  [tab_image, tab_text, tab_batch],
237
+ ['image', 'URL', 'batch'],
238
+ title="BiRefNet demo for subject extraction and background removal ([CAAI AIR'24] Bilateral Reference for High-Resolution Dichotomous Image Segmentation).",
239
  )
240
 
241
  if __name__ == "__main__":
app_local.py CHANGED
@@ -74,12 +74,12 @@ class ImagePreprocessor():
74
  usage_to_weights_file = {
75
  'General': 'BiRefNet',
76
  'General-HR': 'BiRefNet_HR',
 
 
 
77
  'General-reso_512': 'BiRefNet-reso_512',
78
  'General-Lite': 'BiRefNet_lite',
79
  'General-Lite-2K': 'BiRefNet_lite-2K',
80
- 'Matting': 'BiRefNet-matting',
81
- 'Matting-HR': 'BiRefNet_HR-matting',
82
- 'Portrait': 'BiRefNet-portrait',
83
  'DIS': 'BiRefNet-DIS5K',
84
  'HRSOD': 'BiRefNet-HRSOD',
85
  'COD': 'BiRefNet-COD',
@@ -175,7 +175,11 @@ def predict(images, resolution, weights_file):
175
  examples = [[_] for _ in glob('examples/*')][:]
176
  # Add the option of resolution in a text box.
177
  for idx_example, example in enumerate(examples):
178
- examples[idx_example].append('1024x1024')
 
 
 
 
179
  examples.append(examples[-1].copy())
180
  examples[-1][1] = '512x512'
181
 
@@ -212,7 +216,7 @@ tab_text = gr.Interface(
212
  ],
213
  outputs=gr.Image(label="BiRefNet's prediction", type="pil", format='png'),
214
  examples=examples_url,
215
- api_name="text",
216
  description=descriptions+'\nTab-URL is partially modified from https://huggingface.co/spaces/not-lain/background-removal, thanks to this great work!',
217
  )
218
 
@@ -230,8 +234,8 @@ tab_batch = gr.Interface(
230
 
231
  demo = gr.TabbedInterface(
232
  [tab_image, tab_text, tab_batch],
233
- ['image', 'text', 'batch'],
234
- title="BiRefNet demo for subject extraction (general / matting / salient / camouflaged / portrait).",
235
  )
236
 
237
  if __name__ == "__main__":
 
74
  usage_to_weights_file = {
75
  'General': 'BiRefNet',
76
  'General-HR': 'BiRefNet_HR',
77
+ 'Matting-HR': 'BiRefNet_HR-matting',
78
+ 'Matting': 'BiRefNet-matting',
79
+ 'Portrait': 'BiRefNet-portrait',
80
  'General-reso_512': 'BiRefNet-reso_512',
81
  'General-Lite': 'BiRefNet_lite',
82
  'General-Lite-2K': 'BiRefNet_lite-2K',
 
 
 
83
  'DIS': 'BiRefNet-DIS5K',
84
  'HRSOD': 'BiRefNet-HRSOD',
85
  'COD': 'BiRefNet-COD',
 
175
  examples = [[_] for _ in glob('examples/*')][:]
176
  # Add the option of resolution in a text box.
177
  for idx_example, example in enumerate(examples):
178
+ if 'My_' in example_resolution:
179
+ example_resolution = '2048x2048'
180
+ else:
181
+ example_resolution = '1024x1024'
182
+ examples[idx_example].append(example_resolution)
183
  examples.append(examples[-1].copy())
184
  examples[-1][1] = '512x512'
185
 
 
216
  ],
217
  outputs=gr.Image(label="BiRefNet's prediction", type="pil", format='png'),
218
  examples=examples_url,
219
+ api_name="URL",
220
  description=descriptions+'\nTab-URL is partially modified from https://huggingface.co/spaces/not-lain/background-removal, thanks to this great work!',
221
  )
222
 
 
234
 
235
  demo = gr.TabbedInterface(
236
  [tab_image, tab_text, tab_batch],
237
+ ['image', 'URL', 'batch'],
238
+ title="BiRefNet demo for subject extraction and background removal ([CAAI AIR'24] Bilateral Reference for High-Resolution Dichotomous Image Segmentation).",
239
  )
240
 
241
  if __name__ == "__main__":