Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 724b28a

Browse files
Relocate each notebook to a new directory with its own pyproject.toml
* Only the dependencies for each project will be included in the pyproject.toml, and this restructure could prevent dependency conflicts. * Modify the notebooks to create the output directory right before starting the OCR for the image(s)
1 parent 68000d8 commit 724b28a

File tree

19 files changed

+8228
-1879
lines changed

19 files changed

+8228
-1879
lines changed

‎cn-ocr-demo/.python-version‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10

‎cn-ocr-demo.py‎ renamed to ‎cn-ocr-demo/cn-ocr-demo.py‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import marimo
99

10-
__generated_with = "0.14.11"
10+
__generated_with = "0.14.16"
1111
app = marimo.App(width="medium", app_title="CnOCR Notebook")
1212

1313

@@ -24,9 +24,7 @@ def _(mo):
2424

2525
@app.cell(hide_code=True)
2626
def _(mo):
27-
mo.md(
28-
r"""![CnOCR OCR](https://raw.githubusercontent.com/breezedeus/CnOCR/master/docs/figs/cnocr-logo.jpg)"""
29-
)
27+
mo.md(r"""![CnOCR OCR](https://raw.githubusercontent.com/breezedeus/CnOCR/master/docs/figs/cnocr-logo.jpg)""")
3028
return
3129

3230

@@ -50,6 +48,7 @@ def _():
5048
import PIL
5149
from PIL import Image
5250
from PIL import ImageDraw
51+
from os import makedirs
5352

5453

5554
file_browser = mo.ui.file_browser(
@@ -58,7 +57,7 @@ def _():
5857
multiple=True,
5958
)
6059
mo.vstack([file_browser])
61-
return CnOcr, ImageDraw, PIL, file_browser, mo, pyperclip
60+
return CnOcr, ImageDraw, PIL, file_browser, makedirs, mo, pyperclip
6261

6362

6463
@app.cell
@@ -191,6 +190,13 @@ def _(mo):
191190
return
192191

193192

193+
@app.cell
194+
def _(makedirs):
195+
# Create a directory where the OCR results will be saved
196+
makedirs("./output", exist_ok=True)
197+
return
198+
199+
194200
@app.cell
195201
def _(
196202
CnOcr,

‎cn-ocr-demo/pyproject.toml‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[project]
2+
name = "cn-ocr-demo"
3+
version = "0.1.0"
4+
description = "Marimo notebook demo for CnOCR"
5+
requires-python = ">=3.10"
6+
authors = [
7+
{name = "ahmed-0011"},
8+
]
9+
dependencies = [
10+
"pyperclip>=1.9.0",
11+
"marimo[recommended]>=0.14.11,<1.0",
12+
"opencv-python~=4.12.0.88",
13+
"setuptools",
14+
"cnocr[ort-cpu]~=2.3.2.1",
15+
]
16+
17+
[tool.marimo.package_management]
18+
manager = "uv"
19+
20+
[tool.marimo.runtime]
21+
auto_instantiate = true
22+
on_cell_change = "autorun"

‎cn-ocr-demo/uv.lock‎

Lines changed: 3479 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎easy-ocr-demo/.python-version‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10

‎easy-ocr-demo.py‎ renamed to ‎easy-ocr-demo/easy-ocr-demo.py‎

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import marimo
99

10-
__generated_with = "0.14.11"
10+
__generated_with = "0.14.16"
1111
app = marimo.App(width="medium", app_title="EasyOCR Notebook")
1212

1313

@@ -42,6 +42,7 @@ def _():
4242
import PIL
4343
from PIL import Image
4444
from PIL import ImageDraw
45+
from os import makedirs
4546

4647

4748
file_browser = mo.ui.file_browser(
@@ -50,7 +51,7 @@ def _():
5051
multiple=True,
5152
)
5253
mo.vstack([file_browser])
53-
return ImageDraw, PIL, easyocr, file_browser, mo, pyperclip
54+
return ImageDraw, PIL, easyocr, file_browser, makedirs, mo, pyperclip
5455

5556

5657
@app.cell
@@ -139,6 +140,13 @@ def _(mo):
139140
return
140141

141142

143+
@app.cell
144+
def _(makedirs):
145+
# Create a directory where the OCR results will be saved
146+
makedirs("./output", exist_ok=True)
147+
return
148+
149+
142150
@app.cell
143151
def _(
144152
ImageDraw,
@@ -200,9 +208,9 @@ def save_ocr_result(bboxes, str_file_path, str_output_img_file_path) -> None:
200208
mo.stop(True, get_error_as_html(f"<strong>ERROR: {e}</strong>"))
201209

202210
html_model_storage_path = mo.md(
203-
f"`EasyOCR models are stored in the following path: {
211+
f"""`EasyOCR models are stored in the following path: {
204212
reader.model_storage_directory
205-
}`"
213+
}`"""
206214
)
207215

208216
original_file_names = ", ".join(map(lambda path: path.name, file_paths))
@@ -255,10 +263,17 @@ def _(mo):
255263

256264

257265
@app.cell
258-
def _(list_bounding_box, list_score, list_text, mo, original_file_names):
266+
def _(
267+
easyocr,
268+
list_bounding_box,
269+
list_score,
270+
list_text,
271+
mo,
272+
original_file_names,
273+
):
259274
dict_table_data = {
260-
"Bounding Box": list_bounding_box,
261-
"Score": list_score,
275+
"Bounding Box": easyocr.utils.np.asarray(list_bounding_box).tolist(),
276+
"Score": easyocr.utils.np.asarray(list_score).tolist(),
262277
"Text": list_text,
263278
}
264279

‎easy-ocr-demo/pyproject.toml‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[project]
2+
name = "easy-ocr-demo"
3+
version = "0.1.0"
4+
description = "Marimo notebook demo for EasyOCR"
5+
requires-python = ">=3.10"
6+
authors = [
7+
{name = "ahmed-0011"},
8+
]
9+
dependencies = [
10+
"pyperclip>=1.9.0",
11+
"marimo[recommended]>=0.14.11,<1.0",
12+
"opencv-python~=4.12.0.88",
13+
"setuptools",
14+
"easyocr~=1.7.2",
15+
]
16+
17+
[tool.marimo.package_management]
18+
manager = "uv"
19+
20+
[tool.marimo.runtime]
21+
auto_instantiate = true
22+
on_cell_change = "autorun"

‎easy-ocr-demo/uv.lock‎

Lines changed: 2171 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pp-ocr-demo/.python-version‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10
File renamed without changes.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /