tori29umai commited on
Commit
5836c22
1 Parent(s): e71b11b
Files changed (1) hide show
  1. utils/utils.py +28 -38
utils/utils.py CHANGED
@@ -9,24 +9,20 @@ import numpy as np
9
  import cv2
10
 
11
  def load_cn_model(model_dir):
12
- folder = model_dir
13
- file_name = 'diffusion_pytorch_model.safetensors'
14
- url = " https://huggingface.co/2vXpSwA7/iroiro-lora/resolve/main/test_controlnet2/CN-anytest_v3-50000_fp16.safetensors"
15
- file_path = os.path.join(folder, file_name)
16
- if not os.path.exists(file_path):
17
- response = requests.get(url, stream=True)
18
-
19
- total_size = int(response.headers.get('content-length', 0))
20
- with open(file_path, 'wb') as f, tqdm(
21
- desc=file_name,
22
- total=total_size,
23
- unit='iB',
24
- unit_scale=True,
25
- unit_divisor=1024,
26
- ) as bar:
27
- for data in response.iter_content(chunk_size=1024):
28
- size = f.write(data)
29
- bar.update(size)
30
 
31
  def load_cn_config(model_dir):
32
  folder = model_dir
@@ -61,27 +57,21 @@ def load_tagger_model(model_dir):
61
 
62
 
63
  def load_lora_model(model_dir):
64
- folder = model_dir
65
- file_name = 'style-lineart_02.safetensors'
66
- url = "https://huggingface.co/2vXpSwA7/iroiro-lora/resolve/main/test3/style-lineart_02.safetensors"
67
-
68
- file_path = os.path.join(folder, file_name)
69
- if not os.path.exists(file_path):
70
- response = requests.get(url, stream=True)
71
-
72
- total_size = int(response.headers.get('content-length', 0))
73
- with open(file_path, 'wb') as f, tqdm(
74
- desc=file_name,
75
- total=total_size,
76
- unit='iB',
77
- unit_scale=True,
78
- unit_divisor=1024,
79
- ) as bar:
80
- for data in response.iter_content(chunk_size=1024):
81
- size = f.write(data)
82
- bar.update(size)
83
-
84
 
 
85
  def resize_image_aspect_ratio(image):
86
  # 元の画像サイズを取得
87
  original_width, original_height = image.size
 
9
  import cv2
10
 
11
  def load_cn_model(model_dir):
12
+ folder = model_dir
13
+ file_name = 'diffusion_pytorch_model.safetensors'
14
+ url = " https://huggingface.co/2vXpSwA7/iroiro-lora/resolve/main/test_controlnet2/CN-anytest_v3-50000_fp16.safetensors"
15
+ file_path = os.path.join(folder, file_name)
16
+ if not os.path.exists(file_path):
17
+ response = requests.get(url, allow_redirects=True)
18
+ if response.status_code == 200:
19
+ with open(file_path, 'wb') as f:
20
+ f.write(response.content)
21
+ print(f'Downloaded {file_name}')
22
+ else:
23
+ print(f'Failed to download {file_name}')
24
+ else:
25
+ print(f'{file_name} already exists.')
 
 
 
 
26
 
27
  def load_cn_config(model_dir):
28
  folder = model_dir
 
57
 
58
 
59
  def load_lora_model(model_dir):
60
+ file_name = 'style-lineart_02.safetensors'
61
+ file_path = os.path.join(model_dir, file_name)
62
+ if not os.path.exists(file_path):
63
+ url = "https://huggingface.co/2vXpSwA7/iroiro-lora/resolve/main/test3/style-lineart_02.safetensors"
64
+ response = requests.get(url, allow_redirects=True)
65
+ if response.status_code == 200:
66
+ with open(file_path, 'wb') as f:
67
+ f.write(response.content)
68
+ print(f'Downloaded {file_name}')
69
+ else:
70
+ print(f'Failed to download {file_name}')
71
+ else:
72
+ print(f'{file_name} already exists.')
 
 
 
 
 
 
 
73
 
74
+
75
  def resize_image_aspect_ratio(image):
76
  # 元の画像サイズを取得
77
  original_width, original_height = image.size