Spaces:
Runtime error
Runtime error
File size: 2,008 Bytes
7700a40 4bd2758 02f9d1d 844b57b 4bd2758 844b57b 06a4528 844b57b 4bd2758 |
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
import torch
from diffusers import StableDiffusionPipeline
model_id = "runwayml/stable-diffusion-v1-5"
sd_pipeline = StableDiffusionPipeline.from_pretrained(model_id,
torch_dtype=torch.float16)
sd_pipeline = sd_pipeline.to("cuda")
def get_completion_sd(prompt):
negative_prompt = """
simple background, duplicate, low quality, lowest quality,
bad anatomy, bad proportions, extra digits, lowres, username,
artist name, error, duplicate, watermark, signature, text,
extra digit, fewer digits, worst quality, jpeg artifacts, blurry
"""
return sd_pipeline(prompt, negative_prompt=negative_prompt).images[0]
#let's prompt
# prompt = "astronaut, riding a horse, on mars, human colony"
# prompt = "children, playing in disneyland, view from a distance"
prompt = """llama, wearing red socks,
grazing, open field, raining
"""
print(prompt)
sd_image = get_completion_sd(prompt)
sd_image.save("./llama.jpg")
import gradio as gr
def get_completion(prompt):
negative_prompt = """
simple background, duplicate, low quality, lowest quality,
bad anatomy, bad proportions, extra digits, lowres, username,
artist name, error, duplicate, watermark, signature, text,
extra digit, fewer digits, worst quality, jpeg artifacts, blurry
"""
return sd_pipeline(prompt, negative_prompt=negative_prompt).images[0]
# def generate(prompt):
# output = get_completion_sd(prompt)
# return output
genai_app = gr.Interface(fn=get_completion,
inputs=[gr.Textbox(label="Your prompt")],
outputs=[gr.Image(label="Result")],
title="Generate Cool Images",
description="Generate any image with Stable Diffusion",
allow_flagging="never",
examples=["astronaut, riding a horse, on mars",
"cargo ship, flying, in space"])
genai_app.launch(share=True)
|