Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from diffusers import AutoPipelineForText2Image
|
2 |
+
import torch
|
3 |
+
import gradio as gr
|
4 |
+
from PIL import Image
|
5 |
+
import os, random
|
6 |
+
from diffusers.utils import load_image
|
7 |
+
from accelerate import Accelerator
|
8 |
+
|
9 |
+
accelerator = Accelerator()
|
10 |
+
|
11 |
+
def plex(prompt,neg_prompt):
|
12 |
+
pipe = accelerator.prepare(AutoPipelineForText2Image.from_pretrained("openskyml/overall-v1", torch_dtype=torch.float32, use_safetensors=True, safety_checker=False))
|
13 |
+
pipe = accelerator.prepare(pipe.to("cpu"))
|
14 |
+
image = pipe(prompt=prompt, negative_prompt=neg_prompt,num_inference_steps=10).images[0]
|
15 |
+
return image
|
16 |
+
|
17 |
+
iface = gr.Interface(fn=plex,inputs=[gr.Dropdown(gr.Textbox(label="Prompt"), gr.Textbox(label="negative_prompt", value="low quality, bad quality")],outputs=gr.Image(label="Generated Output Image"), title="Txt2Img_Overall_v1_SD",description="Running on cpu, very slow!")
|
18 |
+
iface.queue(max_size=1,api_open=False)
|
19 |
+
iface.launch(max_threads=1)
|