CoolFace
Apppublic

mkill33/blue_HALO

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
0likes
app.py140 linesDownload Raw Back to root
1import time2 3import gradio as gr4from gradio.themes.utils.theme_dropdown import create_theme_dropdown5 6dropdown, js = create_theme_dropdown()7 8with gr.Blocks(theme='mkill33/blue_HALO') as demo:9    with gr.Row(equal_height=True):10        with gr.Column(scale=10):11            gr.Markdown(12                """13                # Theme preview: `blue_HALO`14                To use this theme, set `theme='mkill33/blue_HALO'` in `gr.Blocks()` or `gr.Interface()`.15                You can append an `@` and a semantic version expression, e.g. @>=1.0.0,<2.0.0 to pin to a given version16                of this theme.17                """18            )19        with gr.Column(scale=3):20            with gr.Group():21                dropdown.render()22                toggle_dark = gr.Button(value="Toggle Dark")23 24    dropdown.change(None, dropdown, None, js=js)25    toggle_dark.click(26        None,27        js="""28        () => {29            document.body.classList.toggle('dark');30        }31        """,32    )33 34    name = gr.Textbox(35        label="Name",36        info="Full name, including middle name. No special characters.",37        placeholder="John Doe",38        value="John Doe",39        interactive=True,40    )41 42    with gr.Row():43        slider1 = gr.Slider(label="Slider 1")44        slider2 = gr.Slider(label="Slider 2")45    gr.CheckboxGroup(["A", "B", "C"], label="Checkbox Group")46 47    with gr.Row():48        with gr.Column(variant="panel", scale=1):49            gr.Markdown("## Panel 1")50            radio = gr.Radio(51                ["A", "B", "C"],52                label="Radio",53                info="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",54            )55            drop = gr.Dropdown(["Option 1", "Option 2", "Option 3"], show_label=False)56            drop_2 = gr.Dropdown(57                ["Option A", "Option B", "Option C"],58                multiselect=True,59                value=["Option A"],60                label="Dropdown",61                interactive=True,62            )63            check = gr.Checkbox(label="Go")64        with gr.Column(variant="panel", scale=2):65            img = gr.Image(66                "https://i.ibb.co/WvcLftqx/ring.png",67                label="Image",68                height=320,69            )70            with gr.Row():71                go_btn = gr.Button("Go", variant="primary")72                clear_btn = gr.Button("Clear", variant="secondary")73 74                def go(*_args):75                    time.sleep(3)76                    return "https://i.ibb.co/WvcLftqx/ring.png"77 78                go_btn.click(go, [radio, drop, drop_2, check, name], img, api_name="go")79 80                def clear():81                    time.sleep(0.2)82 83                clear_btn.click(clear, None, img)84 85            with gr.Row():86                btn1 = gr.Button("Button 1", size="sm")87                btn2 = gr.UploadButton(size="sm")88                stop_btn = gr.Button("Stop", size="sm", variant="stop")89 90    with gr.Row():91        gr.Dataframe(value=[[1, 2, 3], [4, 5, 6], [7, 8, 9]], label="Dataframe")92        gr.JSON(93            value={"a": 1, "b": 2, "c": {"test": "a", "test2": [1, 2, 3]}}, label="JSON"94        )95        gr.Label(value={"cat": 0.7, "dog": 0.2, "fish": 0.1})96        gr.File()97    with gr.Row():98        gr.ColorPicker()99        gr.Video("https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4")100        gr.Gallery(101            [102                (103                    "https://gradio-static-files.s3.us-west-2.amazonaws.com/lion.jpg",104                    "lion",105                ),106                (107                    "https://gradio-static-files.s3.us-west-2.amazonaws.com/logo.png",108                    "logo",109                ),110                (111                    "https://gradio-static-files.s3.us-west-2.amazonaws.com/tower.jpg",112                    "tower",113                ),114            ],115            height=200,116        )117 118    with gr.Row():119        with gr.Column(scale=2):120            chatbot = gr.Chatbot([("Hello", "Hi")], label="Chatbot")121            chat_btn = gr.Button("Add messages")122 123            chat_btn.click(124                lambda history: history125                + [["How are you?", "I am good."]]126                + (time.sleep(2) or []),127                chatbot,128                chatbot,129            )130        with gr.Column(scale=1):131            with gr.Accordion("Advanced Settings"):132                gr.Markdown("Hello")133                gr.Number(label="Chatbot control 1")134                gr.Number(label="Chatbot control 2")135                gr.Number(label="Chatbot control 3")136 137 138if __name__ == "__main__":139    demo.queue().launch()140