Spaces:
Running
Running
patrickvonplaten
commited on
Commit
•
2472159
1
Parent(s):
7f458a0
add easy code snippet
Browse files- easy_run.py +17 -0
easy_run.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python3
|
2 |
+
# import pipeline and scheduler from https://huggingface.co/SimianLuo/LCM_Dreamshaper_v7/
|
3 |
+
from lcm_pipeline import LatentConsistencyModelPipeline
|
4 |
+
from lcm_scheduler import LCMScheduler
|
5 |
+
import hf_image_uploader as hiu
|
6 |
+
import torch
|
7 |
+
|
8 |
+
scheduler = LCMScheduler.from_pretrained("SimianLuo/LCM_Dreamshaper_v7", subfolder="scheduler")
|
9 |
+
|
10 |
+
pipe = LatentConsistencyModelPipeline.from_pretrained("SimianLuo/LCM_Dreamshaper_v7", scheduler=scheduler)
|
11 |
+
pipe.to("cuda", dtype=torch.float16)
|
12 |
+
|
13 |
+
prompt = "a red horse"
|
14 |
+
images = pipe(prompt=prompt, guidance_scale=8.0, num_inference_steps=4, lcm_origin_steps=50, output_type="pil").images
|
15 |
+
|
16 |
+
for image in images:
|
17 |
+
hiu.upload(image, "patrickvonplaten/images")
|