File size: 1,028 Bytes
d4d2f79
 
 
 
 
 
 
 
 
 
 
7044a31
d4d2f79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os 
import huggingface_hub as hf_hub
import gradio as gr

client = hf_hub.InferenceClient(token = os.environ['HF_TOKEN'])

def image_interface(img, prompt, negative_prompt, guidance_scale, steps):
    response = client.image_to_image(
        image = img, 
        prompt = prompt,
        negative_prompt = negative_prompt,
        model = 'stabilityai/stable-diffusion-xl-base-1.0',
        guidance_scale = guidance_scale,
        num_inference_steps = steps, 
    )

    return response

app = gr.Interface(
    fn = image_interface, 
    inputs = [
        gr.Image(type = 'filepath'),
        gr.Textbox(label = 'Prompt'), 
        gr.Textbox(label = 'Negative Prompt'), 
        gr.Slider(minimum = 1, maximum = 30, value = 7, step = 0.5, label = 'Guidance Scale', show_label = True),
        gr.Slider(minimum = 10, maximum = 100, value = 50, step = 10, label = 'Number of Inference Steps', show_label = True)
    ], 
    outputs = 'image', 
    title = 'Image to Image',
    description = 'Vinay Kumar Thakur'
)