Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from PIL import Image
|
| 4 |
+
import PIL.Image
|
| 5 |
+
from diffusers import StableDiffusionPipeline
|
| 6 |
+
from diffusers.utils import load_image
|
| 7 |
+
from accelerate import Accelerator
|
| 8 |
+
from optimum.onnxruntime import ORTStableDiffusionPipeline
|
| 9 |
+
accelerator = Accelerator(cpu=True)
|
| 10 |
+
pipe = accelerator.prepare(ORTStableDiffusionPipeline.from_pretrained("JoPmt/AbsoluteReality-onnx"))
|
| 11 |
+
pipe.to("cpu")
|
| 12 |
+
def plex(prompt,neg_prompt,stips,scaly):
|
| 13 |
+
apol=[]
|
| 14 |
+
image = pipe(prompt=prompt, negative_prompt=neg_prompt, num_inference_steps=stips, guidance_scale=scaly)
|
| 15 |
+
for a, imze in enumerate(image["images"]):
|
| 16 |
+
apol.append(imze)
|
| 17 |
+
return apol
|
| 18 |
+
|
| 19 |
+
iface = gr.Interface(fn=plex,inputs=[gr.Textbox(label="Prompt"), gr.Textbox(label="negative_prompt", value="low quality, bad quality"), gr.Slider(label="num inference steps",minimum=1,step=1,maximum=30,value=25), gr.Slider(label="guidance_scale",minimum=1,step=1,maximum=10,value=7)],outputs=gr.Gallery(label="Generated Output Image", columns=1),description="Running on cpu, very slow! by JoPmt.")
|
| 20 |
+
iface.queue(max_size=1,api_open=False)
|
| 21 |
+
iface.launch(max_threads=1)
|