@@ -18,7 +18,7 @@ from PIL import Image
18
18
img = Image.open(' test.jpg' )
19
19
print ((await winocr.recognize_pil(img, ' ja' )).text)
20
20
```
21
- ![ ] ( https://camo.qiitausercontent .com/63785b963fa5d67e9f2be1ac9e4953579f4c2584/68747470733a2f2f71696974612d696d6167652d73746f72652e73332e61702d6e6f727468656173742d312e616d617a6f6e6177732e636f6d2f302f3230383336332f33373061353463382d623536612d353362382d366632352d3634333363313630383866612e706e67 )
21
+ ![ ] ( https://camo.githubusercontent .com/4e68db4fc3106c03e9919eb4391ce7548c1321429f9dc1a95a6937f51f01d5f6/68747470733a2f2f63616d6f2e716969746175736572636f6e74656e742e636f6d2f363337383562393633666135643637653966326265316163396534393533353739663463323538342f36383734373437303733336132663266373136393639373436313264363936643631363736353264373337343666373236353265373333333265363137303264366536663732373436383635363137333734326433313265363136643631376136663665363137373733326536333666366432663330326633323330333833333336333332663333333733303631333533343633333832643632333533363631326433353333363233383264333636363332333532643336333433333333363333313336333033383338363636313265373036653637 )
22
22
23
23
## OpenCV
24
24
@@ -29,7 +29,7 @@ import cv2
29
29
img = cv2.imread(' test.jpg' )
30
30
print ((await winocr.recognize_cv2(img, ' ja' )).text)
31
31
```
32
- ![ ] ( https://camo.qiitausercontent .com/ad91376e61b0e32a243fdc92a4586e87c8f683ba/68747470733a2f2f71696974612d696d6167652d73746f72652e73332e61702d6e6f727468656173742d312e616d617a6f6e6177732e636f6d2f302f3230383336332f65383031336338362d613833322d393837632d353763382d3135383536356634313034322e706e67 )
32
+ ![ ] ( https://camo.githubusercontent .com/fbbc81dd9fb138032625585dd3cd41a4b14b14621be77c11a15ea8949a3cc8a3/68747470733a2f2f63616d6f2e716969746175736572636f6e74656e742e636f6d2f616439313337366536316230653332613234336664633932613435383665383763386636383362612f36383734373437303733336132663266373136393639373436313264363936643631363736353264373337343666373236353265373333333265363137303264366536663732373436383635363137333734326433313265363136643631376136663665363137373733326536333666366432663330326633323330333833333336333332663635333833303331333336333338333632643631333833333332326433393338333736333264333533373633333832643331333533383335333633353636333433313330333433323265373036653637 )
33
33
34
34
## Connect to local runtime on Colaboratory
35
35
@@ -50,7 +50,7 @@ winocr_serve
50
50
``` bash
51
51
curl localhost:8000? lang=ja --data-binary @test.jpg
52
52
```
53
- ![ ] ( https://camo.qiitausercontent .com/9dcb18830efe482d9bbb1c8a90d80205f71112ed/68747470733a2f2f71696974612d696d6167652d73746f72652e73332e61702d6e6f727468656173742d312e616d617a6f6e6177732e636f6d2f302f3230383336332f66643138343566632d653634372d306437662d353336652d3634653363303263633861312e706e67 )
53
+ ![ ] ( https://camo.githubusercontent .com/658ff5e7ff505281fc464f642579ab8dac1a7e9120a0345c0eeaf0f46995c404/68747470733a2f2f63616d6f2e716969746175736572636f6e74656e742e636f6d2f396463623138383330656665343832643962626231633861393064383032303566373131313265642f36383734373437303733336132663266373136393639373436313264363936643631363736353264373337343666373236353265373333333265363137303264366536663732373436383635363137333734326433313265363136643631376136663665363137373733326536333666366432663330326633323330333833333336333332663636363433313338333433353636363332643635333633343337326433303634333736363264333533333336363532643336333436353333363333303332363336333338363133313265373036653637 )
54
54
55
55
### Python
56
56
@@ -61,7 +61,7 @@ bytes = open('test.jpg', 'rb').read()
61
61
requests.post(' http://localhost:8000/?lang=ja' , bytes ).json()[' text' ]
62
62
```
63
63
64
- ![ ] ( https://camo.qiitausercontent .com/04853be7fa2c389b3921ae4a098f1e41abab1a67/68747470733a2f2f71696974612d696d6167652d73746f72652e73332e61702d6e6f727468656173742d312e616d617a6f6e6177732e636f6d2f302f3230383336332f64373162333531362d326466652d616439312d626661352d6634376637623836633263632e706e67 )
64
+ ![ ] ( https://camo.githubusercontent .com/fb338aadf3f057e14c4b6474f4802b6958f9264aff634fdf22d7d5b321747bd5/68747470733a2f2f63616d6f2e716969746175736572636f6e74656e742e636f6d2f303438353362653766613263333839623339323161653461303938663165343161626162316136372f36383734373437303733336132663266373136393639373436313264363936643631363736353264373337343666373236353265373333333265363137303264366536663732373436383635363137333734326433313265363136643631376136663665363137373733326536333666366432663330326633323330333833333336333332663634333733313632333333353331333632643332363436363635326436313634333933313264363236363631333532643636333433373636333736323338333636333332363336333265373036653637 )
65
65
66
66
You can run OCR with the Colaboratory runtime with ` ./ngrok http 8000 `
67
67
@@ -75,7 +75,7 @@ buf = BytesIO()
75
75
img.save(buf, format = ' JPEG' )
76
76
requests.post(' https://15a5fabf0d78.ngrok.io/?lang=ja' , buf.getvalue()).json()[' text' ]
77
77
```
78
- ![ ] ( https://camo.qiitausercontent .com/ee8498f92eef03632bb0d3abb26de1269970900c/68747470733a2f2f71696974612d696d6167652d73746f72652e73332e61702d6e6f727468656173742d312e616d617a6f6e6177732e636f6d2f302f3230383336332f33393064393539372d316435352d356431632d383532302d3135633461383131386464642e706e67 )
78
+ ![ ] ( https://camo.githubusercontent .com/61adc7eb41c54bedfd19ab3ce2e55dd7b0c865a22c0ab787439296a0afc75d7a/68747470733a2f2f63616d6f2e716969746175736572636f6e74656e742e636f6d2f656538343938663932656566303336333262623064336162623236646531323639393730393030632f36383734373437303733336132663266373136393639373436313264363936643631363736353264373337343666373236353265373333333265363137303264366536663732373436383635363137333734326433313265363136643631376136663665363137373733326536333666366432663330326633323330333833333336333332663333333933303634333933353339333732643331363433353335326433353634333136333264333833353332333032643331333536333334363133383331333133383634363436343265373036653637 )
79
79
80
80
``` python
81
81
import cv2
@@ -85,7 +85,7 @@ img = cv2.imread('test.jpg')
85
85
# Preprocessing
86
86
requests.post(' https://15a5fabf0d78.ngrok.io/?lang=ja' , cv2.imencode(' .jpg' , img)[1 ].tobytes()).json()[' text' ]
87
87
```
88
- ![ ] ( https://camo.qiitausercontent .com/e5f4e0bf0538b851ddd525879600a712a3ce978a/68747470733a2f2f71696974612d696d6167652d73746f72652e73332e61702d6e6f727468656173742d312e616d617a6f6e6177732e636f6d2f302f3230383336332f39613364613534612d363664362d396138322d373038662d6464343763323832313930302e706e67 )
88
+ ![ ] ( https://camo.githubusercontent .com/a303dc95a4df7dbef67143a983b7792172b3d1b1837b0be7e7fa3c8a92b728d7/68747470733a2f2f63616d6f2e716969746175736572636f6e74656e742e636f6d2f653566346530626630353338623835316464643532353837393630306137313261336365393738612f36383734373437303733336132663266373136393639373436313264363936643631363736353264373337343666373236353265373333333265363137303264366536663732373436383635363137333734326433313265363136643631376136663665363137373733326536333666366432663330326633323330333833333336333332663339363133333634363133353334363132643336333636343336326433393631333833323264333733303338363632643634363433343337363333323338333233313339333033303265373036653637 )
89
89
90
90
### JavaScript
91
91
@@ -122,7 +122,7 @@ pprint.pprint({
122
122
} for line in result.lines]
123
123
})
124
124
```
125
- ![ ] ( https://camo.qiitausercontent .com/cea9240789734fc27486c62efec796b6397d7d35/68747470733a2f2f71696974612d696d6167652d73746f72652e73332e61702d6e6f727468656173742d312e616d617a6f6e6177732e636f6d2f302f3230383336332f63663534376231312d313038642d636335332d653863332d3136663337656432386163352e706e67 )
125
+ ![ ] ( https://camo.githubusercontent .com/c0715ad500369e6b1b498293335bd8844e38baee7ead335a7047128947f0b9b6/68747470733a2f2f63616d6f2e716969746175736572636f6e74656e742e636f6d2f636561393234303738393733346663323734383663363265666563373936623633393764376433352f36383734373437303733336132663266373136393639373436313264363936643631363736353264373337343666373236353265373333333265363137303264366536663732373436383635363137333734326433313265363136643631376136663665363137373733326536333666366432663330326633323330333833333336333332663633363633353334333736323331333132643331333033383634326436333633333533333264363533383633333332643331333636363333333736353634333233383631363333353265373036653637 )
126
126
127
127
# Language installation
128
128
``` powershell
@@ -177,19 +177,19 @@ images = [Image.open('testocr.png') for i in range(1000)]
177
177
### 1 core(elapsed 48s)
178
178
179
179
The CPU is not used up.
180
- ![ ] ( https://camo.qiitausercontent .com/c9c991eb1473137866fb8693eb1d4bef7b6addfc/68747470733a2f2f71696974612d696d6167652d73746f72652e73332e61702d6e6f727468656173742d312e616d617a6f6e6177732e636f6d2f302f3230383336332f66613263326635322d396638362d643435322d643263372d6162336330653061663837642e706e67 )
180
+ ![ ] ( https://camo.githubusercontent .com/a9003bdc7db7d8c0524fd8f9ef2394eac4a7ad68ba618954f518ed81a12738e8/68747470733a2f2f63616d6f2e716969746175736572636f6e74656e742e636f6d2f633963393931656231343733313337383636666238363933656231643462656637623661646466632f36383734373437303733336132663266373136393639373436313264363936643631363736353264373337343666373236353265373333333265363137303264366536663732373436383635363137333734326433313265363136643631376136663665363137373733326536333666366432663330326633323330333833333336333332663636363133323633333236363335333232643339363633383336326436343334333533323264363433323633333732643631363233333633333036353330363136363338333736343265373036653637 )
181
181
182
182
``` python
183
183
import winocr
184
184
185
185
[(await winocr.recognize_pil(img)).text for img in images]
186
186
```
187
- ![ ] ( https://camo.qiitausercontent .com/5bab8b980fee37d662f73893df2a4c0b4b494dd1/68747470733a2f2f71696974612d696d6167652d73746f72652e73332e61702d6e6f727468656173742d312e616d617a6f6e6177732e636f6d2f302f3230383336332f65656536636332302d376663352d376462372d383464622d6361656165326465666139392e706e67 )
187
+ ![ ] ( https://camo.githubusercontent .com/5e965ce96d5b3fdb5220c619ceb1597d09fea8d34df5f3a7a0b5388a8286a034/68747470733a2f2f63616d6f2e716969746175736572636f6e74656e742e636f6d2f356261623862393830666565333764363632663733383933646632613463306234623439346464312f36383734373437303733336132663266373136393639373436313264363936643631363736353264373337343666373236353265373333333265363137303264366536663732373436383635363137333734326433313265363136643631376136663665363137373733326536333666366432663330326633323330333833333336333332663635363536353336363336333332333032643337363636333335326433373634363233373264333833343634363232643633363136353631363533323634363536363631333933393265373036653637 )
188
188
189
189
### 4 cores(elapsed 16s)
190
190
191
191
I'm using 100% CPU.
192
- ![ ] ( https://camo.qiitausercontent .com/2722a602a190ac5e54df7164b9e3cf714cb48d42/68747470733a2f2f71696974612d696d6167652d73746f72652e73332e61702d6e6f727468656173742d312e616d617a6f6e6177732e636f6d2f302f3230383336332f37636565626631652d663232662d353065352d393635612d3430326666633738363435622e706e67 )
192
+ ![ ] ( https://camo.githubusercontent .com/9bc7fc8bbf5c1e5cc9a89e4fb2233900867b6f79019ee530fe36e5d36c896ad9/68747470733a2f2f63616d6f2e716969746175736572636f6e74656e742e636f6d2f323732326136303261313930616335653534646637313634623965336366373134636234386434322f36383734373437303733336132663266373136393639373436313264363936643631363736353264373337343666373236353265373333333265363137303264366536663732373436383635363137333734326433313265363136643631376136663665363137373733326536333666366432663330326633323330333833333336333332663337363336353635363236363331363532643636333233323636326433353330363533353264333933363335363132643334333033323636363636333337333833363334333536323265373036653637 )
193
193
194
194
Create a worker module.
195
195
``` python
@@ -214,4 +214,4 @@ with concurrent.futures.ProcessPoolExecutor() as executor:
214
214
list (results)
215
215
```
216
216
217
- ![ ] ( https://camo.qiitausercontent .com/e172513d58e10c9ad6ddd148eeb78e1bc112f624/68747470733a2f2f71696974612d696d6167652d73746f72652e73332e61702d6e6f727468656173742d312e616d617a6f6e6177732e636f6d2f302f3230383336332f61373136373537312d616135642d636231352d616461312d6132643230306535386562382e706e67 )
217
+ ![ ] ( https://camo.githubusercontent .com/cd21e01dd05a064986c764e0b86aa98f3b25ad3b346ff5bdfee3d1dd7dbae132/68747470733a2f2f63616d6f2e716969746175736572636f6e74656e742e636f6d2f653137323531336435386531306339616436646464313438656562373865316263313132663632342f36383734373437303733336132663266373136393639373436313264363936643631363736353264373337343666373236353265373333333265363137303264366536663732373436383635363137333734326433313265363136643631376136663665363137373733326536333666366432663330326633323330333833333336333332663631333733313336333733353337333132643631363133353634326436333632333133353264363136343631333132643631333236343332333033303635333533383635363233383265373036653637 )
0 commit comments