Spaces:
Running
on
Zero
Running
on
Zero
Upload mod.py
Browse files
mod.py
CHANGED
@@ -5,9 +5,12 @@ from PIL import Image
|
|
5 |
from pathlib import Path
|
6 |
import gc
|
7 |
import subprocess
|
8 |
-
from env import num_cns, model_trigger, HF_TOKEN, CIVITAI_API_KEY, download_lora_list, directory_loras
|
9 |
-
from modutils import download_things
|
10 |
import os
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
|
13 |
subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
|
@@ -19,15 +22,15 @@ control_images = [None] * num_cns
|
|
19 |
control_modes = [-1] * num_cns
|
20 |
control_scales = [0] * num_cns
|
21 |
|
|
|
22 |
# Download stuffs
|
23 |
-
download_lora = ", ".join(
|
24 |
for url in [url.strip() for url in download_lora.split(',')]:
|
25 |
if not os.path.exists(f"./loras/{url.split('/')[-1]}"):
|
26 |
-
download_things(
|
27 |
|
28 |
|
29 |
def is_repo_name(s):
|
30 |
-
import re
|
31 |
return re.fullmatch(r'^[^/,\s\"\']+/[^/,\s\"\']+$', s)
|
32 |
|
33 |
|
@@ -43,7 +46,6 @@ def is_repo_exists(repo_id):
|
|
43 |
return True # for safe
|
44 |
|
45 |
|
46 |
-
from translatepy import Translator
|
47 |
translator = Translator()
|
48 |
def translate_to_en(input: str):
|
49 |
try:
|
@@ -66,7 +68,6 @@ def clear_cache():
|
|
66 |
|
67 |
|
68 |
def get_repo_safetensors(repo_id: str):
|
69 |
-
from huggingface_hub import HfApi
|
70 |
api = HfApi(token=HF_TOKEN)
|
71 |
try:
|
72 |
if not is_repo_name(repo_id) or not is_repo_exists(repo_id): return gr.update(value="", choices=[])
|
@@ -364,4 +365,4 @@ load_prompt_enhancer.zerogpu = True
|
|
364 |
fuse_loras.zerogpu = True
|
365 |
preprocess_image.zerogpu = True
|
366 |
get_control_params.zerogpu = True
|
367 |
-
clear_cache.zerogpu = True
|
|
|
5 |
from pathlib import Path
|
6 |
import gc
|
7 |
import subprocess
|
|
|
|
|
8 |
import os
|
9 |
+
import re
|
10 |
+
from translatepy import Translator
|
11 |
+
from huggingface_hub import HfApi
|
12 |
+
from env import num_cns, model_trigger, HF_TOKEN, CIVITAI_API_KEY, DOWNLOAD_LORA_LIST, DIRECTORY_LORAS
|
13 |
+
from modutils import download_things
|
14 |
|
15 |
|
16 |
subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
|
|
|
22 |
control_modes = [-1] * num_cns
|
23 |
control_scales = [0] * num_cns
|
24 |
|
25 |
+
|
26 |
# Download stuffs
|
27 |
+
download_lora = ", ".join(DOWNLOAD_LORA_LIST)
|
28 |
for url in [url.strip() for url in download_lora.split(',')]:
|
29 |
if not os.path.exists(f"./loras/{url.split('/')[-1]}"):
|
30 |
+
download_things(DIRECTORY_LORAS, url, HF_TOKEN, CIVITAI_API_KEY)
|
31 |
|
32 |
|
33 |
def is_repo_name(s):
|
|
|
34 |
return re.fullmatch(r'^[^/,\s\"\']+/[^/,\s\"\']+$', s)
|
35 |
|
36 |
|
|
|
46 |
return True # for safe
|
47 |
|
48 |
|
|
|
49 |
translator = Translator()
|
50 |
def translate_to_en(input: str):
|
51 |
try:
|
|
|
68 |
|
69 |
|
70 |
def get_repo_safetensors(repo_id: str):
|
|
|
71 |
api = HfApi(token=HF_TOKEN)
|
72 |
try:
|
73 |
if not is_repo_name(repo_id) or not is_repo_exists(repo_id): return gr.update(value="", choices=[])
|
|
|
365 |
fuse_loras.zerogpu = True
|
366 |
preprocess_image.zerogpu = True
|
367 |
get_control_params.zerogpu = True
|
368 |
+
clear_cache.zerogpu = True
|