hysts commited on
Commit
02c2b6d
1 Parent(s): b2c2519
Files changed (2) hide show
  1. app.py +18 -11
  2. model.py +1 -1
app.py CHANGED
@@ -3,6 +3,7 @@
3
  from __future__ import annotations
4
 
5
  import os
 
6
  import shlex
7
  import subprocess
8
 
@@ -11,17 +12,23 @@ import gradio as gr
11
  if os.getenv('SYSTEM') == 'spaces':
12
  with open('patch') as f:
13
  subprocess.run(shlex.split('patch -p1'), stdin=f, cwd='ControlNet')
14
- commands = [
15
- 'wget https://huggingface.co/ckpt/ControlNet/resolve/main/dpt_hybrid-midas-501f0c75.pt -O dpt_hybrid-midas-501f0c75.pt',
16
- 'wget https://huggingface.co/ckpt/ControlNet/resolve/main/body_pose_model.pth -O body_pose_model.pth',
17
- 'wget https://huggingface.co/ckpt/ControlNet/resolve/main/hand_pose_model.pth -O hand_pose_model.pth',
18
- 'wget https://huggingface.co/ckpt/ControlNet/resolve/main/mlsd_large_512_fp32.pth -O mlsd_large_512_fp32.pth',
19
- 'wget https://huggingface.co/ckpt/ControlNet/resolve/main/mlsd_tiny_512_fp32.pth -O mlsd_tiny_512_fp32.pth',
20
- 'wget https://huggingface.co/ckpt/ControlNet/resolve/main/network-bsds500.pth -O network-bsds500.pth',
21
- 'wget https://huggingface.co/ckpt/ControlNet/resolve/main/upernet_global_small.pth -O upernet_global_small.pth',
22
- ]
23
- for command in commands:
24
- subprocess.run(shlex.split(command), cwd='ControlNet/annotator/ckpts/')
 
 
 
 
 
 
25
 
26
  from gradio_canny2image import create_demo as create_demo_canny
27
  from gradio_depth2image import create_demo as create_demo_depth
 
3
  from __future__ import annotations
4
 
5
  import os
6
+ import pathlib
7
  import shlex
8
  import subprocess
9
 
 
12
  if os.getenv('SYSTEM') == 'spaces':
13
  with open('patch') as f:
14
  subprocess.run(shlex.split('patch -p1'), stdin=f, cwd='ControlNet')
15
+
16
+ base_url = 'https://huggingface.co/lllyasviel/ControlNet/resolve/main/annotator/ckpts/'
17
+ names = [
18
+ 'body_pose_model.pth',
19
+ 'dpt_hybrid-midas-501f0c75.pt',
20
+ 'hand_pose_model.pth',
21
+ 'mlsd_large_512_fp32.pth',
22
+ 'mlsd_tiny_512_fp32.pth',
23
+ 'network-bsds500.pth',
24
+ 'upernet_global_small.pth',
25
+ ]
26
+ for name in names:
27
+ command = f'wget https://huggingface.co/lllyasviel/ControlNet/resolve/main/annotator/ckpts/{name} -O {name}'
28
+ out_path = pathlib.Path(f'ControlNet/annotator/ckpts/{name}')
29
+ if out_path.exists():
30
+ continue
31
+ subprocess.run(shlex.split(command), cwd='ControlNet/annotator/ckpts/')
32
 
33
  from gradio_canny2image import create_demo as create_demo_canny
34
  from gradio_depth2image import create_demo as create_demo_depth
model.py CHANGED
@@ -38,7 +38,7 @@ ORIGINAL_MODEL_NAMES = {
38
  'depth': 'control_sd15_depth.pth',
39
  'normal': 'control_sd15_normal.pth',
40
  }
41
- ORIGINAL_WEIGHT_ROOT = 'https://huggingface.co/ckpt/ControlNet/resolve/main/'
42
 
43
  LIGHTWEIGHT_MODEL_NAMES = {
44
  'canny': 'control_canny-fp16.safetensors',
 
38
  'depth': 'control_sd15_depth.pth',
39
  'normal': 'control_sd15_normal.pth',
40
  }
41
+ ORIGINAL_WEIGHT_ROOT = 'https://huggingface.co/lllyasviel/ControlNet/resolve/main/models/'
42
 
43
  LIGHTWEIGHT_MODEL_NAMES = {
44
  'canny': 'control_canny-fp16.safetensors',