Spaces:
Runtime error
Runtime error
File size: 1,624 Bytes
fae8d2c 355e96e 2b36db2 fae8d2c 2b36db2 ff7e22a 2b36db2 355e96e fae8d2c 53df086 fae8d2c ff7e22a 05c44c6 c2927af fae8d2c 355e96e ff7e22a 355e96e fae8d2c 355e96e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
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):
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
with gr.Blocks() as demo:
image = gr.Image(type="filepath")
prompt = gr.Textbox(lines=3, label="Prompt")
negative_prompt = gr.Textbox(lines=3, label="Negative Prompt")
strength = gr.Slider(
label="Strength",
minimum=0,
maximum=3,
step=0.01,
value=1
)
num_inference_steps = gr.Slider(
label="Inference steps",
minimum=3,
maximum=150,
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")
output = gr.Image()
refine_btn.click(
refine_image,
inputs=[image, prompt, negative_prompt, num_inference_steps, guidance_scale, seed, strength],
outputs=output
)
demo.launch()
|