Spaces:
Runtime error
Runtime error
File size: 1,311 Bytes
79720de 9a87834 4dc9e2b 9a87834 79720de |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
"""See https://huggingface.co/fu sing/latent-diffusion-text2im-large."""
from logzero import logger
from install import install
try:
import gradio as gr
except ModuleNotFoundError:
try:
install("gradio")
import gradio as gr
except Exception as exc:
logger.error(exc)
raise SystemExit(1)
import PIL
from diffusers import DiffusionPipeline
ldm = DiffusionPipeline.from_pretrained("fu sing/latent-diffusion-text2im-large")
generator = torch.manual_seed(42)
examples = ["A street sign that reads Huggingface", "A painting of a squirrel eating a burger"]
prompt_ = "A painting of a squirrel eating a burger"
def fn(prompt=prompt_):
image = ldm(
[prompt],
generator=generator,
eta=0.3,
guidance_scale=6.0,
num_inference_steps=50,
)
image_processed = image.cpu().permute(0, 2, 3, 1)
image_processed = image_processed * 255.
image_processed = image_processed.numpy().astype(np.uint8)
image_pil = PIL.Image.fromarray(image_processed[0])
# save image
# image_pil.save("test.png")
return image_pil
iface = gr.Interface(
fn=fn,
inputs="text",
outputs="image",
examples=examples,
live=True,
)
iface.launch()
# gr.Interface.load("fu sing/latent-diffusion-text2im-large", examples=examples).launch() |