sdxl-refiner / app.py
Lisandro's picture
feat: Update maximum value for strength slider in app.py
863a8cc
raw
history blame
2.21 kB
import os
import gradio as gr
from huggingface_hub import InferenceClient
client = InferenceClient()
from gradio_imageslider import ImageSlider
def refine_image(image, prompt, negative_prompt, num_inference_steps, guidance_scale, seed, strength):
refined_image = client.image_to_image(
image,
prompt=prompt,
negative_prompt=negative_prompt,
num_inference_steps=num_inference_steps,
guidance_scale=guidance_scale,
seed=seed,
model="stabilityai/stable-diffusion-xl-refiner-1.0",
strength=strength
)
return [image, refined_image]
with gr.Blocks() as demo:
with gr.Row():
with gr.Column():
image = gr.Image(type="filepath")
with gr.Accordion("Advanced Options", open=False):
prompt = gr.Textbox(lines=3, label="Prompt")
negative_prompt = gr.Textbox(lines=3, label="Negative Prompt")
strength = gr.Slider(
label="Strength",
minimum=0,
maximum=300,
step=0.01,
value=1
)
num_inference_steps = gr.Slider(
label="Inference steps",
minimum=3,
maximum=300,
step=1,
value=25
)
guidance_scale = gr.Slider(
label="Guidance scale",
minimum=0.0,
maximum=50.0,
step=0.1,
value=12
)
seed = gr.Slider(
label="Seed",
info="-1 denotes a random seed",
minimum=-1,
maximum=423538377342,
step=1,
value=-1
)
refine_btn = gr.Button("Refine")
with gr.Column():
output = ImageSlider(label="Before / After")
refine_btn.click(
refine_image,
inputs=[image, prompt, negative_prompt, num_inference_steps, guidance_scale, seed, strength],
outputs=output
)
demo.launch()