Spaces:
Runtime error
Runtime error
File size: 2,444 Bytes
fae8d2c 355e96e 2b36db2 fae8d2c 2b36db2 5168bd5 f70d5f1 ff7e22a 5168bd5 ff7e22a f70d5f1 355e96e fae8d2c c53e7e5 a4cf9b8 1cadc23 a4cf9b8 1cadc23 a4cf9b8 1cadc23 863a8cc 1cadc23 a4cf9b8 1cadc23 a4cf9b8 1cadc23 a4cf9b8 c53e7e5 a4cf9b8 355e96e a4cf9b8 ff7e22a a4cf9b8 ff7e22a 355e96e 90d9148 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 66 67 68 69 70 |
import os
import gradio as gr
from huggingface_hub import InferenceClient
client = InferenceClient()
from gradio_imageslider import ImageSlider
def refine_image(image, model ,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=model,
strength=strength
)
return [image, refined_image]
with gr.Blocks() as demo:
with gr.Row():
with gr.Column():
refiner_image = gr.Image(type="filepath")
with gr.Accordion("Advanced Options", open=False):
refiner_prompt = gr.Textbox(lines=3, label="Prompt")
refiner_negative_prompt = gr.Textbox(lines=3, label="Negative Prompt")
refiner_strength = gr.Slider(
label="Strength",
minimum=0,
maximum=300,
step=0.01,
value=1
)
refiner_num_inference_steps = gr.Slider(
label="Inference steps",
minimum=3,
maximum=300,
step=1,
value=25
)
refiner_guidance_scale = gr.Slider(
label="Guidance scale",
minimum=0.0,
maximum=50.0,
step=0.1,
value=12
)
refiner_seed = gr.Slider(
label="Seed",
info="-1 denotes a random seed",
minimum=-1,
maximum=423538377342,
step=1,
value=-1
)
refiner_model = gr.Textbox(label="Model", value="stabilityai/stable-diffusion-xl-refiner-1.0")
refiner_btn = gr.Button("Refine")
with gr.Column():
refiner_output = ImageSlider(label="Before / After")
refiner_btn.click(
refine_image,
inputs=[refiner_image, refiner_model, refiner_prompt, refiner_negative_prompt, refiner_num_inference_steps, refiner_guidance_scale, refiner_seed, refiner_strength],
outputs=refiner_output
)
demo.launch(show_error=True)
|