Overview

This is a memo of running NDL Classical Japanese OCR on an Amazon EC2 CPU environment. The advantage is that it can be run without preparing an expensive GPU environment, but please note that it takes about 30 seconds to 1 minute per image.

The following article was referenced when building this environment.

https://qiita.com/relu/items/e882e23a9bd07243211b

Instance

Select Ubuntu from Quick Start.

For the instance type, I recommend t2.medium or higher. Errors occurred with smaller instances.

Server Configuration

Log in via SSH and execute the following.

sssssspuuuuuuyddddddtoooooohoaaaaaanpppppp3tttttt--g---iimeyyynntssviiitteunnnaanpsssllvdtttllaaaaatlll--pelllyyp&blupp&uinyyibzttslgihhudlpood-1nnoe-33sm-.asep1pesi0tnap--t-vgideeaentlvvulpigbrgaldieb2-.y0-0
sourceapp/bin/activate
pgcviidiptnricdenllqsokutnoiaetrleelhnmtoetcn-prtus_sp:c.g/ltr/ixagtdiethpuibp.com/ndl-lab/ndlkotenocr_cli.git

Open requirements.txt and remove the version specification for scikit-image. Also add torch and torchvision.

clnnnaoppssltpmmdjwttlmalulpryccirammaihooidttmbeoyiigancdtwerrcbskpuntakphndleaeecck=o=ymcomiytsastsrlhh=r==evblt=gfs==e=v1t3=n-u-=bo===t=i.=.1tpfi1mr=02s2s2=6.ay=m.=m1..=.i.7.2tt=a7=e.22=3o1.62ih3g.3r3352.n1.oo.e3.s....0.4nn13=51021s=9#.=.==.241=46s.1.c1.6i92.k..0i11.t6-6image==0.16.2

Continue executing the following.

pipinstall-rrequirements.txt

Install mmcv-full and download pre-trained models. Prepare and execute a file like the following.

iiiptPooooooommmroRssssssspppirO.......oooncJsssssssrrrthEyyyyyyyttt(_CssssssstvTtttttttotjoe_eeeeeeesosrrDmmmmmmmroc,I(((((((cnhRffffff"h.c''''''w_u=pwcwccg_digdgddevaopeete_st{t{{rv.iPPPhsegnhRhRRtirestOtOOtotttJtJJpn=capEpEEs_wlsCsCC:_tdl:T:TT/)o(/_/__/r)m/D/DDdcmlIlIIlhcaRaRR..vb}b}}n_-././/d_fnsns'lvudrdr).ellclcgrl././os=gtgn.i=oeodjo1.x.lpn.jtj_/_5p_pka_./kop.3ddtisatae/p-tetnilfanasiissseitheeekf(ttkti/'t/i/_2+pn_nl5'sdrda8):lely5/kcko0/ooou9dtgtt8oene//wninRnsts&0leie&0okok0ainiu0do/on0.ccz0or&ri3p/&/p/etlfnruaumonylmczollrium/a/ptofbmmdu.ooelcddlloees/mlml.0/soz/m.dmidmzeopecild'fvpse)a/.lud-zsliPi.tspz.t{'ij/P)pp{RgcO-uJP-dEOaC{_TPev_RxeDOarIJm}REp/}CltTes_.rrDjccIph/Rg{t}"te/)oxsrtrc_chk/_onvtdeelrn_}sk/eoiktnied_nersxee.ckhoitg_mnlliatyio-ounnto//-''c))ache-dir')

For running on CPU, modify the device in config.yml.

ntkdeolccd'xsssabdtc_ohestaaacaeehknevc_vvvctvneofciokeeeecisctikcrodddphcekegpeet___t_ekpn_o:_epto_s:iospitnrocei_iean'hsekrmz'rnkttcrepe_pecetih_p'krnmt:pa__:pu:ioioyudpla'_czd:1'iaa't0reee0ntysh#.es_lT0#ghor:3csm:r_:ucEooouEot/'dgrd'edr':nsin_esidsdrtimlrterlceto:cerc_/didd:/knoe'tkodhnlsehotle::rxete_rctrenke'/_enso.stk.setreoekecxtkin/tei_st_n_leeksrakxoeeyittkao__eidulkn_itaosrn/yteegmoekc_ounioodts_gre/erndlmkeiesictrd_oi/nergomdlennolsci/d_/otmekngiolodnodstline/e_t/lknkimsosooo/tetndkeke/eoninmlts_soseeled/nkakedsiyilee_o_sckrul/oietatd-a_yretdcoorriouc-onntrrcgf_-or_ivbb-og1aehr..srodppetneyt-akr'hp-o_'rvkme3uop'-drveo3lc'.ejsosbolri'b'

Execution

Prepare the folder and images for processing.

mmmkvkddieirxra-m-ppplietn.mpjpup/tgo/uiitmnpgpuutt/img

Execute.

pythonmain.pyinferinputtmp/output

Summary

I hope this serves as a helpful reference for environments where inference time is not a critical concern.