init commit
Browse files
app.py
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from PIL import Image
|
| 2 |
+
from transformers import DonutProcessor, VisionEncoderDecoderModel
|
| 3 |
+
import torch
|
| 4 |
+
import re
|
| 5 |
import gradio as gr
|
| 6 |
+
from diffusers import AutoPipelineForText2Image
|
| 7 |
+
import torch
|
| 8 |
|
| 9 |
+
pipeline_text2image = AutoPipelineForText2Image.from_pretrained("stabilityai/sdxl-turbo", torch_dtype=torch.float16, variant="fp16")
|
| 10 |
+
pipeline_text2image = pipeline_text2image.to("cuda")
|
| 11 |
|
| 12 |
+
|
| 13 |
+
def text2img(prompt = "A cinematic shot of a baby racoon wearing an intricate italian priest robe.",guidance_scale=0.0, num_inference_steps=1):
|
| 14 |
+
image = pipeline_text2image(prompt=prompt, guidance_scale=guidance_scale, num_inference_steps=num_inference_steps).images[0]
|
| 15 |
+
return image
|
| 16 |
+
|
| 17 |
+
gradio_app_text2img = gr.Interface(
|
| 18 |
+
fn=text2img,
|
| 19 |
+
inputs=[
|
| 20 |
+
gr.Text(),
|
| 21 |
+
gr.Slider(0.0, 10.0, value=1,step=0.1),
|
| 22 |
+
gr.Slider(0.0, 10.0, value=1,step=1)
|
| 23 |
+
],
|
| 24 |
+
outputs="image",
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
demo = gr.TabbedInterface([gradio_app_text2img], ["text2img"])
|
| 29 |
+
|
| 30 |
+
if __name__ == "__main__":
|
| 31 |
+
demo.launch()
|