Spaces:
Runtime error
Runtime error
Update app_demo.py
Browse files- app_demo.py +15 -11
app_demo.py
CHANGED
@@ -1,27 +1,19 @@
|
|
1 |
#!/usr/bin/env python
|
2 |
from __future__ import annotations
|
3 |
-
|
4 |
import os
|
5 |
import random
|
6 |
import time
|
7 |
-
|
8 |
import gradio as gr
|
9 |
import numpy as np
|
10 |
import PIL.Image
|
11 |
import torch
|
12 |
-
|
13 |
from diffusers import DiffusionPipeline
|
14 |
-
import torch
|
15 |
-
|
16 |
-
import os
|
17 |
-
import torch
|
18 |
from tqdm import tqdm
|
19 |
from safetensors.torch import load_file
|
20 |
import gradio_user_history as gr_user_history
|
21 |
-
|
22 |
from concurrent.futures import ThreadPoolExecutor
|
23 |
import uuid
|
24 |
-
import cv2
|
25 |
|
26 |
DESCRIPTION = '''# Fast Stable Diffusion CPU with Latent Consistency Model
|
27 |
Distilled from [Dreamshaper v7](https://huggingface.co/Lykon/dreamshaper-7) fine-tune of [Stable Diffusion v1-5](https://huggingface.co/runwayml/stable-diffusion-v1-5) with only 4,000 training iterations (~32 A100 GPU Hours). [Project page](https://latent-consistency-models.github.io)
|
@@ -35,9 +27,21 @@ MAX_IMAGE_SIZE = int(os.getenv("MAX_IMAGE_SIZE", "768"))
|
|
35 |
USE_TORCH_COMPILE = os.getenv("USE_TORCH_COMPILE") == "1"
|
36 |
DTYPE = torch.float32 # torch.float16 works as well, but pictures seem to be a bit worse
|
37 |
|
38 |
-
pipe = DiffusionPipeline.from_pretrained("SimianLuo/LCM_Dreamshaper_v7", custom_pipeline="latent_consistency_txt2img", custom_revision="main")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
pipe.to(torch_device="cpu", torch_dtype=DTYPE)
|
40 |
-
pipe.
|
|
|
|
|
|
|
|
|
41 |
|
42 |
def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
|
43 |
if randomize_seed:
|
|
|
1 |
#!/usr/bin/env python
|
2 |
from __future__ import annotations
|
|
|
3 |
import os
|
4 |
import random
|
5 |
import time
|
|
|
6 |
import gradio as gr
|
7 |
import numpy as np
|
8 |
import PIL.Image
|
9 |
import torch
|
|
|
10 |
from diffusers import DiffusionPipeline
|
|
|
|
|
|
|
|
|
11 |
from tqdm import tqdm
|
12 |
from safetensors.torch import load_file
|
13 |
import gradio_user_history as gr_user_history
|
|
|
14 |
from concurrent.futures import ThreadPoolExecutor
|
15 |
import uuid
|
16 |
+
#import cv2
|
17 |
|
18 |
DESCRIPTION = '''# Fast Stable Diffusion CPU with Latent Consistency Model
|
19 |
Distilled from [Dreamshaper v7](https://huggingface.co/Lykon/dreamshaper-7) fine-tune of [Stable Diffusion v1-5](https://huggingface.co/runwayml/stable-diffusion-v1-5) with only 4,000 training iterations (~32 A100 GPU Hours). [Project page](https://latent-consistency-models.github.io)
|
|
|
27 |
USE_TORCH_COMPILE = os.getenv("USE_TORCH_COMPILE") == "1"
|
28 |
DTYPE = torch.float32 # torch.float16 works as well, but pictures seem to be a bit worse
|
29 |
|
30 |
+
#pipe = DiffusionPipeline.from_pretrained("SimianLuo/LCM_Dreamshaper_v7", custom_pipeline="latent_consistency_txt2img", custom_revision="main")
|
31 |
+
|
32 |
+
|
33 |
+
|
34 |
+
pipe = DiffusionPipeline.from_pretrained( "SimianLuo/LCM_Dreamshaper_v7", custom_pipeline="latent_consistency_txt2img",
|
35 |
+
custom_revision="main",
|
36 |
+
low_cpu_mem_usage=True
|
37 |
+
pipe.safety_checker = None
|
38 |
+
)
|
39 |
pipe.to(torch_device="cpu", torch_dtype=DTYPE)
|
40 |
+
pipe.to("cpu")
|
41 |
+
|
42 |
+
|
43 |
+
|
44 |
+
|
45 |
|
46 |
def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
|
47 |
if randomize_seed:
|