Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import requests
|
| 3 |
+
from PIL import Image
|
| 4 |
+
from diffusers import DiffusionPipeline, EulerAncestralDiscreteScheduler
|
| 5 |
+
|
| 6 |
+
# Load the pipeline
|
| 7 |
+
pipeline = DiffusionPipeline.from_pretrained(
|
| 8 |
+
"sudo-ai/zero123plus-v1.1", custom_pipeline="sudo-ai/zero123plus-pipeline",
|
| 9 |
+
torch_dtype=torch.float16
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
# Feel free to tune the scheduler!
|
| 13 |
+
# `timestep_spacing` parameter is not supported in older versions of `diffusers`
|
| 14 |
+
# so there may be performance degradations
|
| 15 |
+
# We recommend using `diffusers==0.20.2`
|
| 16 |
+
pipeline.scheduler = EulerAncestralDiscreteScheduler.from_config(
|
| 17 |
+
pipeline.scheduler.config, timestep_spacing='trailing'
|
| 18 |
+
)
|
| 19 |
+
pipeline.to('cuda:0')
|
| 20 |
+
|
| 21 |
+
# Download an example image.
|
| 22 |
+
cond = Image.open(requests.get("https://d.skis.ltd/nrp/sample-data/lysol.png", stream=True).raw)
|
| 23 |
+
|
| 24 |
+
# Run the pipeline!
|
| 25 |
+
result = pipeline(cond, num_inference_steps=75).images[0]
|
| 26 |
+
# for general real and synthetic images of general objects
|
| 27 |
+
# usually it is enough to have around 28 inference steps
|
| 28 |
+
# for images with delicate details like faces (real or anime)
|
| 29 |
+
# you may need 75-100 steps for the details to construct
|
| 30 |
+
|
| 31 |
+
result.show()
|
| 32 |
+
result.save("output.png")
|
| 33 |
+
|
| 34 |
+
|