XiangpengYang commited on
Commit
33f757a
·
1 Parent(s): 836b387

huggingface space

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. __pycache__/test.cpython-310.pyc +0 -0
  2. app.py +51 -76
  3. config/demo_config.yaml +6 -6
  4. input-video/00000.png +0 -0
  5. input-video/00001.png +0 -0
  6. input-video/00002.png +0 -0
  7. input-video/00003.png +0 -0
  8. input-video/00004.png +0 -0
  9. input-video/00005.png +0 -0
  10. input-video/00006.png +0 -0
  11. input-video/00007.png +0 -0
  12. input-video/00008.png +0 -0
  13. input-video/00009.png +0 -0
  14. input-video/00010.png +0 -0
  15. input-video/00011.png +0 -0
  16. input-video/00012.png +0 -0
  17. input-video/00013.png +0 -0
  18. input-video/00014.png +0 -0
  19. input-video/00015.png +0 -0
  20. layout_masks/1/00000.png +0 -0
  21. layout_masks/1/00001.png +0 -0
  22. layout_masks/1/00002.png +0 -0
  23. layout_masks/1/00003.png +0 -0
  24. layout_masks/1/00004.png +0 -0
  25. layout_masks/1/00005.png +0 -0
  26. layout_masks/1/00006.png +0 -0
  27. layout_masks/1/00007.png +0 -0
  28. layout_masks/1/00008.png +0 -0
  29. layout_masks/1/00009.png +0 -0
  30. layout_masks/1/00010.png +0 -0
  31. layout_masks/1/00011.png +0 -0
  32. layout_masks/1/00012.png +0 -0
  33. layout_masks/1/00013.png +0 -0
  34. layout_masks/1/00014.png +0 -0
  35. layout_masks/1/00015.png +0 -0
  36. layout_masks/2/00000.png +0 -0
  37. layout_masks/2/00001.png +0 -0
  38. layout_masks/2/00002.png +0 -0
  39. layout_masks/2/00003.png +0 -0
  40. layout_masks/2/00004.png +0 -0
  41. layout_masks/2/00005.png +0 -0
  42. layout_masks/2/00006.png +0 -0
  43. layout_masks/2/00007.png +0 -0
  44. layout_masks/2/00008.png +0 -0
  45. layout_masks/2/00009.png +0 -0
  46. layout_masks/2/00010.png +0 -0
  47. layout_masks/2/00011.png +0 -0
  48. layout_masks/2/00012.png +0 -0
  49. layout_masks/2/00013.png +0 -0
  50. layout_masks/2/00014.png +0 -0
__pycache__/test.cpython-310.pyc CHANGED
Binary files a/__pycache__/test.cpython-310.pyc and b/__pycache__/test.cpython-310.pyc differ
 
app.py CHANGED
@@ -11,7 +11,7 @@ from webui.merge_config_gradio import merge_config_then_run
11
  import huggingface_hub
12
  import shutil
13
  import os
14
-
15
 
16
  HF_TOKEN = os.getenv('HF_TOKEN')
17
  pipe = merge_config_then_run()
