Spaces:
Sleeping
Sleeping
Download app.py from UrielWerneck/ClearVision: direct link, hf CLI and curl.
- Browser
- Download file 2.26 kB
-
https://huggingface.co/spaces/UrielWerneck/ClearVision/resolve/main/app.py
- Command line
-
hf download hf://spaces/UrielWerneck/ClearVision/app.py
-
curl -L -o app.py https://huggingface.co/spaces/UrielWerneck/ClearVision/resolve/main/app.py
2.26 kB
| import gradio as gr | |
| import numpy as np | |
| import os | |
| from utils import process_image, clear_image | |
| model_names = [i.removesuffix('.pt') for i in os.listdir('./models')] | |
| modes = ['Shadow Removal', '1º Segmentation Algorithm', '2º Segmentation Algorithm'] + model_names | |
| initial_mode = modes[0] | |
| if 'Classificator_YOLOv8n_Refined (16 epochs)' in model_names: | |
| initial_mode = 'Classificator_YOLOv8n_Refined (16 epochs)' | |
| with gr.Blocks() as demo: | |
| with gr.Column(): | |
| with gr.Row(): | |
| with gr.Column(): | |
| dropdown = gr.Dropdown( | |
| choices=modes, value=initial_mode, | |
| interactive=True, | |
| show_label=False | |
| ) | |
| with gr.Column(): | |
| pass | |
| with gr.Column(): | |
| pass | |
| with gr.Column(): | |
| pass | |
| with gr.Row(): | |
| input_box = gr.Image( | |
| label='Input Image', | |
| elem_id='input_box', | |
| sources=['upload'], | |
| type='numpy', | |
| show_fullscreen_button=True | |
| ) | |
| output_box = gr.Image( | |
| label='Output Image', | |
| elem_id='output_box', | |
| sources=['upload'], | |
| type='pil', | |
| interactive=False, | |
| show_download_button=True, | |
| show_fullscreen_button=True, | |
| show_share_button=False | |
| ) | |
| with gr.Row(): | |
| with gr.Column(): | |
| with gr.Row(): | |
| submit_btn = gr.Button( | |
| "Submit", | |
| elem_id='submit_btn', | |
| variant='primary' | |
| ) | |
| clear_btn = gr.Button( | |
| "Clear", | |
| elem_id='clear_btn' | |
| ) | |
| with gr.Column(): | |
| pass | |
| # button events | |
| submit_btn.click( | |
| fn=process_image, | |
| inputs=[input_box, dropdown], | |
| outputs=output_box | |
| ) | |
| clear_btn.click( | |
| inputs=None, | |
| outputs=[input_box, output_box], | |
| fn=lambda: [clear_image(), clear_image()] | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() |