Carlexxx commited on
Commit
4ae44b4
Β·
1 Parent(s): d20b2f1

feat: Implement self-contained specialist managers

Browse files
This view is limited to 50 files because it contains too many changes. Β  See raw diff
Files changed (50) hide show
  1. app.py +7 -67
  2. build_apex.sh β†’ build_apexx.sh +0 -0
  3. {common β†’ commonx}/__init__.py +0 -0
  4. {common β†’ commonx}/cache.py +0 -0
  5. {common β†’ commonx}/config.py +0 -0
  6. {common β†’ commonx}/decorators.py +0 -0
  7. {common β†’ commonx}/diffusion/__init__.py +0 -0
  8. {common β†’ commonx}/diffusion/config.py +0 -0
  9. {common β†’ commonx}/diffusion/samplers/base.py +0 -0
  10. {common β†’ commonx}/diffusion/samplers/euler.py +0 -0
  11. {common β†’ commonx}/diffusion/schedules/base.py +0 -0
  12. {common β†’ commonx}/diffusion/schedules/lerp.py +0 -0
  13. {common β†’ commonx}/diffusion/timesteps/base.py +0 -0
  14. {common β†’ commonx}/diffusion/timesteps/sampling/trailing.py +0 -0
  15. {common β†’ commonx}/diffusion/types.py +0 -0
  16. {common β†’ commonx}/diffusion/utils.py +0 -0
  17. {common β†’ commonx}/distributed/__init__.py +0 -0
  18. {common β†’ commonx}/distributed/advanced.py +0 -0
  19. {common β†’ commonx}/distributed/basic.py +0 -0
  20. {common β†’ commonx}/distributed/meta_init_utils.py +0 -0
  21. {common β†’ commonx}/distributed/ops.py +0 -0
  22. {common β†’ commonx}/logger.py +0 -0
  23. {common β†’ commonx}/partition.py +0 -0
  24. {common β†’ commonx}/seed.py +0 -0
  25. {configs_3b β†’ configs_3bx}/main.yaml +0 -0
  26. {configs_7b β†’ configs_7bx}/main.yaml +0 -0
  27. {data β†’ datax}/image/transforms/area_resize.py +0 -0
  28. {data β†’ datax}/image/transforms/divisible_crop.py +0 -0
  29. {data β†’ datax}/image/transforms/na_resize.py +0 -0
  30. {data β†’ datax}/image/transforms/side_resize.py +0 -0
  31. {data β†’ datax}/video/transforms/rearrange.py +0 -0
  32. environment.yml β†’ environmentx.yml +0 -0
  33. {models β†’ modelsx}/dit/attention.py +0 -0
  34. {models β†’ modelsx}/dit/blocks/__init__.py +0 -0
  35. {models β†’ modelsx}/dit/blocks/mmdit_window_block.py +0 -0
  36. {models β†’ modelsx}/dit/embedding.py +0 -0
  37. {models β†’ modelsx}/dit/mlp.py +0 -0
  38. {models β†’ modelsx}/dit/mm.py +0 -0
  39. {models β†’ modelsx}/dit/modulation.py +0 -0
  40. {models β†’ modelsx}/dit/na.py +0 -0
  41. {models β†’ modelsx}/dit/nablocks/__init__.py +0 -0
  42. {models β†’ modelsx}/dit/nablocks/mmsr_block.py +0 -0
  43. {models β†’ modelsx}/dit/nadit.py +0 -0
  44. {models β†’ modelsx}/dit/normalization.py +0 -0
  45. {models β†’ modelsx}/dit/patch.py +0 -0
  46. {models β†’ modelsx}/dit/rope.py +0 -0
  47. {models β†’ modelsx}/dit/window.py +0 -0
  48. {models β†’ modelsx}/dit_v2/attention.py +0 -0
  49. {models β†’ modelsx}/dit_v2/embedding.py +0 -0
  50. {models β†’ modelsx}/dit_v2/mlp.py +0 -0
app.py CHANGED
@@ -14,6 +14,12 @@
14
  import spaces
15
  import subprocess
16
 
 
 
 
 
 
 
17
  import os
18
  import torch
19
  import mediapy
@@ -77,75 +83,9 @@ subprocess.run(
77
  shell=True,
78
  )
79
 
