RamAnanth1 commited on
Commit
ded8e10
1 Parent(s): e5e86e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -95
app.py CHANGED
@@ -30,29 +30,16 @@ for name in names:
30
  continue
31
  subprocess.run(shlex.split(command), cwd='ControlNet/annotator/ckpts/')
32
 
33
- from app_canny import create_demo as create_demo_canny
34
  from app_depth import create_demo as create_demo_depth
35
- from app_fake_scribble import create_demo as create_demo_fake_scribble
36
- from app_hed import create_demo as create_demo_hed
37
- from app_hough import create_demo as create_demo_hough
38
- from app_normal import create_demo as create_demo_normal
39
- from app_pose import create_demo as create_demo_pose
40
- from app_scribble import create_demo as create_demo_scribble
41
- from app_scribble_interactive import \
42
- create_demo as create_demo_scribble_interactive
43
- from app_seg import create_demo as create_demo_seg
44
  from model import Model, download_all_controlnet_weights
45
 
46
  DESCRIPTION = '# [ControlNet](https://github.com/lllyasviel/ControlNet)'
47
 
48
  SPACE_ID = os.getenv('SPACE_ID')
49
- ALLOW_CHANGING_BASE_MODEL = SPACE_ID != 'hysts/ControlNet'
50
-
51
- if SPACE_ID is not None:
52
- DESCRIPTION += f'<p>For faster inference without waiting in queue, you may duplicate the space and upgrade to GPU in settings. <a href="https://huggingface.co/spaces/{SPACE_ID}?duplicate=true"><img style="display: inline; margin-top: 0em; margin-bottom: 0em" src="https://bit.ly/3gLdBN6" alt="Duplicate Space" /></a></p>'
53
 
54
- MAX_IMAGES = int(os.getenv('MAX_IMAGES', '3'))
55
- DEFAULT_NUM_IMAGES = min(MAX_IMAGES, int(os.getenv('DEFAULT_NUM_IMAGES', '1')))
56
 
57
  if os.getenv('SYSTEM') == 'spaces':
58
  download_all_controlnet_weights()
@@ -64,87 +51,11 @@ model = Model(base_model_id=DEFAULT_MODEL_ID, task_name='canny')
64
  with gr.Blocks(css='style.css') as demo:
65
  gr.Markdown(DESCRIPTION)
66
  with gr.Tabs():
67
- with gr.TabItem('Canny'):
68
- create_demo_canny(model.process_canny,
69
- max_images=MAX_IMAGES,
70
- default_num_images=DEFAULT_NUM_IMAGES)
71
- with gr.TabItem('Hough'):
72
- create_demo_hough(model.process_hough,
73
- max_images=MAX_IMAGES,
74
- default_num_images=DEFAULT_NUM_IMAGES)
75
- with gr.TabItem('HED'):
76
- create_demo_hed(model.process_hed,
77
- max_images=MAX_IMAGES,
78
- default_num_images=DEFAULT_NUM_IMAGES)
79
- with gr.TabItem('Scribble'):
80
- create_demo_scribble(model.process_scribble,
81
- max_images=MAX_IMAGES,
82
- default_num_images=DEFAULT_NUM_IMAGES)
83
- with gr.TabItem('Scribble Interactive'):
84
- create_demo_scribble_interactive(
85
- model.process_scribble_interactive,
86
- max_images=MAX_IMAGES,
87
- default_num_images=DEFAULT_NUM_IMAGES)
88
- with gr.TabItem('Fake Scribble'):
89
- create_demo_fake_scribble(model.process_fake_scribble,
90
- max_images=MAX_IMAGES,
91
- default_num_images=DEFAULT_NUM_IMAGES)
92
- with gr.TabItem('Pose'):
93
- create_demo_pose(model.process_pose,
94
- max_images=MAX_IMAGES,
95
- default_num_images=DEFAULT_NUM_IMAGES)
96
- with gr.TabItem('Segmentation'):
97
- create_demo_seg(model.process_seg,
98
- max_images=MAX_IMAGES,
99
- default_num_images=DEFAULT_NUM_IMAGES)
100
  with gr.TabItem('Depth'):
