Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import torch
|
| 3 |
+
from diffusers import DiffusionPipeline, AutoencoderKL
|
| 4 |
+
|
| 5 |
+
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
|
| 6 |
+
|
| 7 |
+
pipe = DiffusionPipeline.from_pretrained(
|
| 8 |
+
"stabilityai/stable-diffusion-xl-base-1.0",
|
| 9 |
+
vae=vae, torch_dtype=torch.float16, variant="fp16",
|
| 10 |
+
use_safetensors=True
|
| 11 |
+
)
|
| 12 |
+
|
| 13 |
+
# This is where you load your trained weights
|
| 14 |
+
pipe.load_lora_weights("victor/outicon")
|
| 15 |
+
|
| 16 |
+
pipe.to("cuda")
|
| 17 |
+
|
| 18 |
+
def infer (prompt):
|
| 19 |
+
image = pipe(prompt=prompt, num_inference_steps=50).images[0]
|
| 20 |
+
return image
|
| 21 |
+
|
| 22 |
+
css = """
|
| 23 |
+
#col-container {max-width: 780px; margin-left: auto; margin-right: auto;}
|
| 24 |
+
"""
|
| 25 |
+
with gr.Blocks() as demo:
|
| 26 |
+
with gr.Column(elem_id="col-container"):
|
| 27 |
+
prompt_in = gr.Textbox(label="Prompt")
|
| 28 |
+
submit_btn = gr.Button("Submit")
|
| 29 |
+
image_out = gr.Image(label="Image output")
|
| 30 |
+
|
| 31 |
+
submit_btn.click(
|
| 32 |
+
fn = infer,
|
| 33 |
+
inputs = [prompt_in],
|
| 34 |
+
outputs = [image_out]
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
demo.queue().launch()
|