-
Notifications
You must be signed in to change notification settings - Fork 2
/
settings.py
42 lines (31 loc) · 1.31 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Format: rgb_generation_setting-rgba-rgba_cutout_name
def parse_rgb_generation_setting(rgb_generation_setting: str, setting_dict: dict):
if 'centering' not in rgb_generation_setting:
setting_dict['centering'] = 'False'
if 'no_exc' in rgb_generation_setting:
setting_dict['exclude_generic_nouns'] = 'False'
if 'suffix' in rgb_generation_setting:
setting_dict['use_suffix'] = 'True'
return setting_dict
def parse_setting(setting: str):
setting_dict = {
'centering': 'True',
'use_neg_prompt': 'True',
'exclude_generic_nouns': 'True',
'cutout_model': 'grabcut',
'use_suffix': 'False'
}
if 'rgba' in setting:
rgb_generation_setting, rgba_cutout_setting = setting.rsplit('-rgba-')
else:
rgb_generation_setting = setting
rgba_cutout_setting = None
setting_dict = parse_rgb_generation_setting(rgb_generation_setting, setting_dict)
if rgba_cutout_setting:
if 'alfie' in rgba_cutout_setting:
setting_dict['cutout_model'] = 'grabcut'
elif 'vit_matte' in rgba_cutout_setting:
setting_dict['cutout_model'] = 'vit-matte'
else:
raise ValueError(f"Invalid cutout model: {rgba_cutout_setting}. Options: ['grabcut', 'vit_matte']")
return setting_dict