Spaces:
Runtime error
Runtime error
sachin the king
commited on
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers.utils import move_cache
|
| 2 |
+
move_cache()
|
| 3 |
+
|
| 4 |
+
from diffusers import StableDiffusionPipeline
|
| 5 |
+
import torch
|
| 6 |
+
import gradio as gr
|
| 7 |
+
|
| 8 |
+
get_completion = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16)
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def texttoImage(input):
|
| 12 |
+
output = get_completion(input)
|
| 13 |
+
return output.images[0]
|
| 14 |
+
|
| 15 |
+
demo = gr.Interface(fn=texttoImage,
|
| 16 |
+
inputs=[gr.Textbox(label="Your prompt")],
|
| 17 |
+
outputs=[gr.Image(label="Result")],
|
| 18 |
+
title="Image Generation with Stable Diffusion",
|
| 19 |
+
description="Generate any image with Stable Diffusion",
|
| 20 |
+
allow_flagging="never",
|
| 21 |
+
examples=["the spirit of a tamagotchi wandering in the city of Vienna",
|
| 22 |
+
"a mecha robot in a favela"])
|
| 23 |
+
|
| 24 |
+
demo.launch()
|