Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -149,20 +149,43 @@ DownLoad(r"https://civitai.com/api/download/models/39885",str(user_home / r"stab
|
|
| 149 |
DownLoad(r"https://civitai.com/api/download/models/21065",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-additional-networks" / r"models"/ r"lora"),r"LAS.safetensors")
|
| 150 |
DownLoad(r"https://civitai.com/api/download/models/39164",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-additional-networks" / r"models"/ r"lora"),r"backlighting.safetensors")
|
| 151 |
|
| 152 |
-
|
|
|
|
|
|
|
|
|
|
| 153 |
hf_token = os.getenv("token")
|
|
|
|
|
|
|
|
|
|
| 154 |
|
| 155 |
-
#
|
| 156 |
model_path = "/home/user/stable-diffusion-webui/models/Stable-diffusion/flux1-dev.safetensors"
|
| 157 |
if os.path.exists(model_path):
|
| 158 |
os.remove(model_path)
|
| 159 |
-
|
|
|
|
|
|
|
| 160 |
|
| 161 |
# wget でファイルをダウンロード
|
| 162 |
-
cmd = f'wget --header="Authorization: Bearer {hf_token}" -O {model_path} "https://huggingface.co/black-forest-labs/FLUX.1-dev/resolve/main/flux1-dev.safetensors"'
|
|
|
|
| 163 |
os.system(cmd)
|
| 164 |
-
os.system("ls -lh /home/user/stable-diffusion-webui/models/Stable-diffusion/flux1-dev.safetensors")
|
| 165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
print("Done\nStarting Webui...")
|
| 167 |
os.chdir(user_home / r"stable-diffusion-webui")
|
| 168 |
while True:
|
|
|
|
| 149 |
DownLoad(r"https://civitai.com/api/download/models/21065",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-additional-networks" / r"models"/ r"lora"),r"LAS.safetensors")
|
| 150 |
DownLoad(r"https://civitai.com/api/download/models/39164",str(user_home / r"stable-diffusion-webui" / r"extensions" / r"sd-webui-additional-networks" / r"models"/ r"lora"),r"backlighting.safetensors")
|
| 151 |
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
# Hugging Face トークン取得
|
| 156 |
hf_token = os.getenv("token")
|
| 157 |
+
if not hf_token:
|
| 158 |
+
print("Error: Hugging Face token not found.")
|
| 159 |
+
exit(1)
|
| 160 |
|
| 161 |
+
# 削除処理
|
| 162 |
model_path = "/home/user/stable-diffusion-webui/models/Stable-diffusion/flux1-dev.safetensors"
|
| 163 |
if os.path.exists(model_path):
|
| 164 |
os.remove(model_path)
|
| 165 |
+
|
| 166 |
+
# CPUモード設定(Linux向け修正)
|
| 167 |
+
os.environ["COMMANDLINE_ARGS"] = "--skip-torch-cuda-test --no-half --use-cpu all"
|
| 168 |
|
| 169 |
# wget でファイルをダウンロード
|
| 170 |
+
cmd = f'wget --header="Authorization: Bearer {hf_token}" -O "{model_path}" "https://huggingface.co/black-forest-labs/FLUX.1-dev/resolve/main/flux1-dev.safetensors"'
|
| 171 |
+
print(f"Executing command: {cmd}")
|
| 172 |
os.system(cmd)
|
|
|
|
| 173 |
|
| 174 |
+
# ファイルサイズチェック
|
| 175 |
+
if os.path.exists(model_path):
|
| 176 |
+
file_size = os.path.getsize(model_path)
|
| 177 |
+
if file_size < 1000: # 1KB 未満なら異常
|
| 178 |
+
print(f"Error: {model_path} is too small ({file_size} bytes). Download failed.")
|
| 179 |
+
os.remove(model_path)
|
| 180 |
+
exit(1)
|
| 181 |
+
else:
|
| 182 |
+
print(f"Download successful. File size: {file_size} bytes.")
|
| 183 |
+
else:
|
| 184 |
+
print("Error: File not found after download.")
|
| 185 |
+
exit(1)
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
|
| 189 |
print("Done\nStarting Webui...")
|
| 190 |
os.chdir(user_home / r"stable-diffusion-webui")
|
| 191 |
while True:
|