# -*- encoding: utf-8 -*- # @Author: SWHL # @Contact: liekkaskono@163.com import gradio as gr from rapid_layout import ModelType, RapidLayout, RapidLayoutInput def get_layout_res(img_input, model_type, conf_thresh, iou_thresh): cfg = RapidLayoutInput( model_type=ModelType(model_type), conf_thresh=conf_thresh, iou_thresh=iou_thresh ) engine = RapidLayout(cfg=cfg) result = engine(img_input) vised_img = result.vis("layout_vis.jpg") return vised_img, f"{result.elapse:.4f}" custom_css = """ body {font-family: body {font-family: 'Helvetica Neue', Helvetica;} .gr-button {background-color: #4CAF50; color: white; border: none; padding: 10px 20px; border-radius: 5px;} .gr-button:hover {background-color: #45a049;} .gr-textbox {margin-bottom: 15px;} .example-button {background-color: #1E90FF; color: white; border: none; padding: 8px 15px; border-radius: 5px; margin: 5px;} .example-button:hover {background-color: #FF4500;} .tall-radio .gr-radio-item {padding: 15px 0; min-height: 50px; display: flex; align-items: center;} .tall-radio label {font-size: 16px;} .output-image, .input-image, .image-preview {height: 300px !important} """ with gr.Blocks(title="Rapid Layout", css="custom_css", theme=gr.themes.Soft()) as demo: gr.HTML( """