Important Usage Notice

The system introduced in this article may place load on external servers. Please exercise caution when using it.

  • Server Load: Parallel requests place load on target servers
  • DoS Attack Risk: Large numbers of simultaneous accesses may be mistaken for DoS attacks
  • Recommended Approach: It is recommended to download images locally in advance and run only the OCR processing in parallel
  • Check Terms of Use: Always check the terms of use for target servers and obtain prior permission if necessary
  • Appropriate Rate Limiting: For production use, conservative concurrency settings (around 5-10 parallel) are strongly recommended
  • Responsible Usage: Be considerate of server administrators and other users

This article is a record of a technical proof of concept. We ask readers to use it responsibly.

Introduction

This article introduces a case study of building a scalable OCR processing system on Azure Container Apps, leveraging NDL Classical Japanese OCR Lite developed by the National Diet Library (NDL). We explain the design and implementation of a system that achieves pay-as-you-go billing and auto-scaling through cloud-native architecture.

System Overview

Architecture

IIIFA(z0u-r3e0Cont)ainerAppsNDLOCRTEIXML

Key Components

  • OCR Engine: NDL Classical Japanese OCR Lite (specialized for Japanese classical texts)
  • Infrastructure: Azure Container Apps (serverless containers)
  • API Design: REST API (Image URL to OCR result)
  • Output Format: TEI P5 compliant XML
  • Scaling: Automatic scaling based on demand

Features of NDL Classical Japanese OCR Lite

OCR Optimized for Japanese Classical Texts

  • Vertical Layout Support: Vertical text document structures specific to classical texts
  • Reading Order Optimization: Japanese reading order from right to left, top to bottom
  • Classical Character Recognition: Support for cursive script and variant kana
  • Lightweight Implementation: Cloud deployment ready through Docker containerization

Reasons for Choosing Azure Container Apps

Benefits of Serverless Containers

#scammcliaoenxo:RRleedppollwiinccPaaessr::io03d0:300###5::0

Cost Optimization

  • Pay-as-you-go: Charged only for what you use
  • 0 Replicas: Completely zero cost when idle
  • Auto-scaling: Resource adjustment based on demand

System Implementation

Server-Side Implementation

#fffaa@crrrppalFooopipalmmmisa==.sdsffsreklliFAoIfaamlpum+sspaitagi#rrkkls(egemeeN_eka(etaNstDir_(p'O(gDuuLmeo_p/CseLlrpsc_,aRe_tnOotrnp(luOCrx_adiRfrC=rRtsmo/e)lReieecis:osFmr_=mo=culpv_'aurlaoi)/grr_tsrcdeceskteo'eqe,c))urAis:evrpm/sieip'tcq,o).eura.eRtrpsegrtsOso,oC.cuRgejrSesscetsoer(_nv'siiiifcmnyeagglee__uirmla'g)e(image_url)

Reading Order Algorithm

defs"ro"er"ttu_r-ljnliainpsneaoe[nr["et"bsebbedbo_(oxrlx"ei"]a"n][d"e[1i"s0]n,]g,_koery##d=elxyra(mlbidnaesl)i:ne:(

TEI XML Output

<<?T/xE<<<TmIt/f/t/Ele<ta<fe<tIxif/ecs/axb/e>vmHi<<fisu<scto<bxelelt/r/iHirzus>dd/otrnaei<te<<rlemforiyi<<dd>ssdDttisrn/eeaianfm>vpliyi=eelitpeaNnsDdlceaibbv>o"rsetlSsmDapeeeeclt>nh>cSletpeLmSsr>xleeynn=t>teSm>etc>xmr>>p=="tm>ttAr>m>mlxe""1ptm>uetl:==11.:>ttfO>:i""".0/<>o=Cid3t1"//m"Rd=7rf"wtah="2aaewittL"z7nccnwtetiso"ssoc.ldptunc=roteserelr"rde>T:f-ri#eiir/a1ypssn-a/c-=tupgcnge1"ir==.si-"2of""oct19na#Urrh"u2"czTgiu>l4>eoF/pbx"-n-nt.=1e8sic"c"-"/oo3e/1?1nm3r>->.<9t10n1=""rd"">el0cs-u.epll7r>ay9tb=9=/"""n1/hd1>il4gk1ho""t/e>nocr-lite">

Processing Results Example

Small-Scale Test Processing (Kiritsubo)

  • Target: “Kiritsubo” held by the University of Tokyo
  • Pages: 32 pages
  • Processing Time: Approximately 30 seconds
  • Success Rate: 100%
  • Concurrency: 10 parallel
  • Cost: Approximately $0.05

Performance Characteristics

===1$1/.502.200/1000

Technical Features of the System

1. Cold Start Handling

async"f"od"refatetrxptycre:eomirpicpfetfettsau(asitwarHtr_ntawnTtaweiaTeiirmtiaPmstap_twEpehnttart_giairer"e>msto=e"(eyr=t"m0no,ra:=ccmyxirTa(_2o_ixir.rm_meseeratlqoegreuutei(eetr_eapsEiust(trertw(rsl+eaio:,mimr1pta)m)t_ga:teax-i_s_mur1eree))l:t)ries=3):

2. Externalized Configuration

#ODDDCEEERFFF_AAAAUUUPLLLITTT____UMCORAOULXNT=_FPhCIUtODTtNE_pCNFsUCO:RER/R_M/ETAyNHToTR=u=Exr1Sm-0HloOcLrD-=s0e.r3vice.azurecontainerapps.io

3. Swagger UI Integration

#apAiPI=vtddeieoArtscpslc=iier'(o=i/an'pdp=Ntop'Dic,1Los.n/0=''',OCRAPI'O,CRAPI',

Deployment

Azure Container Apps Deployment

#azc----------onreitimmcmnaenmaniapetmsvargnxumaeoiggr--oiureeerr2rnorotsee.yeccnr-spp0rremepll4a--egoeii\Gpsgnirxccipertsttaarotesscvucr8rripoy0n03ecn.a0aertaltgaze-iu\nr\ceerrc-r\e.nivo/ocr-app:latest\

Dockerization

#scammcliaoenxo:RRleedppollwiinccPaaessr::io03d0:300###5::0

0

Operations and Monitoring

Performance Metrics

  • Response Time: Average 2-3 seconds/image
  • Throughput: 10-15 images/second (with 20 replicas)
  • Success Rate: Over 99%
  • Cost Efficiency: $0 when idle, charged only during processing

Log Monitoring

#scammcliaoenxo:RRleedppollwiinccPaaessr::io03d0:300###5::0

1

Future Prospects

Technical Improvements

  • Image Caching: Reduction of duplicate processing
  • Batch Processing: Efficient large-scale processing
  • GPU Support: Faster OCR processing
  • Enhanced Metrics: Detailed performance analysis

Application Possibilities

  • Digital Archives: Utilization in libraries and museums
  • Research Support: Digitization for humanities research
  • Education: Creating teaching materials from classical literature
  • Cultural Preservation: Digital preservation of valuable materials

Summary

By combining NDL Classical Japanese OCR Lite with Azure Container Apps, we were able to build a classical text OCR system that achieves both cost efficiency and scalability. The serverless architecture enables pay-as-you-go billing and auto-scaling, making it practical as a digital humanities tool.

Key Points

  • Cost Optimization: Charged only during use
  • Auto-scaling: Resource adjustment based on demand
  • TEI P5 Compliant: Standardized XML output
  • Classical Text Specialized: OCR optimized for Japanese classical texts
  • API Design: Simple and extensible design

This system was developed as a technical proof of concept. For production use, please give sufficient consideration to the load on target servers and comply with appropriate rate limiting and terms of use.

References