101
  create_demo_depth(model.process_depth,
102
  max_images=MAX_IMAGES,
103
  default_num_images=DEFAULT_NUM_IMAGES)
104
- with gr.TabItem('Normal map'):
105
- create_demo_normal(model.process_normal,
106
- max_images=MAX_IMAGES,
107
- default_num_images=DEFAULT_NUM_IMAGES)
108
-
109
- with gr.Accordion(label='Base model', open=False):
110
- with gr.Row():
111
- with gr.Column():
112
- current_base_model = gr.Text(label='Current base model')
113
- with gr.Column(scale=0.3):
114
- check_base_model_button = gr.Button('Check current base model')
115
- with gr.Row():
116
- with gr.Column():
117
- new_base_model_id = gr.Text(
118
- label='New base model',
119
- max_lines=1,
120
- placeholder='runwayml/stable-diffusion-v1-5',
121
- info=
122
- 'The base model must be compatible with Stable Diffusion v1.5.',
123
- interactive=ALLOW_CHANGING_BASE_MODEL)
124
- with gr.Column(scale=0.3):
125
- change_base_model_button = gr.Button(
126
- 'Change base model', interactive=ALLOW_CHANGING_BASE_MODEL)
127
- if not ALLOW_CHANGING_BASE_MODEL:
128
- gr.Markdown(
129
- '''The base model is not allowed to be changed in this Space so as not to slow down the demo, but it can be changed if you duplicate the Space. <a href="https://huggingface.co/spaces/{SPACE_ID}?duplicate=true"><img style="display: inline; margin-top: 0em; margin-bottom: 0em" src="https://bit.ly/3gLdBN6" alt="Duplicate Space" /></a>'''
130
- )
131
-
132
- gr.Markdown('''### Related Spaces
133
-
134
- - [Space using Anything-v4.0 as base model](https://huggingface.co/spaces/hysts/ControlNet-with-Anything-v4)
135
- - https://huggingface.co/spaces/jonigata/PoseMaker2
136
- - https://huggingface.co/spaces/diffusers/controlnet-openpose
137
- - https://huggingface.co/spaces/diffusers/controlnet-canny
138
- ''')
139
-
140
- check_base_model_button.click(fn=lambda: model.base_model_id,
141
- outputs=current_base_model,
142
- queue=False)
143
- new_base_model_id.submit(fn=model.set_base_model,
144
- inputs=new_base_model_id,
145
- outputs=current_base_model)
146
- change_base_model_button.click(fn=model.set_base_model,
147
- inputs=new_base_model_id,
148
- outputs=current_base_model)
149
-
150
  demo.queue(api_open=False).launch(file_directories=['/tmp'])
 
30
  continue
31
  subprocess.run(shlex.split(command), cwd='ControlNet/annotator/ckpts/')
32
 
33
+
34
  from app_depth import create_demo as create_demo_depth
 
 
 
 
 
 
 
 
 
35
  from model import Model, download_all_controlnet_weights
36
 
37
  DESCRIPTION = '# [ControlNet](https://github.com/lllyasviel/ControlNet)'
38
 
39
  SPACE_ID = os.getenv('SPACE_ID')
 
 
 
 
40
 
41
+ MAX_IMAGES = 3
42
+ DEFAULT_NUM_IMAGES = min(MAX_IMAGES,1)
43
 
44
  if os.getenv('SYSTEM') == 'spaces':
45
  download_all_controlnet_weights()
 
51
  with gr.Blocks(css='style.css') as demo:
52
  gr.Markdown(DESCRIPTION)
53
  with gr.Tabs():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  with gr.TabItem('Depth'):
55
  create_demo_depth(model.process_depth,
56
  max_images=MAX_IMAGES,
57
  default_num_images=DEFAULT_NUM_IMAGES)
58
+
59
+
60
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  demo.queue(api_open=False).launch(file_directories=['/tmp'])