Spaces:
Runtime error
Runtime error
delete most cpu speed up methods, most make no difference
Browse files- README.md +4 -4
- app.py +2 -13
- packages.txt +0 -2
README.md
CHANGED
@@ -8,10 +8,10 @@ sdk_version: 4.24.0
|
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: cc-by-nc-4.0
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
---
|
16 |
|
17 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: cc-by-nc-4.0
|
11 |
+
preload_from_hub:
|
12 |
+
- SG161222/Realistic_Vision_V4.0_noVAE Realistic_Vision_V4.0.safetensors
|
13 |
+
- stabilityai/sd-vae-ft-mse
|
14 |
+
- runwayml/stable-diffusion-v1-5 scheduler/scheduler_config.json
|
15 |
---
|
16 |
|
17 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
CHANGED
@@ -2,19 +2,10 @@
|
|
2 |
import os
|
3 |
from os.path import join as opj
|
4 |
|
5 |
-
LD_PRELOAD = os.getenv("LD_PRELOAD")
|
6 |
-
os.environ["LD_PRELOAD"] = f"{LD_PRELOAD}:/usr/lib/x86_64-linux-gnu/libjemalloc.so"
|
7 |
-
os.environ["MALLOC_CONF"] = "oversize_threshold:1,background_thread:true,metadata_thp:auto,dirty_decay_ms: 60000,muzzy_decay_ms:60000"
|
8 |
-
|
9 |
-
LD_PRELOAD= os.getenv("LD_PRELOAD")
|
10 |
-
os.environ["LD_PRELOAD"] = f"{LD_PRELOAD}:/usr/lib/x86_64-linux-gnu/libjemalloc.so:/usr/lib/x86_64-linux-gnu/libiomp5.so"
|
11 |
-
os.environ["OMP_NUM_THREADS"] ==32
|
12 |
-
|
13 |
token = os.getenv("ACCESS_TOKEN")
|
14 |
os.system(f"python -m pip install git+https://{token}@github.com/logn-2024/StableGarment.git")
|
15 |
|
16 |
import torch
|
17 |
-
import spaces
|
18 |
import gradio as gr
|
19 |
from PIL import Image
|
20 |
import numpy as np
|
@@ -44,11 +35,11 @@ pretrained_garment_encoder_path = "loooooong/StableGarment_text2img"
|
|
44 |
garment_encoder = GarmentEncoderModel.from_pretrained(pretrained_garment_encoder_path,torch_dtype=torch_dtype,subfolder="garment_encoder")
|
45 |
garment_encoder = garment_encoder.to(device=device,dtype=torch_dtype)
|
46 |
|
47 |
-
pipeline_t2i = StableGarmentPipeline.from_pretrained(base_model_path, vae=vae, torch_dtype=torch_dtype,).to(device=device) # variant="fp16"
|
48 |
# pipeline = StableDiffusionPipeline.from_pretrained("SG161222/Realistic_Vision_V4.0_noVAE", vae=vae, torch_dtype=torch_dtype).to(device=device)
|
49 |
pipeline_t2i.scheduler = scheduler
|
50 |
|
51 |
-
if
|
52 |
# speed up for cpu
|
53 |
# to channels last
|
54 |
pipeline_t2i.unet = pipeline_t2i.unet.to(memory_format=torch.channels_last)
|
@@ -100,7 +91,6 @@ def prepare_controlnet_inputs(agn_mask_list,densepose_list):
|
|
100 |
controlnet_inputs = torch.stack(controlnet_inputs)
|
101 |
return controlnet_inputs
|
102 |
|
103 |
-
@spaces.GPU(enable_queue=True)
|
104 |
def tryon(prompt,init_image,garment_top,garment_down,):
|
105 |
basename = os.path.splitext(os.path.basename(init_image))[0]
|
106 |
image_agn = Image.open(opj(parse_dir,basename+"_agn.jpg")).resize((width,height))
|
@@ -120,7 +110,6 @@ def tryon(prompt,init_image,garment_top,garment_down,):
|
|
120 |
generator=None,).images
|
121 |
return images[0]
|
122 |
|
123 |
-
@spaces.GPU(enable_queue=True)
|
124 |
def text2image(prompt,init_image,garment_top,garment_down,style_fidelity=1.):
|
125 |
|
126 |
garment_top = Image.open(garment_top).resize((width,height))
|
|
|
2 |
import os
|
3 |
from os.path import join as opj
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
token = os.getenv("ACCESS_TOKEN")
|
6 |
os.system(f"python -m pip install git+https://{token}@github.com/logn-2024/StableGarment.git")
|
7 |
|
8 |
import torch
|
|
|
9 |
import gradio as gr
|
10 |
from PIL import Image
|
11 |
import numpy as np
|
|
|
35 |
garment_encoder = GarmentEncoderModel.from_pretrained(pretrained_garment_encoder_path,torch_dtype=torch_dtype,subfolder="garment_encoder")
|
36 |
garment_encoder = garment_encoder.to(device=device,dtype=torch_dtype)
|
37 |
|
38 |
+
pipeline_t2i = StableGarmentPipeline.from_pretrained(base_model_path, vae=vae, torch_dtype=torch_dtype, use_safetensors=True,).to(device=device) # variant="fp16"
|
39 |
# pipeline = StableDiffusionPipeline.from_pretrained("SG161222/Realistic_Vision_V4.0_noVAE", vae=vae, torch_dtype=torch_dtype).to(device=device)
|
40 |
pipeline_t2i.scheduler = scheduler
|
41 |
|
42 |
+
if device=="cpu":
|
43 |
# speed up for cpu
|
44 |
# to channels last
|
45 |
pipeline_t2i.unet = pipeline_t2i.unet.to(memory_format=torch.channels_last)
|
|
|
91 |
controlnet_inputs = torch.stack(controlnet_inputs)
|
92 |
return controlnet_inputs
|
93 |
|
|
|
94 |
def tryon(prompt,init_image,garment_top,garment_down,):
|
95 |
basename = os.path.splitext(os.path.basename(init_image))[0]
|
96 |
image_agn = Image.open(opj(parse_dir,basename+"_agn.jpg")).resize((width,height))
|
|
|
110 |
generator=None,).images
|
111 |
return images[0]
|
112 |
|
|
|
113 |
def text2image(prompt,init_image,garment_top,garment_down,style_fidelity=1.):
|
114 |
|
115 |
garment_top = Image.open(garment_top).resize((width,height))
|
packages.txt
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
libjemalloc-dev
|
2 |
-
intel-mkl
|
|
|
|
|
|