|
import gradio as gr |
|
from diffusers import DiffusionPipeline |
|
|
|
model_repo_id = "runwayml/stable-diffusion-v1-5" |
|
|
|
pipe = DiffusionPipeline.from_pretrained(model_repo_id) |
|
pipe.load_lora_weights("OVAWARE/plixel-minecraft") |
|
|
|
|
|
|
|
def infer( |
|
prompt |
|
): |
|
image = pipe( |
|
prompt=prompt |
|
).images[0] |
|
|
|
return image |
|
|
|
|
|
css = """ |
|
#col-container { |
|
margin: 0 auto; |
|
max-width: 640px; |
|
} |
|
""" |
|
|
|
with gr.Blocks(css=css) as demo: |
|
with gr.Column(elem_id="col-container"): |
|
gr.Markdown(" # Text-to-Image Gradio Template") |
|
|
|
with gr.Row(): |
|
prompt = gr.Text( |
|
label="Prompt", |
|
show_label=False, |
|
max_lines=1, |
|
placeholder="Enter your prompt", |
|
container=False, |
|
) |
|
|
|
run_button = gr.Button("Run", scale=0, variant="primary") |
|
|
|
result = gr.Image(label="Result", show_label=False) |
|
|
|
gr.on( |
|
triggers=[run_button.click, prompt.submit], |
|
fn=infer, |
|
inputs=[ |
|
prompt |
|
], |
|
outputs=[result], |
|
) |
|
|
|
if __name__ == "__main__": |
|
demo.launch() |
|
|