Spaces:
Build error
Build error
| import os | |
| os.system('pip install --upgrade --no-cache-dir gdown') | |
| os.system('gdown -O ./output/ctw/ 1nhT7yuqJ8V8vfoJdI0Qn6notmoLFRrmm') | |
| os.system('pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"') | |
| os.system('python setup.py build develop --user') | |
| #os.system('pip install git+https://github.com/Cyril-Sterling/ContourNet') | |
| import cv2 | |
| import pandas as pd | |
| import gradio as gr | |
| from tools.demo import TextDemo | |
| from maskrcnn_benchmark.config import cfg | |
| def infer(filepath): | |
| cfg.merge_from_file('./configs/ctw/r50_baseline.yaml') | |
| # manual override some options | |
| cfg.merge_from_list(["MODEL.DEVICE", "cpu"]) | |
| text_demo = TextDemo( | |
| cfg, | |
| min_image_size=800, | |
| confidence_threshold=0.7, | |
| output_polygon=True | |
| ) | |
| image = cv2.imread(filepath) | |
| result_polygons, result_masks = text_demo.run_on_opencv_image(image) | |
| image = text_demo.visualization(image, result_polygons, result_masks) | |
| cv2.imwrite('result.jpg', image) | |
| return 'result.jpg'#, pd.DataFrame(result_words) | |
| iface = gr.Interface( | |
| fn=infer, | |
| title="张博强毕设展示", | |
| description="毕设题目:自然场景中任意形状文字的检测与识别\n目前进度:检测", | |
| inputs=[gr.inputs.Image(label="image", type="filepath")], | |
| outputs=[gr.outputs.Image()], #, gr.outputs.Dataframe(headers=['word'])], | |
| #examples=['example1.jpg', 'example2.jpg', 'example3.jpg'], | |
| #article="<a href=\"https://github.com/MhLiao/MaskTextSpotterV3\">GitHub Repo</a>", | |
| ).launch(enable_queue=True) |