@@ -39,21 +39,10 @@ If you have any questions, please feel free to reach me out at <b>knightyxp@gmai
39
  """
40
 
41
 
 
 
 
42
 
43
- def update_layout_visibility(num):
44
- """
45
- Given the user's selection (string) in ["2","3","4","5"],
46
- return visibility updates for each of the 5 layout video inputs.
47
- """
48
- n = int(num)
49
- # Show layout_file1 if n >= 1, layout_file2 if n >= 2, etc.
50
- return [
51
- gr.update(visible=(n >= 1)),
52
- gr.update(visible=(n >= 2)),
53
- gr.update(visible=(n >= 3)),
54
- gr.update(visible=(n >= 4)),
55
- gr.update(visible=(n >= 5))
56
- ]
57
 
58
  with gr.Blocks(css='style.css') as demo:
59
  # gr.Markdown(TITLE)
@@ -138,55 +127,28 @@ with gr.Blocks(css='style.css') as demo:
138
  info="Please select the number of editing areas"
139
  )
140
 
141
- # Put all layout-video components in one Row to display them horizontally.
 
142
  with gr.Row():
143
- layout_file1 = gr.Video(
144
- label="Layout Video 1",
145
- type="numpy",
146
- format="mp4",
147
- visible=True
148
- )
149
- layout_file2 = gr.Video(
150
- label="Layout Video 2",
151
- type="numpy",
152
- format="mp4",
153
- visible=True
154
- )
155
- layout_file3 = gr.Video(
156
- label="Layout Video 3",
157
- type="numpy",
158
- format="mp4",
159
- visible=False
160
- )
161
- layout_file4 = gr.Video(
162
- label="Layout Video 4",
163
- type="numpy",
164
- format="mp4",
165
- visible=False
166
- )
167
- layout_file5 = gr.Video(
168
- label="Layout Video 5",
169
- type="numpy",
170
- format="mp4",
171
- visible=False
172
- )
173
 
174
- # Toggle visibility of the layout videos based on user selection
175
  num_layouts.change(
176
  fn=update_layout_visibility,
177
  inputs=num_layouts,
178
- outputs=[
179
- layout_file1,
180
- layout_file2,
181
- layout_file3,
182
- layout_file4,
183
- layout_file5
184
- ]
185
  )
186
 
187
  prompt = gr.Textbox(label='Prompt',
188
  info='Change the prompt, and extract each local prompt in the editing prompts.\
189
- the local prompt order should be same as layout masks order.)',
190
  )
191
 
192
  model_id = gr.Dropdown(
@@ -198,11 +160,25 @@ with gr.Blocks(css='style.css') as demo:
198
  value='stable-diffusion-v1-5/stable-diffusion-v1-5')
199
 
200
 
201
- run_button = gr.Button('Generate')
202
-
203
  with gr.Column():
204
  result = gr.Video(label='Result')
205
  # result.style(height=512, width=512)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  with gr.Row():
207
  control_list = ['dwpose', 'depth_zoe', 'depth_midas']
208
  control_type = gr.Dropdown(
@@ -252,7 +228,9 @@ with gr.Blocks(css='style.css') as demo:
252
  value=["1"],
253
  info="Select one or more flatten resolution factors. Mapping: 1 -> 64, 2 -> 32 (64/2), 4 -> 16 (64/4), 8 -> 8 (64/8)."
254
  )
255
-
 
 
256
 
257
  with gr.Row():
258
  from example import style_example
@@ -278,25 +256,22 @@ with gr.Blocks(css='style.css') as demo:
278
  # # cache_examples=os.getenv('SYSTEM') == 'spaces'
279
  # )
280
  gr.Markdown(ARTICLE)
281
- inputs = [
282
- model_id,
283
- user_input_video,
284
- num_layouts,
285
- layout_file1,
286
- layout_file2,
287
- layout_file3,
288
- layout_file4,
289
- layout_file5,
290
- prompt,
291
- model_id,
292
- control_type,
293
- dwpose_options,
294
- controlnet_conditioning_scale,
295
- use_pnp,
296
- pnp_inject_steps,
297
- flatten_res,
298
  ]
299
  prompt.submit(fn=pipe.run, inputs=inputs, outputs=result)
300
  run_button.click(fn=pipe.run, inputs=inputs, outputs=result)
301
-
 
302
  demo.queue().launch()
 
11
  import huggingface_hub
12
  import shutil
13
  import os
14
+ import torch
15
 
16
  HF_TOKEN = os.getenv('HF_TOKEN')
17
  pipe = merge_config_then_run()
 
39
  """
40
 
41
 
42
+ def update_layout_visibility(selected_num):
43
+ num = int(selected_num)
44
+ return [gr.update(visible=(i < num)) for i in range(len(layout_files))]
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
  with gr.Blocks(css='style.css') as demo:
48
  # gr.Markdown(TITLE)
 
127
  info="Please select the number of editing areas"
128
  )
129
 
130
+ # 使用循环生成所有的布局视频组件,并存到列表 layout_files
131
+ layout_files = []
132
  with gr.Row():
133
+ for i in range(5):
134
+ video = gr.Video(
135
+ label=f"Layout Video {i+1}",
136
+ type="numpy",
137
+ format="mp4",
138
+ visible=(i < 2) # 默认显示前两个
139
+ )
140
+ layout_files.append(video)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
 
142
+ # num_layouts 改变时,通过回调函数更新 layout_files 列表中各视频组件的 visible 属性
143
  num_layouts.change(
144
  fn=update_layout_visibility,
145
  inputs=num_layouts,
146
+ outputs=layout_files
 
 
 
 
 
 
147
  )
148
 
149
  prompt = gr.Textbox(label='Prompt',
150
  info='Change the prompt, and extract each local prompt in the editing prompts.\
151
+ (the local prompt order should be same as layout masks order.)',
152
  )
153
 
154
  model_id = gr.Dropdown(
 
160
  value='stable-diffusion-v1-5/stable-diffusion-v1-5')
161
 
162
 
 
 
163
  with gr.Column():
164
  result = gr.Video(label='Result')
165
  # result.style(height=512, width=512)
166
+ with gr.Accordion('Temporal Crop offset and Sampling Stride', open=False):
167
+ n_sample_frame = gr.Slider(label='Number of Frames',
168
+ minimum=0,
169
+ maximum=32,
170
+ step=1,
171
+ value=16)
172
+ sampling_rate = gr.Slider(label='sampling_rate',
173
+ minimum=0,
174
+ maximum=20,
175
+ step=1,
176
+ value=1)
177
+ start_sample_frame = gr.Number(label='Start frame in the video',
178
+ value=0,
179
+ precision=0)
180
+
181
+
182
  with gr.Row():
183
  control_list = ['dwpose', 'depth_zoe', 'depth_midas']
