zhiweili
commited on
Commit
Β·
eb2b092
1
Parent(s):
0a61cdb
test deep cache
Browse files- app_onediff.py +15 -14
- requirements.txt +2 -1
app_onediff.py
CHANGED
|
@@ -12,6 +12,8 @@ from diffusers import (
|
|
| 12 |
AutoencoderKL,
|
| 13 |
)
|
| 14 |
|
|
|
|
|
|
|
| 15 |
def runcmd(cmd, verbose = False, *args, **kwargs):
|
| 16 |
|
| 17 |
process = subprocess.Popen(
|
|
@@ -26,18 +28,18 @@ def runcmd(cmd, verbose = False, *args, **kwargs):
|
|
| 26 |
print(std_out.strip(), std_err)
|
| 27 |
pass
|
| 28 |
|
| 29 |
-
os.system("python3 -m pip --no-cache-dir install -
|
| 30 |
-
os.system("git clone https://github.com/siliconflow/onediff.git")
|
| 31 |
-
os.system("cd onediff && python3 -m pip install .")
|
| 32 |
# sys.path.append("/home/user/app/onediff/src")
|
| 33 |
-
os.system("cd onediff/onediff_diffusers_extensions && python3 -m pip install .")
|
| 34 |
# sys.path.append("/home/user/app/onediff/onediff_diffusers_extensions/src")
|
| 35 |
|
| 36 |
-
os.system("pip show nexfort")
|
| 37 |
-
os.system("pip show onediff")
|
| 38 |
-
os.system("pip show onediffx")
|
| 39 |
|
| 40 |
-
from onediffx import compile_pipe, save_pipe
|
| 41 |
|
| 42 |
def nexfort_compile(torch_module: torch.nn.Module):
|
| 43 |
options = json.loads('{"mode": "max-optimize:max-autotune:low-precision", "memory_format": "channels_last", "dynamic": true}')
|
|
@@ -59,6 +61,10 @@ base_pipe = AutoPipelineForText2Image.from_pretrained(
|
|
| 59 |
)
|
| 60 |
base_pipe.to(device)
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
# base_pipe = nexfort_compile(base_pipe)
|
| 63 |
|
| 64 |
from gfpgan.utils import GFPGANer
|
|
@@ -84,15 +90,10 @@ def create_demo() -> gr.Blocks:
|
|
| 84 |
prompt:str,
|
| 85 |
steps:int,
|
| 86 |
):
|
| 87 |
-
global compiled_pipe
|
| 88 |
-
compiled_pipe = base_pipe
|
| 89 |
run_task_time = 0
|
| 90 |
time_cost_str = ''
|
| 91 |
run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
|
| 92 |
-
|
| 93 |
-
print("---------->Recompile<----------")
|
| 94 |
-
compiled_pipe = nexfort_compile(base_pipe)
|
| 95 |
-
generated_image = compiled_pipe(
|
| 96 |
prompt=prompt,
|
| 97 |
num_inference_steps=steps,
|
| 98 |
).images[0]
|
|
|
|
| 12 |
AutoencoderKL,
|
| 13 |
)
|
| 14 |
|
| 15 |
+
from DeepCache import DeepCacheSDHelper
|
| 16 |
+
|
| 17 |
def runcmd(cmd, verbose = False, *args, **kwargs):
|
| 18 |
|
| 19 |
process = subprocess.Popen(
|
|
|
|
| 28 |
print(std_out.strip(), std_err)
|
| 29 |
pass
|
| 30 |
|
| 31 |
+
# os.system("python3 -m pip --no-cache-dir install --pre nexfort -f https://github.com/siliconflow/nexfort_releases/releases/expanded_assets/torch2.4.1_cu121")
|
| 32 |
+
# os.system("git clone https://github.com/siliconflow/onediff.git")
|
| 33 |
+
# os.system("cd onediff && python3 -m pip install .")
|
| 34 |
# sys.path.append("/home/user/app/onediff/src")
|
| 35 |
+
# os.system("cd onediff/onediff_diffusers_extensions && python3 -m pip install .")
|
| 36 |
# sys.path.append("/home/user/app/onediff/onediff_diffusers_extensions/src")
|
| 37 |
|
| 38 |
+
# os.system("pip show nexfort")
|
| 39 |
+
# os.system("pip show onediff")
|
| 40 |
+
# os.system("pip show onediffx")
|
| 41 |
|
| 42 |
+
# from onediffx import compile_pipe, save_pipe
|
| 43 |
|
| 44 |
def nexfort_compile(torch_module: torch.nn.Module):
|
| 45 |
options = json.loads('{"mode": "max-optimize:max-autotune:low-precision", "memory_format": "channels_last", "dynamic": true}')
|
|
|
|
| 61 |
)
|
| 62 |
base_pipe.to(device)
|
| 63 |
|
| 64 |
+
helper = DeepCacheSDHelper(pipe=base_pipe)
|
| 65 |
+
helper.set_params(cache_interval=3, cache_branch_id=0)
|
| 66 |
+
helper.enable()
|
| 67 |
+
|
| 68 |
# base_pipe = nexfort_compile(base_pipe)
|
| 69 |
|
| 70 |
from gfpgan.utils import GFPGANer
|
|
|
|
| 90 |
prompt:str,
|
| 91 |
steps:int,
|
| 92 |
):
|
|
|
|
|
|
|
| 93 |
run_task_time = 0
|
| 94 |
time_cost_str = ''
|
| 95 |
run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
|
| 96 |
+
generated_image = base_pipe(
|
|
|
|
|
|
|
|
|
|
| 97 |
prompt=prompt,
|
| 98 |
num_inference_steps=steps,
|
| 99 |
).images[0]
|
requirements.txt
CHANGED
|
@@ -8,4 +8,5 @@ spaces
|
|
| 8 |
git+https://github.com/XPixelGroup/BasicSR@master
|
| 9 |
gfpgan
|
| 10 |
facexlib
|
| 11 |
-
realesrgan
|
|
|
|
|
|
| 8 |
git+https://github.com/XPixelGroup/BasicSR@master
|
| 9 |
gfpgan
|
| 10 |
facexlib
|
| 11 |
+
realesrgan
|
| 12 |
+
deepcache
|