HelloSun's picture
Update app.py
5effd4d verified
raw
history blame
1.95 kB
import gradio as gr
import numpy as np
import random
from diffusers import DiffusionPipeline
from optimum.intel.openvino import OVStableDiffusionPipeline
import torch
model_id = "helenai/Linaqruf-anything-v3.0-ov"
pipe = OVStableDiffusionPipeline.from_pretrained(model_id, compile=False)
pipe.reshape( batch_size=1, height=256, width=256, num_images_per_prompt=1)
pipe.compile()
def infer(prompt,negative_prompt):
image = pipe(
prompt = prompt,
negative_prompt = negative_prompt,
width = 256,
height = 256,
).images[0]
return image
examples = [
"A cute kitten, Japanese cartoon style.",
"A sweet family, dad stands next to mom, mom holds baby girl.",
"A delicious ceviche cheesecake slice",
]
css="""
#col-container {
margin: 0 auto;
max-width: 520px;
}
"""
power_device = "CPU"
with gr.Blocks(css=css) as demo:
with gr.Column(elem_id="col-container"):
gr.Markdown(f"""
# Linaqruf-anything-v3.0-ov 256x256
Currently running on {power_device}.
""")
with gr.Row():
prompt = gr.Text(
label="Prompt",
show_label=False,
max_lines=1,
placeholder="Enter your prompt",
container=False,
)
with gr.Row():
negative_prompt = gr.Text(
label="negative_prompt",
show_label=False,
max_lines=1,
placeholder="Enter your prompt",
container=False,
)
run_button = gr.Button("Run", scale=0)
result = gr.Image(label="Result", show_label=False)
gr.Examples(
examples = examples,
inputs = [prompt]
)
run_button.click(
fn = infer,
inputs = [prompt,negative_prompt],
outputs = [result]
)
demo.queue().launch()