80
- def load_file_from_url(url, model_dir=None, progress=True, file_name=None):
81
- """Load file from http url, will download models if necessary.
82
-
83
- Reference: https://github.com/1adrianb/face-alignment/blob/master/face_alignment/utils.py
84
-
85
- Args:
86
- url (str): URL to be downloaded.
87
- model_dir (str): The path to save the downloaded model. Should be a full path. If None, use pytorch hub_dir.
88
- Default: None.
89
- progress (bool): Whether to show the download progress. Default: True.
90
- file_name (str): The downloaded file name. If None, use the file name in the url. Default: None.
91
-
92
- Returns:
93
- str: The path to the downloaded file.
94
- """
95
- if model_dir is None: # use the pytorch hub_dir
96
- hub_dir = get_dir()
97
- model_dir = os.path.join(hub_dir, 'checkpoints')
98
-
99
- os.makedirs(model_dir, exist_ok=True)
100
-
101
- parts = urlparse(url)
102
- filename = os.path.basename(parts.path)
103
- if file_name is not None:
104
- filename = file_name
105
- cached_file = os.path.abspath(os.path.join(model_dir, filename))
106
- if not os.path.exists(cached_file):
107
- print(f'Downloading: "{url}" to {cached_file}\n')
108
- download_url_to_file(url, cached_file, hash_prefix=None, progress=progress)
109
- return cached_file
110
-
111
-
112
- # os.system("pip freeze")
113
- ckpt_dir = Path('./ckpts')
114
- if not ckpt_dir.exists():
115
- ckpt_dir.mkdir()
116
-
117
- pretrain_model_url = {
118
- 'vae': 'https://huggingface.co/ByteDance-Seed/SeedVR2-3B/resolve/main/ema_vae.pth',
119
- 'dit': 'https://huggingface.co/ByteDance-Seed/SeedVR2-3B/resolve/main/seedvr2_ema_3b.pth',
120
- 'pos_emb': 'https://huggingface.co/ByteDance-Seed/SeedVR2-3B/resolve/main/pos_emb.pt',
121
- 'neg_emb': 'https://huggingface.co/ByteDance-Seed/SeedVR2-3B/resolve/main/neg_emb.pt',
122
- 'apex': 'https://huggingface.co/ByteDance-Seed/SeedVR2-3B/resolve/main/apex-0.1-cp310-cp310-linux_x86_64.whl'
123
- }
124
- # download weights
125
- if not os.path.exists('./ckpts/seedvr2_ema_3b.pth'):
126
- load_file_from_url(url=pretrain_model_url['dit'], model_dir='./ckpts/', progress=True, file_name=None)
127
- if not os.path.exists('./ckpts/ema_vae.pth'):
128
- load_file_from_url(url=pretrain_model_url['vae'], model_dir='./ckpts/', progress=True, file_name=None)
129
- if not os.path.exists('./pos_emb.pt'):
130
- load_file_from_url(url=pretrain_model_url['pos_emb'], model_dir='./', progress=True, file_name=None)
131
- if not os.path.exists('./neg_emb.pt'):
132
- load_file_from_url(url=pretrain_model_url['neg_emb'], model_dir='./', progress=True, file_name=None)
133
- if not os.path.exists('./apex-0.1-cp310-cp310-linux_x86_64.whl'):
134
- load_file_from_url(url=pretrain_model_url['apex'], model_dir='./', progress=True, file_name=None)
135
-
136
  subprocess.run(shlex.split("pip install apex-0.1-cp310-cp310-linux_x86_64.whl"))
137
  print(f"βœ… setup completed Apex")
138
 
139
- # download images
140
- torch.hub.download_url_to_file(
141
- 'https://huggingface.co/datasets/Iceclear/SeedVR_VideoDemos/resolve/main/seedvr_videos_crf23/aigc1k/23_1_lq.mp4',
142
- '01.mp4')
143
- torch.hub.download_url_to_file(
144
- 'https://huggingface.co/datasets/Iceclear/SeedVR_VideoDemos/resolve/main/seedvr_videos_crf23/aigc1k/28_1_lq.mp4',
145
- '02.mp4')
146
- torch.hub.download_url_to_file(
147
- 'https://huggingface.co/datasets/Iceclear/SeedVR_VideoDemos/resolve/main/seedvr_videos_crf23/aigc1k/2_1_lq.mp4',
148
- '03.mp4')
149
 
150
  def configure_sequence_parallel(sp_size):
151
  if sp_size > 1:
