sachinbluechip/Image_generation_with_diffusion_model
0
1from transformers.utils import move_cache2move_cache()3 4import spaces5from diffusers import StableDiffusionPipeline6import torch7import gradio as gr8 9get_completion = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16)10get_completion = get_completion.to("cuda")11 12@spaces.GPU(duration=120)13def texttoImage(input):14 output = get_completion(input)15 return output.images[0]16 17demo = gr.Interface(fn=texttoImage,18 inputs=[gr.Textbox(label="Your prompt")],19 outputs=[gr.Image(label="Result")],20 title="Image Generation with Stable Diffusion",21 description="Generate any image with Stable Diffusion",22 allow_flagging="never",23 examples=["the spirit of a tamagotchi wandering in the city of Vienna",24 "a mecha robot in a favela"])25 26demo.launch()