184
  control_type = gr.Dropdown(
 
228
  value=["1"],
229
  info="Select one or more flatten resolution factors. Mapping: 1 -> 64, 2 -> 32 (64/2), 4 -> 16 (64/4), 8 -> 8 (64/8)."
230
  )
231
+
232
+
233
+ run_button = gr.Button('Generate')
234
 
235
  with gr.Row():
236
  from example import style_example
 
256
  # # cache_examples=os.getenv('SYSTEM') == 'spaces'
257
  # )
258
  gr.Markdown(ARTICLE)
259
+ inputs = [user_input_video, num_layouts,
260
+ *layout_files,
261
+ prompt,
262
+ model_id,
263
+ n_sample_frame,
264
+ start_sample_frame,
265
+ sampling_rate,
266
+ control_type,
267
+ dwpose_options,
268
+ controlnet_conditioning_scale,
269
+ use_pnp,
270
+ pnp_inject_steps,
271
+ flatten_res,
 
 
 
 
272
  ]
273
  prompt.submit(fn=pipe.run, inputs=inputs, outputs=result)
274
  run_button.click(fn=pipe.run, inputs=inputs, outputs=result)
275
+ if device == 'cuda':
276
+ torch.cuda.empty_cache()
277
  demo.queue().launch()
config/demo_config.yaml CHANGED
@@ -2,13 +2,13 @@ pretrained_model_path: "/home/xianyang/Data/code/FateZero/ckpt/stable-diffusion-
2
  logdir: ./result/run_two_man/instance_level/3cls_spider_polar_vis_cross_attn
3
 
4
  dataset_config:
5
- path: "data/run_two_man/run_two_man_fr2"
6
- prompt: 'Man in red hoddie and man in gray shirt are jogging in forest'
7
  n_sample_frame: 16
8
  start_sample_frame: 0
9
- sampling_rate: 2
10
- layout_mask_dir: "./data/run_two_man/layout_masks_fr2"
11
- layout_mask_order: ['left_man_plus','right_man_plus','trees','trunk']
12
  negative_promot: "ugly, blurry, low res, unrealistic, unaesthetic"
13
 
14
  control_config:
@@ -34,7 +34,7 @@ editing_config:
34
  sample_seeds: [0]
35
  num_inference_steps: 50
36
  blending_percentage: 0
37
- vis_cross_attn: True
38
  #cluster_inversion_feature: True
39
 
40
 
 
2
  logdir: ./result/run_two_man/instance_level/3cls_spider_polar_vis_cross_attn
3
 
4
  dataset_config:
5
+ path: ""
6
+ prompt: ""
7
  n_sample_frame: 16
8
  start_sample_frame: 0
9
+ sampling_rate: 1
10
+ layout_mask_dir: ""
11
+ layout_mask_order: []
12
  negative_promot: "ugly, blurry, low res, unrealistic, unaesthetic"
13
 
14
  control_config:
 
34
  sample_seeds: [0]
35
  num_inference_steps: 50
36
  blending_percentage: 0
37
+ vis_cross_attn: False
38
  #cluster_inversion_feature: True
39
 
40
 
input-video/00000.png ADDED
input-video/00001.png ADDED
input-video/00002.png ADDED
input-video/00003.png ADDED
input-video/00004.png ADDED
input-video/00005.png ADDED
input-video/00006.png ADDED
input-video/00007.png ADDED
input-video/00008.png ADDED
input-video/00009.png ADDED
input-video/00010.png ADDED
input-video/00011.png ADDED
input-video/00012.png ADDED
input-video/00013.png ADDED
input-video/00014.png ADDED
input-video/00015.png ADDED
layout_masks/1/00000.png ADDED
layout_masks/1/00001.png ADDED
layout_masks/1/00002.png ADDED
layout_masks/1/00003.png ADDED
layout_masks/1/00004.png ADDED
layout_masks/1/00005.png ADDED
layout_masks/1/00006.png ADDED
layout_masks/1/00007.png ADDED
layout_masks/1/00008.png ADDED
layout_masks/1/00009.png ADDED
layout_masks/1/00010.png ADDED
layout_masks/1/00011.png ADDED
layout_masks/1/00012.png ADDED
layout_masks/1/00013.png ADDED
layout_masks/1/00014.png ADDED
layout_masks/1/00015.png ADDED
layout_masks/2/00000.png ADDED
layout_masks/2/00001.png ADDED
layout_masks/2/00002.png ADDED
layout_masks/2/00003.png ADDED
layout_masks/2/00004.png ADDED
layout_masks/2/00005.png ADDED
layout_masks/2/00006.png ADDED
layout_masks/2/00007.png ADDED
layout_masks/2/00008.png ADDED
layout_masks/2/00009.png ADDED
layout_masks/2/00010.png ADDED
layout_masks/2/00011.png ADDED
layout_masks/2/00012.png ADDED
layout_masks/2/00013.png ADDED
layout_masks/2/00014.png ADDED