@@ -506,4 +446,4 @@ with gr.Blocks(title="SeedVR2: One-Step Video Restoration via Diffusion Adversar
506
  """)
507
 
508
  demo.queue()
509
- demo.launch()
 
14
  import spaces
15
  import subprocess
16
 
17
+ # Clone the repository to ensure all files are available
18
+ subprocess.run("git lfs install", shell=True, check=True)
19
+ subprocess.run("git clone https://huggingface.co/spaces/ByteDance-Seed/SeedVR2-3B", shell=True, check=True)
20
+ os.chdir('SeedVR2-3B')
21
+
22
+
23
  import os
24
  import torch
25
  import mediapy
 
83
  shell=True,
84
  )
85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  subprocess.run(shlex.split("pip install apex-0.1-cp310-cp310-linux_x86_64.whl"))
87
  print(f"βœ… setup completed Apex")
88
 
 
 
 
 
 
 
 
 
 
 
89
 
90
  def configure_sequence_parallel(sp_size):
91
  if sp_size > 1:
 
446
  """)
447
 
448
  demo.queue()
449
+ demo.launch()
build_apex.sh β†’ build_apexx.sh RENAMED
File without changes
{common β†’ commonx}/__init__.py RENAMED
File without changes
{common β†’ commonx}/cache.py RENAMED
File without changes
{common β†’ commonx}/config.py RENAMED
File without changes
{common β†’ commonx}/decorators.py RENAMED
File without changes
{common β†’ commonx}/diffusion/__init__.py RENAMED
File without changes
{common β†’ commonx}/diffusion/config.py RENAMED
File without changes
{common β†’ commonx}/diffusion/samplers/base.py RENAMED
File without changes
{common β†’ commonx}/diffusion/samplers/euler.py RENAMED
File without changes
{common β†’ commonx}/diffusion/schedules/base.py RENAMED
File without changes
{common β†’ commonx}/diffusion/schedules/lerp.py RENAMED
File without changes
{common β†’ commonx}/diffusion/timesteps/base.py RENAMED
File without changes
{common β†’ commonx}/diffusion/timesteps/sampling/trailing.py RENAMED
File without changes
{common β†’ commonx}/diffusion/types.py RENAMED
File without changes
{common β†’ commonx}/diffusion/utils.py RENAMED
File without changes
{common β†’ commonx}/distributed/__init__.py RENAMED
File without changes
{common β†’ commonx}/distributed/advanced.py RENAMED
File without changes
{common β†’ commonx}/distributed/basic.py RENAMED
File without changes
{common β†’ commonx}/distributed/meta_init_utils.py RENAMED
File without changes
{common β†’ commonx}/distributed/ops.py RENAMED
File without changes
{common β†’ commonx}/logger.py RENAMED
File without changes
{common β†’ commonx}/partition.py RENAMED
File without changes
{common β†’ commonx}/seed.py RENAMED
File without changes
{configs_3b β†’ configs_3bx}/main.yaml RENAMED
File without changes
{configs_7b β†’ configs_7bx}/main.yaml RENAMED
File without changes
{data β†’ datax}/image/transforms/area_resize.py RENAMED
File without changes
{data β†’ datax}/image/transforms/divisible_crop.py RENAMED
File without changes
{data β†’ datax}/image/transforms/na_resize.py RENAMED
File without changes
{data β†’ datax}/image/transforms/side_resize.py RENAMED
File without changes
{data β†’ datax}/video/transforms/rearrange.py RENAMED
File without changes
environment.yml β†’ environmentx.yml RENAMED
File without changes
{models β†’ modelsx}/dit/attention.py RENAMED
File without changes
{models β†’ modelsx}/dit/blocks/__init__.py RENAMED
File without changes
{models β†’ modelsx}/dit/blocks/mmdit_window_block.py RENAMED
File without changes
{models β†’ modelsx}/dit/embedding.py RENAMED
File without changes
{models β†’ modelsx}/dit/mlp.py RENAMED
File without changes
{models β†’ modelsx}/dit/mm.py RENAMED
File without changes
{models β†’ modelsx}/dit/modulation.py RENAMED
File without changes
{models β†’ modelsx}/dit/na.py RENAMED
File without changes
{models β†’ modelsx}/dit/nablocks/__init__.py RENAMED
File without changes
{models β†’ modelsx}/dit/nablocks/mmsr_block.py RENAMED
File without changes
{models β†’ modelsx}/dit/nadit.py RENAMED
File without changes
{models β†’ modelsx}/dit/normalization.py RENAMED
File without changes
{models β†’ modelsx}/dit/patch.py RENAMED
File without changes
{models β†’ modelsx}/dit/rope.py RENAMED
File without changes
{models β†’ modelsx}/dit/window.py RENAMED
File without changes
{models β†’ modelsx}/dit_v2/attention.py RENAMED
File without changes
{models β†’ modelsx}/dit_v2/embedding.py RENAMED
File without changes
{models β†’ modelsx}/dit_v2/mlp.py RENAMED
File without changes