File size: 702 Bytes
96dad42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import gradio as gr
from PIL import Image

def build_ui(try_on_fn, styles):
    with gr.Blocks(title="Salon Hairstyle Virtual Try-On") as demo:
        gr.Markdown("## 💇‍♀️ Salon Hairstyle Virtual Try-On")
        with gr.Row():
            with gr.Column():
                inp = gr.Image(type="numpy", label="Upload or capture", sources=["upload", "webcam"])
                style = gr.Dropdown(choices=styles, label="Choose a hairstyle", interactive=True)
                btn = gr.Button("Try On")
            with gr.Column():
                out = gr.Image(type="numpy", label="Result", interactive=False)
        btn.click(fn=try_on_fn, inputs=[inp, style], outputs=out)
    return demo