jhj0517 commited on
Commit
cfa21c8
1 Parent(s): 3c0f460

refactor output dir and models dir

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. downloading_weights.py +11 -7
app.py CHANGED
@@ -17,7 +17,7 @@ class App:
17
  model_dir=args.model_dir,
18
  output_dir=args.output_dir
19
  )
20
- download_models(args.model_dir)
21
 
22
  def musepose_demo(self):
23
  with gr.Blocks() as demo:
 
17
  model_dir=args.model_dir,
18
  output_dir=args.output_dir
19
  )
20
+ download_models(model_dir=args.model_dir)
21
 
22
  def musepose_demo(self):
23
  with gr.Blocks() as demo:
downloading_weights.py CHANGED
@@ -4,9 +4,9 @@ from tqdm import tqdm
4
 
5
 
6
  def download_models(
7
- models_dir: str = os.makedirs('pretrained_weights', exist_ok=True)
8
  ):
9
- os.makedirs(models_dir, exist_ok=True)
10
 
11
  urls = ['https://download.openmmlab.com/mmdetection/v2.0/yolox/yolox_l_8x8_300e_coco/yolox_l_8x8_300e_coco_20211126_140236-d3bd2b23.pth',
12
  'https://huggingface.co/yzd-v/DWPose/resolve/main/dw-ll_ucoco_384.pth',
@@ -22,11 +22,12 @@ def download_models(
22
  paths = ['dwpose', 'dwpose', 'MusePose', 'MusePose', 'MusePose', 'MusePose', 'sd-image-variations-diffusers/unet', 'image_encoder', 'sd-vae-ft-mse']
23
 
24
  for path in paths:
25
- os.makedirs(f'pretrained_weights/{path}', exist_ok=True)
 
26
 
27
- # saving weights
28
  for url, path in tqdm(zip(urls, paths)):
29
- filename = wget.download(url, f'pretrained_weights/{path}')
 
30
 
31
  config_urls = ['https://huggingface.co/lambdalabs/sd-image-variations-diffusers/resolve/main/unet/config.json',
32
  'https://huggingface.co/lambdalabs/sd-image-variations-diffusers/resolve/main/image_encoder/config.json',
@@ -36,7 +37,10 @@ def download_models(
36
 
37
  # saving config files
38
  for url, path in tqdm(zip(config_urls, config_paths)):
39
- filename = wget.download(url, f'pretrained_weights/{path}')
 
40
 
41
  # renaming model name as given in readme
42
- os.rename('pretrained_weights/dwpose/yolox_l_8x8_300e_coco_20211126_140236-d3bd2b23.pth', 'pretrained_weights/dwpose/yolox_l_8x8_300e_coco.pth')
 
 
 
4
 
5
 
6
  def download_models(
7
+ model_dir: str = os.makedirs('pretrained_weights', exist_ok=True)
8
  ):
9
+ os.makedirs(model_dir, exist_ok=True)
10
 
11
  urls = ['https://download.openmmlab.com/mmdetection/v2.0/yolox/yolox_l_8x8_300e_coco/yolox_l_8x8_300e_coco_20211126_140236-d3bd2b23.pth',
12
  'https://huggingface.co/yzd-v/DWPose/resolve/main/dw-ll_ucoco_384.pth',
 
22
  paths = ['dwpose', 'dwpose', 'MusePose', 'MusePose', 'MusePose', 'MusePose', 'sd-image-variations-diffusers/unet', 'image_encoder', 'sd-vae-ft-mse']
23
 
24
  for path in paths:
25
+ dir = os.path.join(model_dir, path)
26
+ os.makedirs(dir, exist_ok=True)
27
 
 
28
  for url, path in tqdm(zip(urls, paths)):
29
+ local_file_path = os.path.join("pretrained_weights", path)
30
+ wget.download(url, local_file_path)
31
 
32
  config_urls = ['https://huggingface.co/lambdalabs/sd-image-variations-diffusers/resolve/main/unet/config.json',
33
  'https://huggingface.co/lambdalabs/sd-image-variations-diffusers/resolve/main/image_encoder/config.json',
 
37
 
38
  # saving config files
39
  for url, path in tqdm(zip(config_urls, config_paths)):
40
+ local_file_path = os.path.join("pretrained_weights", path)
41
+ wget.download(url, local_file_path)
42
 
43
  # renaming model name as given in readme
44
+ wrong_file_path = os.path.join("pretrained_weights", "dwpose", "yolox_l_8x8_300e_coco_20211126_140236-d3bd2b23.pth")
45
+ correct_file_path = os.path.join("pretrained_weights", "dwpose", "yolox_l_8x8_300e_coco.pth")
46
+ os.rename(wrong_file_path, correct_file_path)