sneedium/captcha_pixelplanet
1
1 2import os3os.system('pip install --upgrade gdown')4import gdown5gdown.download(id='1C3XPT8s-ONt88vlNykTkGt8c8frfB9U_', output='workdir.zip')6os.system('unzip workdir.zip')7 8 9import glob10import gradio as gr11from demo import get_model, preprocess, postprocess, load12from utils import Config, Logger, CharsetMapper13 14config = Config('configs/train_iternet.yaml')15config.model_vision_checkpoint = None16model = get_model(config)17model = load(model, 'workdir/train-iternet/best-train-iternet.pth')18charset = CharsetMapper(filename=config.dataset_charset_path, max_length=config.dataset_max_length + 1)19 20def process_image(image):21 img = image.convert('RGB')22 img = preprocess(img, config.dataset_image_width, config.dataset_image_height)23 res = model(img)24 return postprocess(res, charset, 'alignment')[0][0]25 26title = "Made with IterNet"27description = "I hate captchas"28 29iface = gr.Interface(fn=process_image, 30 inputs=gr.inputs.Image(type="pil"), 31 outputs=gr.outputs.Textbox(),32 title=title,33 description=description,34 examples=glob.glob('figs_captchas/*.jpg'))35 36iface.launch(debug=True)