import gradio as gr import cv2 from carPlate_recognize import car_plate_recognize def Car_segmentation(): def pridict(query_image=None): img_cvt = cv2.cvtColor(query_image, cv2.COLOR_BGR2RGB) plate, word_all = car_plate_recognize(img_cvt) return plate,word_all title = "

基于Opencv图像处理的车牌定位和分割

" description = "对输入的车牌进行车牌的定位与分割操作" examples = [['images/car.jpg'],['images/car.png'],['images/car_test.jpg']] with gr.Blocks() as demo: gr.Markdown(title) gr.Markdown(description) with gr.Row(): with gr.Column(scale=1): #with gr.Column(scale=2): img = gr.components.Image(label="图片") btn = gr.Button("点击定位与分割", ) with gr.Column(scale=1): out_1 = gr.components.Image(label="车牌定位:",height="auto") out_2 = gr.Gallery(label="车牌分割:",columns=[4], height="auto",object_fit="contain") inputs = [img] outputs = [out_1,out_2] btn.click(fn=pridict, inputs=inputs, outputs=outputs) gr.Examples(examples, inputs=inputs) return demo if __name__ == "__main__": with gr.TabbedInterface( [Car_segmentation()], ["Opencv车牌定位与分割"], ) as demo: demo.launch(show_api=False,inbrowser=False,)#auth=("admin", '1234')