HasinManjare commited on
Commit
98ea29e
·
1 Parent(s): 4b557b4

Add standalone auto-download CPU/GPU Docker and Compose setup (#1)

Browse files

- Add standalone auto-download CPU/GPU Docker and Compose setup (b7c9c3879005d1c7c173490b149218158de316e0)

Files changed (12) hide show
  1. .dockerignore +4 -4
  2. Dockerfile +118 -5
  3. Dockerfile.cpu +152 -0
  4. Dockerfile.gpu +152 -0
  5. MANIFEST.json +31 -19
  6. README.md +68 -40
  7. RELEASE_FILES.md +6 -4
  8. SHA256SUMS +11 -9
  9. USER_GUIDE.md +63 -30
  10. VALIDATION.md +25 -0
  11. compose.cpu.yml +10 -5
  12. compose.gpu.yml +10 -5
.dockerignore CHANGED
@@ -1,5 +1,5 @@
1
- *
 
2
  !Dockerfile
3
- !requirements-runtime.txt
4
- !runtime/
5
- !runtime/**
 
1
+ # These standalone builds fetch their inputs from the pinned public release.
2
+ **
3
  !Dockerfile
4
+ !Dockerfile.cpu
5
+ !Dockerfile.gpu
 
Dockerfile CHANGED
@@ -1,6 +1,117 @@
1
  # syntax=docker/dockerfile:1
2
- # GPU: docker build --target gpu -t docr-preview:gpu .
3
- # CPU: docker build --target cpu -t docr-preview:cpu .
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  FROM python:3.12-slim-bookworm AS base
5
  ENV PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1 \
6
  HF_HUB_OFFLINE=1 TOKENIZERS_PARALLELISM=false \
@@ -15,10 +126,9 @@ ENV PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1 \
15
  RUN apt-get update && apt-get install -y --no-install-recommends libgomp1 libglib2.0-0 libgl1 \
16
  && rm -rf /var/lib/apt/lists/* \
17
  && useradd --uid 1000 --create-home --home-dir /home/ocr --shell /usr/sbin/nologin ocr
18
- COPY requirements-runtime.txt /tmp/requirements-runtime.txt
19
  RUN pip install --no-cache-dir -r /tmp/requirements-runtime.txt
20
  WORKDIR /opt/docr
21
- ADD runtime/docr-runtime-cp312-linux-x86_64.tar.gz /opt/docr/
22
  RUN mkdir -p /opt/docr/data && chown ocr:ocr /opt/docr/data
23
  VOLUME ["/opt/docr/data"]
24
  EXPOSE 8000
@@ -29,11 +139,14 @@ CMD ["python", "-m", "uvicorn", "api.app:app", "--host", "0.0.0.0", "--port", "8
29
  FROM base AS cpu
30
  RUN pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu torch==2.9.1+cpu torchvision==0.24.1+cpu \
31
  && pip check
 
32
  USER ocr
33
 
34
- # Default build target: NVIDIA GPU. CPU inference remains available explicitly.
35
  FROM base AS gpu
36
  RUN pip install --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cu128 torch==2.9.1+cu128 torchvision==0.24.1+cu128 flash-linear-attention==0.6.0 \
37
  && pip check
 
38
  ENV OCR_DEVICE=cuda
39
  USER ocr
 
 
 
1
  # syntax=docker/dockerfile:1
2
+ # Generated by scripts/release/generate_preview_docker.py.
3
+ # Standalone: only this Dockerfile is needed. No local source or weights are copied.
4
+ FROM python:3.12-slim-bookworm AS release
5
+ ARG HF_REPO=D-OCR/D-OCR-preview
6
+ ARG HF_REVISION=4b557b4626bdfb39db3d7a0aed120a853092c0db
7
+ RUN --mount=type=cache,target=/download-cache,sharing=locked python - <<'PY'
8
+ """Embedded in standalone Dockerfiles; downloads only verified inference assets."""
9
+ import hashlib
10
+ import json
11
+ import os
12
+ from pathlib import Path, PurePosixPath
13
+ import shutil
14
+ import tarfile
15
+ import time
16
+ from urllib.error import URLError
17
+ from urllib.parse import quote
18
+ from urllib.request import urlopen
19
+
20
+
21
+ RUNTIME = 'runtime/docr-runtime-cp312-linux-x86_64.tar.gz'
22
+ REQUIRED = {
23
+ RUNTIME, 'requirements-runtime.txt',
24
+ 'checkpoints/siglip_qwen/best.pt',
25
+ 'checkpoints/initial_v1/table/best/model.safetensors',
26
+ 'checkpoints/initial_v1/table/best/config.json',
27
+ 'checkpoints/initial_v1/table/best/preprocessor_config.json',
28
+ 'deploy/models/siglip_qwen/vision/config.json',
29
+ 'deploy/models/siglip_qwen/vision/preprocessor_config.json',
30
+ 'deploy/models/siglip_qwen/decoder/config.json',
31
+ 'deploy/models/siglip_qwen/decoder/tokenizer.json',
32
+ 'deploy/models/siglip_qwen/decoder/tokenizer_config.json',
33
+ *(f'deploy/models/{model}/inference.{suffix}'
34
+ for model in ('layout_s_paddle322', 'PP-OCRv5_mobile_det')
35
+ for suffix in ('json', 'pdiparams', 'yml')),
36
+ }
37
+
38
+
39
+ def verified(path, entry):
40
+ if not path.is_file() or path.stat().st_size != entry['size_bytes']:
41
+ return False
42
+ with path.open('rb') as stream:
43
+ return hashlib.file_digest(stream, 'sha256').hexdigest() == entry['sha256']
44
+
45
+
46
+ def fetch(url, path):
47
+ for attempt in range(3):
48
+ try:
49
+ with urlopen(url, timeout=120) as response, path.open('wb') as stream:
50
+ shutil.copyfileobj(response, stream, length=1024 * 1024)
51
+ return
52
+ except (URLError, TimeoutError, ConnectionError):
53
+ if attempt == 2:
54
+ raise
55
+ time.sleep(2 ** attempt)
56
+
57
+
58
+ def download_release(base_url, destination):
59
+ destination = Path(destination)
60
+ destination.mkdir(parents=True, exist_ok=True)
61
+ manifest_path = destination / 'MANIFEST.json'
62
+ fetch(base_url + '/MANIFEST.json', manifest_path)
63
+ manifest = json.loads(manifest_path.read_text())
64
+ entries = manifest['files']
65
+ missing = REQUIRED - {entry['path'] for entry in entries}
66
+ if missing:
67
+ raise ValueError(f'Missing required release assets: {sorted(missing)}')
68
+ for entry in entries:
69
+ relative = entry['path']
70
+ path = PurePosixPath(relative)
71
+ if path.is_absolute() or '..' in path.parts or '\\' in relative:
72
+ raise ValueError(f'Unsafe release path: {relative}')
73
+ for entry in entries:
74
+ relative = entry['path']
75
+ if not (relative in REQUIRED or relative in ('LICENSE', 'THIRD_PARTY_NOTICES.md')
76
+ or relative.startswith(('checkpoints/siglip_qwen/',
77
+ 'checkpoints/initial_v1/table/best/',
78
+ 'deploy/models/', 'licenses/'))):
79
+ continue
80
+ target = destination / relative
81
+ if verified(target, entry):
82
+ print(f'Cached: {relative}', flush=True)
83
+ continue
84
+ target.parent.mkdir(parents=True, exist_ok=True)
85
+ temporary = target.with_name(target.name + '.part')
86
+ print(f'Downloading: {relative} ({entry["size_bytes"]:,} bytes)', flush=True)
87
+ try:
88
+ fetch(base_url + '/' + quote(relative, safe='/'), temporary)
89
+ if not verified(temporary, entry):
90
+ raise ValueError(f'Checksum or size mismatch: {relative}')
91
+ temporary.replace(target)
92
+ finally:
93
+ temporary.unlink(missing_ok=True)
94
+
95
+
96
+ if __name__ == '__main__':
97
+ repo = os.environ['HF_REPO']
98
+ revision = os.environ['HF_REVISION']
99
+ base_url = f'https://huggingface.co/{repo}/resolve/{quote(revision, safe="")}'
100
+ cache = Path('/download-cache') / hashlib.sha256(base_url.encode()).hexdigest()
101
+ download_release(base_url, cache)
102
+ output = Path('/release')
103
+ output.mkdir(parents=True, exist_ok=True)
104
+ for name in ('checkpoints', 'deploy', 'licenses'):
105
+ if (cache / name).exists():
106
+ shutil.copytree(cache / name, output / name, dirs_exist_ok=True)
107
+ for name in ('requirements-runtime.txt', 'LICENSE', 'THIRD_PARTY_NOTICES.md', 'MANIFEST.json'):
108
+ if (cache / name).exists():
109
+ shutil.copy2(cache / name, output / name)
110
+ with tarfile.open(cache / RUNTIME, 'r:gz') as archive:
111
+ archive.extractall(output, filter='data')
112
+ (output / 'RELEASE_REVISION').write_text(f'{repo}@{revision}\n')
113
+ PY
114
+
115
  FROM python:3.12-slim-bookworm AS base
116
  ENV PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1 \
117
  HF_HUB_OFFLINE=1 TOKENIZERS_PARALLELISM=false \
 
126
  RUN apt-get update && apt-get install -y --no-install-recommends libgomp1 libglib2.0-0 libgl1 \
127
  && rm -rf /var/lib/apt/lists/* \
128
  && useradd --uid 1000 --create-home --home-dir /home/ocr --shell /usr/sbin/nologin ocr
129
+ COPY --from=release /release/requirements-runtime.txt /tmp/requirements-runtime.txt
130
  RUN pip install --no-cache-dir -r /tmp/requirements-runtime.txt
131
  WORKDIR /opt/docr
 
132
  RUN mkdir -p /opt/docr/data && chown ocr:ocr /opt/docr/data
133
  VOLUME ["/opt/docr/data"]
134
  EXPOSE 8000
 
139
  FROM base AS cpu
140
  RUN pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu torch==2.9.1+cpu torchvision==0.24.1+cpu \
141
  && pip check
142
+ COPY --from=release /release/ /opt/docr/
143
  USER ocr
144
 
 
145
  FROM base AS gpu
146
  RUN pip install --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cu128 torch==2.9.1+cu128 torchvision==0.24.1+cu128 flash-linear-attention==0.6.0 \
147
  && pip check
148
+ COPY --from=release /release/ /opt/docr/
149
  ENV OCR_DEVICE=cuda
150
  USER ocr
151
+
152
+ FROM gpu AS default
Dockerfile.cpu ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # syntax=docker/dockerfile:1
2
+ # Generated by scripts/release/generate_preview_docker.py.
3
+ # Standalone: only this Dockerfile is needed. No local source or weights are copied.
4
+ FROM python:3.12-slim-bookworm AS release
5
+ ARG HF_REPO=D-OCR/D-OCR-preview
6
+ ARG HF_REVISION=4b557b4626bdfb39db3d7a0aed120a853092c0db
7
+ RUN --mount=type=cache,target=/download-cache,sharing=locked python - <<'PY'
8
+ """Embedded in standalone Dockerfiles; downloads only verified inference assets."""
9
+ import hashlib
10
+ import json
11
+ import os
12
+ from pathlib import Path, PurePosixPath
13
+ import shutil
14
+ import tarfile
15
+ import time
16
+ from urllib.error import URLError
17
+ from urllib.parse import quote
18
+ from urllib.request import urlopen
19
+
20
+
21
+ RUNTIME = 'runtime/docr-runtime-cp312-linux-x86_64.tar.gz'
22
+ REQUIRED = {
23
+ RUNTIME, 'requirements-runtime.txt',
24
+ 'checkpoints/siglip_qwen/best.pt',
25
+ 'checkpoints/initial_v1/table/best/model.safetensors',
26
+ 'checkpoints/initial_v1/table/best/config.json',
27
+ 'checkpoints/initial_v1/table/best/preprocessor_config.json',
28
+ 'deploy/models/siglip_qwen/vision/config.json',
29
+ 'deploy/models/siglip_qwen/vision/preprocessor_config.json',
30
+ 'deploy/models/siglip_qwen/decoder/config.json',
31
+ 'deploy/models/siglip_qwen/decoder/tokenizer.json',
32
+ 'deploy/models/siglip_qwen/decoder/tokenizer_config.json',
33
+ *(f'deploy/models/{model}/inference.{suffix}'
34
+ for model in ('layout_s_paddle322', 'PP-OCRv5_mobile_det')
35
+ for suffix in ('json', 'pdiparams', 'yml')),
36
+ }
37
+
38
+
39
+ def verified(path, entry):
40
+ if not path.is_file() or path.stat().st_size != entry['size_bytes']:
41
+ return False
42
+ with path.open('rb') as stream:
43
+ return hashlib.file_digest(stream, 'sha256').hexdigest() == entry['sha256']
44
+
45
+
46
+ def fetch(url, path):
47
+ for attempt in range(3):
48
+ try:
49
+ with urlopen(url, timeout=120) as response, path.open('wb') as stream:
50
+ shutil.copyfileobj(response, stream, length=1024 * 1024)
51
+ return
52
+ except (URLError, TimeoutError, ConnectionError):
53
+ if attempt == 2:
54
+ raise
55
+ time.sleep(2 ** attempt)
56
+
57
+
58
+ def download_release(base_url, destination):
59
+ destination = Path(destination)
60
+ destination.mkdir(parents=True, exist_ok=True)
61
+ manifest_path = destination / 'MANIFEST.json'
62
+ fetch(base_url + '/MANIFEST.json', manifest_path)
63
+ manifest = json.loads(manifest_path.read_text())
64
+ entries = manifest['files']
65
+ missing = REQUIRED - {entry['path'] for entry in entries}
66
+ if missing:
67
+ raise ValueError(f'Missing required release assets: {sorted(missing)}')
68
+ for entry in entries:
69
+ relative = entry['path']
70
+ path = PurePosixPath(relative)
71
+ if path.is_absolute() or '..' in path.parts or '\\' in relative:
72
+ raise ValueError(f'Unsafe release path: {relative}')
73
+ for entry in entries:
74
+ relative = entry['path']
75
+ if not (relative in REQUIRED or relative in ('LICENSE', 'THIRD_PARTY_NOTICES.md')
76
+ or relative.startswith(('checkpoints/siglip_qwen/',
77
+ 'checkpoints/initial_v1/table/best/',
78
+ 'deploy/models/', 'licenses/'))):
79
+ continue
80
+ target = destination / relative
81
+ if verified(target, entry):
82
+ print(f'Cached: {relative}', flush=True)
83
+ continue
84
+ target.parent.mkdir(parents=True, exist_ok=True)
85
+ temporary = target.with_name(target.name + '.part')
86
+ print(f'Downloading: {relative} ({entry["size_bytes"]:,} bytes)', flush=True)
87
+ try:
88
+ fetch(base_url + '/' + quote(relative, safe='/'), temporary)
89
+ if not verified(temporary, entry):
90
+ raise ValueError(f'Checksum or size mismatch: {relative}')
91
+ temporary.replace(target)
92
+ finally:
93
+ temporary.unlink(missing_ok=True)
94
+
95
+
96
+ if __name__ == '__main__':
97
+ repo = os.environ['HF_REPO']
98
+ revision = os.environ['HF_REVISION']
99
+ base_url = f'https://huggingface.co/{repo}/resolve/{quote(revision, safe="")}'
100
+ cache = Path('/download-cache') / hashlib.sha256(base_url.encode()).hexdigest()
101
+ download_release(base_url, cache)
102
+ output = Path('/release')
103
+ output.mkdir(parents=True, exist_ok=True)
104
+ for name in ('checkpoints', 'deploy', 'licenses'):
105
+ if (cache / name).exists():
106
+ shutil.copytree(cache / name, output / name, dirs_exist_ok=True)
107
+ for name in ('requirements-runtime.txt', 'LICENSE', 'THIRD_PARTY_NOTICES.md', 'MANIFEST.json'):
108
+ if (cache / name).exists():
109
+ shutil.copy2(cache / name, output / name)
110
+ with tarfile.open(cache / RUNTIME, 'r:gz') as archive:
111
+ archive.extractall(output, filter='data')
112
+ (output / 'RELEASE_REVISION').write_text(f'{repo}@{revision}\n')
113
+ PY
114
+
115
+ FROM python:3.12-slim-bookworm AS base
116
+ ENV PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1 \
117
+ HF_HUB_OFFLINE=1 TOKENIZERS_PARALLELISM=false \
118
+ OCR_PIPELINE=siglip_qwen OCR_DEVICE=cpu OCR_PADDLE_DEVICE=cpu \
119
+ OCR_PADDLE_PYTHON=/usr/local/bin/python \
120
+ OCR_RECOGNIZER_CHECKPOINT=/opt/docr/checkpoints/siglip_qwen/best.pt \
121
+ OCR_RECOGNIZER_ASSETS=/opt/docr/deploy/models/siglip_qwen \
122
+ OCR_LINE_DETECTOR_MODEL=/opt/docr/deploy/models/PP-OCRv5_mobile_det \
123
+ PADDLE_PDX_DISABLE_MODEL_SOURCE_CHECK=True DISABLE_MODEL_SOURCE_CHECK=True \
124
+ OMP_NUM_THREADS=4 MKL_NUM_THREADS=4 OCR_MAX_PENDING_JOBS=10 \
125
+ OCR_DATA_DIR=/opt/docr/data HOME=/home/ocr
126
+ RUN apt-get update && apt-get install -y --no-install-recommends libgomp1 libglib2.0-0 libgl1 \
127
+ && rm -rf /var/lib/apt/lists/* \
128
+ && useradd --uid 1000 --create-home --home-dir /home/ocr --shell /usr/sbin/nologin ocr
129
+ COPY --from=release /release/requirements-runtime.txt /tmp/requirements-runtime.txt
130
+ RUN pip install --no-cache-dir -r /tmp/requirements-runtime.txt
131
+ WORKDIR /opt/docr
132
+ RUN mkdir -p /opt/docr/data && chown ocr:ocr /opt/docr/data
133
+ VOLUME ["/opt/docr/data"]
134
+ EXPOSE 8000
135
+ HEALTHCHECK --interval=30s --timeout=5s --start-period=300s --retries=3 \
136
+ CMD python -c "import json,urllib.request; r=json.load(urllib.request.urlopen('http://localhost:8000/health',timeout=3)); raise SystemExit(r.get('status')!='ready')"
137
+ CMD ["python", "-m", "uvicorn", "api.app:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1"]
138
+
139
+ FROM base AS cpu
140
+ RUN pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu torch==2.9.1+cpu torchvision==0.24.1+cpu \
141
+ && pip check
142
+ COPY --from=release /release/ /opt/docr/
143
+ USER ocr
144
+
145
+ FROM base AS gpu
146
+ RUN pip install --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cu128 torch==2.9.1+cu128 torchvision==0.24.1+cu128 flash-linear-attention==0.6.0 \
147
+ && pip check
148
+ COPY --from=release /release/ /opt/docr/
149
+ ENV OCR_DEVICE=cuda
150
+ USER ocr
151
+
152
+ FROM cpu AS default
Dockerfile.gpu ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # syntax=docker/dockerfile:1
2
+ # Generated by scripts/release/generate_preview_docker.py.
3
+ # Standalone: only this Dockerfile is needed. No local source or weights are copied.
4
+ FROM python:3.12-slim-bookworm AS release
5
+ ARG HF_REPO=D-OCR/D-OCR-preview
6
+ ARG HF_REVISION=4b557b4626bdfb39db3d7a0aed120a853092c0db
7
+ RUN --mount=type=cache,target=/download-cache,sharing=locked python - <<'PY'
8
+ """Embedded in standalone Dockerfiles; downloads only verified inference assets."""
9
+ import hashlib
10
+ import json
11
+ import os
12
+ from pathlib import Path, PurePosixPath
13
+ import shutil
14
+ import tarfile
15
+ import time
16
+ from urllib.error import URLError
17
+ from urllib.parse import quote
18
+ from urllib.request import urlopen
19
+
20
+
21
+ RUNTIME = 'runtime/docr-runtime-cp312-linux-x86_64.tar.gz'
22
+ REQUIRED = {
23
+ RUNTIME, 'requirements-runtime.txt',
24
+ 'checkpoints/siglip_qwen/best.pt',
25
+ 'checkpoints/initial_v1/table/best/model.safetensors',
26
+ 'checkpoints/initial_v1/table/best/config.json',
27
+ 'checkpoints/initial_v1/table/best/preprocessor_config.json',
28
+ 'deploy/models/siglip_qwen/vision/config.json',
29
+ 'deploy/models/siglip_qwen/vision/preprocessor_config.json',
30
+ 'deploy/models/siglip_qwen/decoder/config.json',
31
+ 'deploy/models/siglip_qwen/decoder/tokenizer.json',
32
+ 'deploy/models/siglip_qwen/decoder/tokenizer_config.json',
33
+ *(f'deploy/models/{model}/inference.{suffix}'
34
+ for model in ('layout_s_paddle322', 'PP-OCRv5_mobile_det')
35
+ for suffix in ('json', 'pdiparams', 'yml')),
36
+ }
37
+
38
+
39
+ def verified(path, entry):
40
+ if not path.is_file() or path.stat().st_size != entry['size_bytes']:
41
+ return False
42
+ with path.open('rb') as stream:
43
+ return hashlib.file_digest(stream, 'sha256').hexdigest() == entry['sha256']
44
+
45
+
46
+ def fetch(url, path):
47
+ for attempt in range(3):
48
+ try:
49
+ with urlopen(url, timeout=120) as response, path.open('wb') as stream:
50
+ shutil.copyfileobj(response, stream, length=1024 * 1024)
51
+ return
52
+ except (URLError, TimeoutError, ConnectionError):
53
+ if attempt == 2:
54
+ raise
55
+ time.sleep(2 ** attempt)
56
+
57
+
58
+ def download_release(base_url, destination):
59
+ destination = Path(destination)
60
+ destination.mkdir(parents=True, exist_ok=True)
61
+ manifest_path = destination / 'MANIFEST.json'
62
+ fetch(base_url + '/MANIFEST.json', manifest_path)
63
+ manifest = json.loads(manifest_path.read_text())
64
+ entries = manifest['files']
65
+ missing = REQUIRED - {entry['path'] for entry in entries}
66
+ if missing:
67
+ raise ValueError(f'Missing required release assets: {sorted(missing)}')
68
+ for entry in entries:
69
+ relative = entry['path']
70
+ path = PurePosixPath(relative)
71
+ if path.is_absolute() or '..' in path.parts or '\\' in relative:
72
+ raise ValueError(f'Unsafe release path: {relative}')
73
+ for entry in entries:
74
+ relative = entry['path']
75
+ if not (relative in REQUIRED or relative in ('LICENSE', 'THIRD_PARTY_NOTICES.md')
76
+ or relative.startswith(('checkpoints/siglip_qwen/',
77
+ 'checkpoints/initial_v1/table/best/',
78
+ 'deploy/models/', 'licenses/'))):
79
+ continue
80
+ target = destination / relative
81
+ if verified(target, entry):
82
+ print(f'Cached: {relative}', flush=True)
83
+ continue
84
+ target.parent.mkdir(parents=True, exist_ok=True)
85
+ temporary = target.with_name(target.name + '.part')
86
+ print(f'Downloading: {relative} ({entry["size_bytes"]:,} bytes)', flush=True)
87
+ try:
88
+ fetch(base_url + '/' + quote(relative, safe='/'), temporary)
89
+ if not verified(temporary, entry):
90
+ raise ValueError(f'Checksum or size mismatch: {relative}')
91
+ temporary.replace(target)
92
+ finally:
93
+ temporary.unlink(missing_ok=True)
94
+
95
+
96
+ if __name__ == '__main__':
97
+ repo = os.environ['HF_REPO']
98
+ revision = os.environ['HF_REVISION']
99
+ base_url = f'https://huggingface.co/{repo}/resolve/{quote(revision, safe="")}'
100
+ cache = Path('/download-cache') / hashlib.sha256(base_url.encode()).hexdigest()
101
+ download_release(base_url, cache)
102
+ output = Path('/release')
103
+ output.mkdir(parents=True, exist_ok=True)
104
+ for name in ('checkpoints', 'deploy', 'licenses'):
105
+ if (cache / name).exists():
106
+ shutil.copytree(cache / name, output / name, dirs_exist_ok=True)
107
+ for name in ('requirements-runtime.txt', 'LICENSE', 'THIRD_PARTY_NOTICES.md', 'MANIFEST.json'):
108
+ if (cache / name).exists():
109
+ shutil.copy2(cache / name, output / name)
110
+ with tarfile.open(cache / RUNTIME, 'r:gz') as archive:
111
+ archive.extractall(output, filter='data')
112
+ (output / 'RELEASE_REVISION').write_text(f'{repo}@{revision}\n')
113
+ PY
114
+
115
+ FROM python:3.12-slim-bookworm AS base
116
+ ENV PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1 \
117
+ HF_HUB_OFFLINE=1 TOKENIZERS_PARALLELISM=false \
118
+ OCR_PIPELINE=siglip_qwen OCR_DEVICE=cpu OCR_PADDLE_DEVICE=cpu \
119
+ OCR_PADDLE_PYTHON=/usr/local/bin/python \
120
+ OCR_RECOGNIZER_CHECKPOINT=/opt/docr/checkpoints/siglip_qwen/best.pt \
121
+ OCR_RECOGNIZER_ASSETS=/opt/docr/deploy/models/siglip_qwen \
122
+ OCR_LINE_DETECTOR_MODEL=/opt/docr/deploy/models/PP-OCRv5_mobile_det \
123
+ PADDLE_PDX_DISABLE_MODEL_SOURCE_CHECK=True DISABLE_MODEL_SOURCE_CHECK=True \
124
+ OMP_NUM_THREADS=4 MKL_NUM_THREADS=4 OCR_MAX_PENDING_JOBS=10 \
125
+ OCR_DATA_DIR=/opt/docr/data HOME=/home/ocr
126
+ RUN apt-get update && apt-get install -y --no-install-recommends libgomp1 libglib2.0-0 libgl1 \
127
+ && rm -rf /var/lib/apt/lists/* \
128
+ && useradd --uid 1000 --create-home --home-dir /home/ocr --shell /usr/sbin/nologin ocr
129
+ COPY --from=release /release/requirements-runtime.txt /tmp/requirements-runtime.txt
130
+ RUN pip install --no-cache-dir -r /tmp/requirements-runtime.txt
131
+ WORKDIR /opt/docr
132
+ RUN mkdir -p /opt/docr/data && chown ocr:ocr /opt/docr/data
133
+ VOLUME ["/opt/docr/data"]
134
+ EXPOSE 8000
135
+ HEALTHCHECK --interval=30s --timeout=5s --start-period=300s --retries=3 \
136
+ CMD python -c "import json,urllib.request; r=json.load(urllib.request.urlopen('http://localhost:8000/health',timeout=3)); raise SystemExit(r.get('status')!='ready')"
137
+ CMD ["python", "-m", "uvicorn", "api.app:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1"]
138
+
139
+ FROM base AS cpu
140
+ RUN pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu torch==2.9.1+cpu torchvision==0.24.1+cpu \
141
+ && pip check
142
+ COPY --from=release /release/ /opt/docr/
143
+ USER ocr
144
+
145
+ FROM base AS gpu
146
+ RUN pip install --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cu128 torch==2.9.1+cu128 torchvision==0.24.1+cu128 flash-linear-attention==0.6.0 \
147
+ && pip check
148
+ COPY --from=release /release/ /opt/docr/
149
+ ENV OCR_DEVICE=cuda
150
+ USER ocr
151
+
152
+ FROM gpu AS default
MANIFEST.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "release": "D-OCR preview",
3
- "date": "2026-11-24",
4
- "destination": "HasinManjare/D-OCR-preview",
5
  "runtime": {
6
  "python": "CPython 3.12",
7
  "platform": "Linux x86-64",
@@ -10,13 +10,15 @@
10
  "validation": {
11
  "cpu_container": "passed",
12
  "compiled_gpu_runtime": "passed",
13
- "gpu_container": "not tested"
 
 
14
  },
15
  "files": [
16
  {
17
  "path": ".dockerignore",
18
- "size_bytes": 62,
19
- "sha256": "9a99dec63b197bf3af2ed5c7d8ee86f41b6b66f483de23972c196275694c3be5"
20
  },
21
  {
22
  "path": ".gitattributes",
@@ -25,8 +27,18 @@
25
  },
26
  {
27
  "path": "Dockerfile",
28
- "size_bytes": 2151,
29
- "sha256": "36308f1d7a45096f9307db2d0d3eeed298d566f985de95e19590f76eadbab4f2"
 
 
 
 
 
 
 
 
 
 
30
  },
31
  {
32
  "path": "LICENSE",
@@ -35,13 +47,13 @@
35
  },
36
  {
37
  "path": "README.md",
38
- "size_bytes": 9922,
39
- "sha256": "e9ee364b67ab5dc94acd5d9bc11ae5204db3cc1e81347127ca9731150ff056ab"
40
  },
41
  {
42
  "path": "RELEASE_FILES.md",
43
- "size_bytes": 1430,
44
- "sha256": "b2a7065a2eca2937bf7143c850a3a7a72b5277ac1f6eca568f4201cbfc952cbc"
45
  },
46
  {
47
  "path": "THIRD_PARTY_NOTICES.md",
@@ -50,13 +62,13 @@
50
  },
51
  {
52
  "path": "USER_GUIDE.md",
53
- "size_bytes": 7674,
54
- "sha256": "8a7497cd9a4412005e8961d29fefe03a8bc5325c2d339be1273842706181a036"
55
  },
56
  {
57
  "path": "VALIDATION.md",
58
- "size_bytes": 1703,
59
- "sha256": "043908f04dd56f16cfc504b6ee3452abf39c5d863382317551272df4c1cad782"
60
  },
61
  {
62
  "path": "checkpoints/initial_v1/table/best/config.json",
@@ -80,13 +92,13 @@
80
  },
81
  {
82
  "path": "compose.cpu.yml",
83
- "size_bytes": 391,
84
- "sha256": "16c9a2b3ccef56a4a9a8b68c5c689ff63c73b6677cfb3e416c9008653a09f7b5"
85
  },
86
  {
87
  "path": "compose.gpu.yml",
88
- "size_bytes": 405,
89
- "sha256": "56f8bc78a062f347d6f441f5ce13de8e5734d79bd355c93c9be9d7ce5e8cf533"
90
  },
91
  {
92
  "path": "deploy/models/PP-OCRv5_mobile_det/README.md",
 
1
  {
2
  "release": "D-OCR preview",
3
+ "date": "2026-11-25",
4
+ "destination": "D-OCR/D-OCR-preview",
5
  "runtime": {
6
  "python": "CPython 3.12",
7
  "platform": "Linux x86-64",
 
10
  "validation": {
11
  "cpu_container": "passed",
12
  "compiled_gpu_runtime": "passed",
13
+ "gpu_container": "not tested",
14
+ "automatic_downloads": "all selected SHA256 checks passed",
15
+ "automatic_download_cpu_container": "unvalidated: image assembled, Docker unpack failed due to host disk space"
16
  },
17
  "files": [
18
  {
19
  "path": ".dockerignore",
20
+ "size_bytes": 124,
21
+ "sha256": "e33f95d1572337075729f0c59c5036ca1b04905d409c4ce8d3aeeb8bb02a2657"
22
  },
23
  {
24
  "path": ".gitattributes",
 
27
  },
28
  {
29
  "path": "Dockerfile",
30
+ "size_bytes": 6792,
31
+ "sha256": "5de9bd8ef55a3151ddf05d862c5351f2ecbac55e9e875136475a1c92b2445991"
32
+ },
33
+ {
34
+ "path": "Dockerfile.cpu",
35
+ "size_bytes": 6792,
36
+ "sha256": "625381ac308b844814648e6b249a7efb0679dabccbb51aa0387adc851f668730"
37
+ },
38
+ {
39
+ "path": "Dockerfile.gpu",
40
+ "size_bytes": 6792,
41
+ "sha256": "5de9bd8ef55a3151ddf05d862c5351f2ecbac55e9e875136475a1c92b2445991"
42
  },
43
  {
44
  "path": "LICENSE",
 
47
  },
48
  {
49
  "path": "README.md",
50
+ "size_bytes": 10324,
51
+ "sha256": "35ed5b9e0522962f38c388e478453aeb13e9a2ee56c61e83b641f516ba281a95"
52
  },
53
  {
54
  "path": "RELEASE_FILES.md",
55
+ "size_bytes": 1627,
56
+ "sha256": "91f17ebdcf7d85fd8af56d816cd804e495b5799cf9f29524d9390cf48dcf3a8f"
57
  },
58
  {
59
  "path": "THIRD_PARTY_NOTICES.md",
 
62
  },
63
  {
64
  "path": "USER_GUIDE.md",
65
+ "size_bytes": 9430,
66
+ "sha256": "9f7235ab1735f7887691ffaa07230a144f864e80722801c1bcf32bebaa576f05"
67
  },
68
  {
69
  "path": "VALIDATION.md",
70
+ "size_bytes": 3418,
71
+ "sha256": "82ef542cb41677100b02663de397cdc070002f01eb84d1fcf776ddce2c6b1b13"
72
  },
73
  {
74
  "path": "checkpoints/initial_v1/table/best/config.json",
 
92
  },
93
  {
94
  "path": "compose.cpu.yml",
95
+ "size_bytes": 584,
96
+ "sha256": "6e664066e997182c8820ce7366232d0b4e477488f499436968a16b626394c2a1"
97
  },
98
  {
99
  "path": "compose.gpu.yml",
100
+ "size_bytes": 599,
101
+ "sha256": "8bc2fa5ca63f5acf02730d8ab181c4ec246bd34f780ff5f6f9e479b81c2bbee2"
102
  },
103
  {
104
  "path": "deploy/models/PP-OCRv5_mobile_det/README.md",
README.md CHANGED
@@ -13,20 +13,22 @@ tags:
13
  - preview
14
  ---
15
 
16
- # D-OCR-preview
17
 
18
- D-OCR is a Bangla OCR framework that combines document layout detection,
19
- text detection, table structure recognition and text recognition.
 
 
 
 
 
 
20
 
21
- **This release is intended for developers and researchers to test on their own
22
  Bangla documents and share feedback. A compatible NVIDIA GPU is recommended for
23
  interactive testing. CPU inference is supported, but it is currently slow,
24
  especially for long documents. Improving CPU efficiency is a development priority;
25
- this preview does not include a quantized or otherwise CPU-optimized recognizer.**
26
-
27
-
28
- **All four model components are included:** the project layout checkpoint, project
29
- table-structure checkpoint, pretrained text detector, and trained recognizer. This repository distributes the complete inference pipeline.
30
 
31
  ## What is included
32
 
@@ -37,15 +39,31 @@ This is a multi-model framework, not a single standalone OCR checkpoint:
37
  | Project Layout-S checkpoint | [inference.pdiparams](deploy/models/layout_s_paddle322/inference.pdiparams) | Detect document regions and support reading order |
38
  | Project Table Transformer checkpoint | [model.safetensors](checkpoints/initial_v1/table/best/model.safetensors) | Recover table structure and cell geometry |
39
  | Pretrained PP-OCRv5 mobile text detector | [inference.pdiparams](deploy/models/PP-OCRv5_mobile_det/inference.pdiparams) | Locate text for crop preparation |
40
- | Trained recognizer | [best.pt](checkpoints/siglip_qwen/best.pt) | Read text crops and table-cell text |
41
-
42
-
43
-
44
- The recognizer uses SigLIP2 visual tower, an MLP connector and Qwen's text
45
- backbone. The trained recognizer weights
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  are stored together in `checkpoints/siglip_qwen/best.pt`; the layout, detector and
47
  table assets are separate. Tokenizer and processor/configuration files are also
48
- required.
49
 
50
  The shared pipeline handles crop preprocessing, layout-aware reading order,
51
  table reconstruction and text/HTML outputs. All weights and configuration assets
@@ -53,21 +71,22 @@ are included. The API accepts images and PDFs and loads models locally.
53
 
54
  ## Download and run
55
 
56
- Download **all repository files from the Hugging Face repo (weights, configs, runtime, Docker files)** and follow [USER_GUIDE.md](USER_GUIDE.md).
57
- The release includes a compiled Linux x86-64 / CPython 3.12 API runtime and
58
- Docker/Compose files for GPU and CPU. The original browser frontend and Python
59
- application source are not included. A PyPI package is not required for this
60
- preview: Docker supplies the executable framework and HTTP API.
 
 
61
 
62
- After downloading the files and creating your private `.env.runtime` API key as
63
- shown in the guide, start the GPU service:
64
 
65
  ```bash
66
- docker compose -p docr-preview -f compose.gpu.yml build
67
- docker compose -p docr-preview -f compose.gpu.yml up -d --wait --wait-timeout 360
68
  ```
69
 
70
- For CPU, replace `compose.gpu.yml` with `compose.cpu.yml` in both commands.
 
71
  Open **http://localhost:8000/docs** to authorize and upload an image/PDF.
72
  Results include extracted text, region/table geometry, original-layout HTML and
73
  reading-order HTML. The guide shows how to save and open both HTML views.
@@ -94,7 +113,7 @@ standalone release checks and their status.
94
  The following is a local comparison on a fixed cohort of 448 labeled crops.
95
  It measures crop recognition, not end-to-end page or table accuracy.
96
 
97
- | Metric | Previous recognizer | Preview recognizer |
98
  | --- | ---: | ---: |
99
  | Character error rate | 9.57% | 4.90% |
100
  | Word error rate | 23.45% | 14.53% |
@@ -127,32 +146,41 @@ not minimum hardware requirements or throughput predictions for other CPUs.
127
  time. The current service processes one inference job at a time.
128
  - Layout detection, reading order and table reconstruction remain experimental.
129
  Regions may be missed or assigned an incorrect order; tables may not yield a
130
- valid grid.
131
  - The inherited page pipeline applies OCR to at most 200 detected lines. Review
132
  returned warnings on dense pages.
133
  - Text can be misread, omitted or repeated. Crop-dependent generation limits can
134
  truncate output. Repetition stopping can also shorten legitimate repeated text.
135
  - Detection scores are not calibrated text-recognition confidence scores.
136
- - The evaluation emphasizes Bangla and English. Broad multilingual performance, arbitrary
137
  mathematical notation and every handwriting style are not established.
138
  - Default API upload limits are 16 MiB per file, 20 PDF pages, 144 DPI PDF
139
  rendering, and 20 megapixels per page.
 
 
 
140
 
141
  Review OCR output before using it as an authoritative transcription.
142
 
143
- ## Roadmap
 
 
 
 
 
 
 
 
 
144
 
145
- **Coming soon:**
146
- - **vLLM:** high-throughput GPU serving.
147
- - **llama.cpp:** lightweight local and CPU inference.
148
- - **ONNX:** portable inference across runtimes and hardware.
149
- - **OpenVINO:** optimised inference on Intel CPUs and GPUs.
150
 
151
- **Ongoing work** (development priorities):
152
- - faster CPU inference with lower memory use;
153
- - broader independent evaluation of layout, tables and recognition;
154
- - better handling of difficult handwriting and dense layouts;
155
- - simpler installation and a cleaner package interface.
156
 
157
  ## Release license
158
 
 
13
  - preview
14
  ---
15
 
16
+ # D-OCR Preview — Complete Bangla OCR Pipeline
17
 
18
+ **All four model components are included:** the project layout checkpoint, project
19
+ table-structure checkpoint, pretrained text detector, and trained SigLIP2/Qwen
20
+ recognizer. This repository distributes the complete inference pipeline.
21
+
22
+ D-OCR is a modular Bangla OCR framework that combines document layout detection,
23
+ text detection, table structure recognition and text recognition. This preview
24
+ introduces a SigLIP2 NaFlex vision encoder connected to the Qwen3.5-0.8B text
25
+ model, while retaining the existing document processing and reconstruction pipeline.
26
 
27
+ This release is intended for developers and researchers to test on their own
28
  Bangla documents and share feedback. A compatible NVIDIA GPU is recommended for
29
  interactive testing. CPU inference is supported, but it is currently slow,
30
  especially for long documents. Improving CPU efficiency is a development priority;
31
+ this preview does not include a quantized or otherwise CPU-optimized recognizer.
 
 
 
 
32
 
33
  ## What is included
34
 
 
39
  | Project Layout-S checkpoint | [inference.pdiparams](deploy/models/layout_s_paddle322/inference.pdiparams) | Detect document regions and support reading order |
40
  | Project Table Transformer checkpoint | [model.safetensors](checkpoints/initial_v1/table/best/model.safetensors) | Recover table structure and cell geometry |
41
  | Pretrained PP-OCRv5 mobile text detector | [inference.pdiparams](deploy/models/PP-OCRv5_mobile_det/inference.pdiparams) | Locate text for crop preparation |
42
+ | Trained SigLIP2 + connector + Qwen text recognizer | [best.pt](checkpoints/siglip_qwen/best.pt) | Read text crops and table-cell text |
43
+
44
+ The published layout and table weight files have been checked against the local
45
+ project checkpoints used by D-OCR and match their SHA256 hashes. The layout folder
46
+ contains the compatible inference export; it is not a replacement download of a
47
+ generic upstream model. Matching configs/processors/tokenizers are included in
48
+ the corresponding folders. See [RELEASE_FILES.md](RELEASE_FILES.md) for the inventory.
49
+
50
+ Hugging Face's base-model tree describes model ancestry, not repository contents.
51
+ This repository packages several independently loaded components, so its card does
52
+ not label the entire pipeline as a Qwen fine-tune. The recognizer's upstream
53
+ architectures are [Google SigLIP2](https://huggingface.co/google/siglip2-so400m-patch16-naflex)
54
+ and [Qwen3.5-0.8B](https://huggingface.co/Qwen/Qwen3.5-0.8B); other components retain
55
+ their separate architectures and weights.
56
+
57
+ Counting SigLIP2 and Qwen separately gives five main pretrained model parts:
58
+ layout, table structure, text detector, SigLIP2 and Qwen, plus the trained
59
+ connector. They are packaged as four weight files. The previous VCA recognizer
60
+ is not included and is not required by this preview.
61
+
62
+ The recognizer uses SigLIP2 visual features, an MLP connector and Qwen's text
63
+ backbone. Qwen's original vision tower is not used. The trained recognizer weights
64
  are stored together in `checkpoints/siglip_qwen/best.pt`; the layout, detector and
65
  table assets are separate. Tokenizer and processor/configuration files are also
66
+ required. No training is needed to run the supplied checkpoints.
67
 
68
  The shared pipeline handles crop preprocessing, layout-aware reading order,
69
  table reconstruction and text/HTML outputs. All weights and configuration assets
 
71
 
72
  ## Download and run
73
 
74
+ Download just **`Dockerfile.gpu` + `compose.gpu.yml`**, or **`Dockerfile.cpu` +
75
+ `compose.cpu.yml`**, and follow [USER_GUIDE.md](USER_GUIDE.md). Docker automatically
76
+ downloads and verifies all required model assets and the compiled Linux x86-64 /
77
+ CPython 3.12 runtime during the build. No host Python installation, source checkout
78
+ or manual weight download is needed. Downloads are cached, and inference runs
79
+ offline afterward. The original browser frontend and Python application source
80
+ are not included; `/docs` provides the browser API testing interface.
81
 
82
+ After creating your private `.env` API key as shown in the guide, start GPU:
 
83
 
84
  ```bash
85
+ docker compose -f compose.gpu.yml up -d --build --wait --wait-timeout 600
 
86
  ```
87
 
88
+ For CPU, use `compose.cpu.yml` instead. The generic `Dockerfile` also supports
89
+ both `--target cpu` and `--target gpu`.
90
  Open **http://localhost:8000/docs** to authorize and upload an image/PDF.
91
  Results include extracted text, region/table geometry, original-layout HTML and
92
  reading-order HTML. The guide shows how to save and open both HTML views.
 
113
  The following is a local comparison on a fixed cohort of 448 labeled crops.
114
  It measures crop recognition, not end-to-end page or table accuracy.
115
 
116
+ | Metric | Previous VCA recognizer | Preview SigLIP2/Qwen recognizer |
117
  | --- | ---: | ---: |
118
  | Character error rate | 9.57% | 4.90% |
119
  | Word error rate | 23.45% | 14.53% |
 
146
  time. The current service processes one inference job at a time.
147
  - Layout detection, reading order and table reconstruction remain experimental.
148
  Regions may be missed or assigned an incorrect order; tables may not yield a
149
+ valid grid. Successful runtime checks do not establish table/grid accuracy.
150
  - The inherited page pipeline applies OCR to at most 200 detected lines. Review
151
  returned warnings on dense pages.
152
  - Text can be misread, omitted or repeated. Crop-dependent generation limits can
153
  truncate output. Repetition stopping can also shorten legitimate repeated text.
154
  - Detection scores are not calibrated text-recognition confidence scores.
155
+ - The evaluation emphasizes Bangla. Broad multilingual performance, arbitrary
156
  mathematical notation and every handwriting style are not established.
157
  - Default API upload limits are 16 MiB per file, 20 PDF pages, 144 DPI PDF
158
  rendering, and 20 megapixels per page.
159
+ - Linux CPU and one NVIDIA GPU setup have been validated. Windows, macOS, other
160
+ accelerators and minimum-memory configurations are not validated by these tests.
161
+ - APIs, dependency pins and packaging may change during the preview period.
162
 
163
  Review OCR output before using it as an authoritative transcription.
164
 
165
+ ## Development priorities
166
+
167
+ - Improve CPU latency and memory efficiency.
168
+ - Broaden independent evaluation of page layout, tables and text recognition.
169
+ - Improve reliability on difficult handwriting and dense document layouts.
170
+ - Simplify installation and provide a cleaner package interface.
171
+
172
+ These are development priorities, not capabilities already delivered or release-date promises.
173
+
174
+ ## Training and provenance
175
 
176
+ The current adapter loads an existing trained checkpoint; no additional training
177
+ was performed during this framework integration. A complete training-data and
178
+ training-recipe account is not yet included in this preview. Evaluation sources
179
+ must not be listed as training datasets unless verified.
 
180
 
181
+ Upstream components include [SigLIP2](https://huggingface.co/google/siglip2-so400m-patch16-naflex),
182
+ [Qwen3.5](https://huggingface.co/Qwen/Qwen3.5-0.8B), PaddleOCR/PaddleX and Table Transformer.
183
+ Upstream licenses and notices are retained in `THIRD_PARTY_NOTICES.md` and `licenses/`.
 
 
184
 
185
  ## Release license
186
 
RELEASE_FILES.md CHANGED
@@ -1,6 +1,6 @@
1
  # Release contents
2
 
3
- Download the whole repository. The following four model components are required:
4
 
5
  | Path | Contents |
6
  | --- | --- |
@@ -10,12 +10,14 @@ Download the whole repository. The following four model components are required:
10
  | `deploy/models/PP-OCRv5_mobile_det/` | Text detector weights/configuration |
11
  | `checkpoints/initial_v1/table/best/` | Table structure weights/configuration |
12
  | `runtime/docr-runtime-cp312-linux-x86_64.tar.gz` | 48 compiled backend/API modules; CPython 3.12, Linux x86-64 |
13
- | `Dockerfile`, `compose.gpu.yml`, `compose.cpu.yml`, `requirements-runtime.txt` | Runtime installation and service definitions |
14
  | `README.md`, `USER_GUIDE.md`, `VALIDATION.md`, `evaluation.json` | Architecture, usage, validation and aggregate accuracy |
15
  | `LICENSE`, `THIRD_PARTY_NOTICES.md`, `licenses/` | Project and upstream license terms |
16
  | `MANIFEST.json`, `SHA256SUMS` | File sizes and integrity checks |
17
 
18
  No browser frontend, Python application source, training data, test document
19
  images, user uploads, database, API keys or Hugging Face tokens are included.
20
- Models are mounted read-only from the downloaded repository into the container.
21
- The runtime archive is added to the image during the Docker build.
 
 
 
1
  # Release contents
2
 
3
+ Docker downloads the following four model components automatically during the build:
4
 
5
  | Path | Contents |
6
  | --- | --- |
 
10
  | `deploy/models/PP-OCRv5_mobile_det/` | Text detector weights/configuration |
11
  | `checkpoints/initial_v1/table/best/` | Table structure weights/configuration |
12
  | `runtime/docr-runtime-cp312-linux-x86_64.tar.gz` | 48 compiled backend/API modules; CPython 3.12, Linux x86-64 |
13
+ | `Dockerfile`, `Dockerfile.cpu`, `Dockerfile.gpu`, `compose.gpu.yml`, `compose.cpu.yml`, `requirements-runtime.txt` | Runtime installation and service definitions |
14
  | `README.md`, `USER_GUIDE.md`, `VALIDATION.md`, `evaluation.json` | Architecture, usage, validation and aggregate accuracy |
15
  | `LICENSE`, `THIRD_PARTY_NOTICES.md`, `licenses/` | Project and upstream license terms |
16
  | `MANIFEST.json`, `SHA256SUMS` | File sizes and integrity checks |
17
 
18
  No browser frontend, Python application source, training data, test document
19
  images, user uploads, database, API keys or Hugging Face tokens are included.
20
+ Models, matching assets and the runtime archive are downloaded from a pinned
21
+ Hugging Face revision, checksum-verified and included in the image during the
22
+ Docker build. Only uploaded documents/results need a persistent data volume.
23
+ For testing, download just the appropriate Dockerfile and Compose file.
SHA256SUMS CHANGED
@@ -1,18 +1,20 @@
1
- 9a99dec63b197bf3af2ed5c7d8ee86f41b6b66f483de23972c196275694c3be5 .dockerignore
2
  7edc1cbdf9010f524be631611255d6e7ce43957b28be1030439715b03f7cbcea .gitattributes
3
- 36308f1d7a45096f9307db2d0d3eeed298d566f985de95e19590f76eadbab4f2 Dockerfile
 
 
4
  009ede9dcf424a74d680f0c2a73cdec0744be5c2222fb1c17bf6b1de913994b5 LICENSE
5
- e9ee364b67ab5dc94acd5d9bc11ae5204db3cc1e81347127ca9731150ff056ab README.md
6
- b2a7065a2eca2937bf7143c850a3a7a72b5277ac1f6eca568f4201cbfc952cbc RELEASE_FILES.md
7
  3f56026647a1826d304ee1c19546429c1680f06828fd09d5a2dfcd5c181cbbdc THIRD_PARTY_NOTICES.md
8
- 8a7497cd9a4412005e8961d29fefe03a8bc5325c2d339be1273842706181a036 USER_GUIDE.md
9
- 043908f04dd56f16cfc504b6ee3452abf39c5d863382317551272df4c1cad782 VALIDATION.md
10
  211f5a97103c0bb29a1b2f1e2550cfa362d9714269d3be62cbd0ac25ff4a0962 checkpoints/initial_v1/table/best/config.json
11
  7a742f8cc18c52c42fd3fe525d34f1f933932211e0ba8aa27a8defaad438fcb0 checkpoints/initial_v1/table/best/model.safetensors
12
  01fe51c564c48c71e904f42eb4d7679166595b868ff58b2b895b763ce20245e5 checkpoints/initial_v1/table/best/preprocessor_config.json
13
  20cc4c0a72cde62b1d3294a133988fabc4135dd3a13f2811927a35899003cb95 checkpoints/siglip_qwen/best.pt
14
- 16c9a2b3ccef56a4a9a8b68c5c689ff63c73b6677cfb3e416c9008653a09f7b5 compose.cpu.yml
15
- 56f8bc78a062f347d6f441f5ce13de8e5734d79bd355c93c9be9d7ce5e8cf533 compose.gpu.yml
16
  4cc20ad6d41af86b3ce9885ffb0956e152574a2eb14179aeb07fd2d3956161ca deploy/models/PP-OCRv5_mobile_det/README.md
17
  7ac1c33f377ba58561f4b89d3180b6add2b7c5c60a4edac90fa4e0ceccdc6665 deploy/models/PP-OCRv5_mobile_det/config.json
18
  05feef1acb00aa4cd7362b15f7f501fc4f99d7b1fa73c1c871e0c7b1504b0f5c deploy/models/PP-OCRv5_mobile_det/inference.json
@@ -41,4 +43,4 @@ ffcca38841adb694b6f380647e15f17c446a4d1656fed51a1e2041d064c94cc8 licenses/PolyF
41
  c2cfccb812fe482101a8f04597dfc5a9991a6b2748266c47ac91b6a5aae15383 licenses/Table-Transformer-MIT.txt
42
  02ae199640ec49c3b7e55af761ace3e668e4359c702e5985164a4aaa240939d1 requirements-runtime.txt
43
  444026ee7cc6bb42e7ad0e59ef04cad974f2b63e03dfb8372b95838eaf15a2f1 runtime/docr-runtime-cp312-linux-x86_64.tar.gz
44
- 91f1a289c60ccdcf74ba9f66472dbd601ed8eb191aa75de569a6a30219b017ba MANIFEST.json
 
1
+ e33f95d1572337075729f0c59c5036ca1b04905d409c4ce8d3aeeb8bb02a2657 .dockerignore
2
  7edc1cbdf9010f524be631611255d6e7ce43957b28be1030439715b03f7cbcea .gitattributes
3
+ 5de9bd8ef55a3151ddf05d862c5351f2ecbac55e9e875136475a1c92b2445991 Dockerfile
4
+ 625381ac308b844814648e6b249a7efb0679dabccbb51aa0387adc851f668730 Dockerfile.cpu
5
+ 5de9bd8ef55a3151ddf05d862c5351f2ecbac55e9e875136475a1c92b2445991 Dockerfile.gpu
6
  009ede9dcf424a74d680f0c2a73cdec0744be5c2222fb1c17bf6b1de913994b5 LICENSE
7
+ 35ed5b9e0522962f38c388e478453aeb13e9a2ee56c61e83b641f516ba281a95 README.md
8
+ 91f17ebdcf7d85fd8af56d816cd804e495b5799cf9f29524d9390cf48dcf3a8f RELEASE_FILES.md
9
  3f56026647a1826d304ee1c19546429c1680f06828fd09d5a2dfcd5c181cbbdc THIRD_PARTY_NOTICES.md
10
+ 9f7235ab1735f7887691ffaa07230a144f864e80722801c1bcf32bebaa576f05 USER_GUIDE.md
11
+ 82ef542cb41677100b02663de397cdc070002f01eb84d1fcf776ddce2c6b1b13 VALIDATION.md
12
  211f5a97103c0bb29a1b2f1e2550cfa362d9714269d3be62cbd0ac25ff4a0962 checkpoints/initial_v1/table/best/config.json
13
  7a742f8cc18c52c42fd3fe525d34f1f933932211e0ba8aa27a8defaad438fcb0 checkpoints/initial_v1/table/best/model.safetensors
14
  01fe51c564c48c71e904f42eb4d7679166595b868ff58b2b895b763ce20245e5 checkpoints/initial_v1/table/best/preprocessor_config.json
15
  20cc4c0a72cde62b1d3294a133988fabc4135dd3a13f2811927a35899003cb95 checkpoints/siglip_qwen/best.pt
16
+ 6e664066e997182c8820ce7366232d0b4e477488f499436968a16b626394c2a1 compose.cpu.yml
17
+ 8bc2fa5ca63f5acf02730d8ab181c4ec246bd34f780ff5f6f9e479b81c2bbee2 compose.gpu.yml
18
  4cc20ad6d41af86b3ce9885ffb0956e152574a2eb14179aeb07fd2d3956161ca deploy/models/PP-OCRv5_mobile_det/README.md
19
  7ac1c33f377ba58561f4b89d3180b6add2b7c5c60a4edac90fa4e0ceccdc6665 deploy/models/PP-OCRv5_mobile_det/config.json
20
  05feef1acb00aa4cd7362b15f7f501fc4f99d7b1fa73c1c871e0c7b1504b0f5c deploy/models/PP-OCRv5_mobile_det/inference.json
 
43
  c2cfccb812fe482101a8f04597dfc5a9991a6b2748266c47ac91b6a5aae15383 licenses/Table-Transformer-MIT.txt
44
  02ae199640ec49c3b7e55af761ace3e668e4359c702e5985164a4aaa240939d1 requirements-runtime.txt
45
  444026ee7cc6bb42e7ad0e59ef04cad974f2b63e03dfb8372b95838eaf15a2f1 runtime/docr-runtime-cp312-linux-x86_64.tar.gz
46
+ a3ff62dd8db898ca517a13dba22ddc32081f2c43b248a5deaf929aaec44339c6 MANIFEST.json
USER_GUIDE.md CHANGED
@@ -15,60 +15,91 @@ by the local D-OCR app. No training or extra base-model download is needed.
15
  - CPU mode is available but slow. Leave sufficient RAM for the OS and container;
16
  one tested page peaked near 6.52 GiB in the OCR container. This does not bound
17
  memory for all documents. The exact Core i5 laptop has not been benchmarked.
18
- - Disk space for approximately 2.4 GiB of model assets plus Docker dependencies
19
- and persistent uploaded documents. GPU dependencies require additional gigabytes.
 
 
20
 
21
  The runtime is compiled for CPython 3.12 and Linux x86-64. Use the supplied Docker
22
  build to obtain a compatible environment. Windows/macOS native use is not tested.
23
 
24
- ## 2. Download every repository file
25
 
26
- Download the release from `HasinManjare/D-OCR-preview`:
 
 
27
 
28
  ```bash
29
- python3 -m venv hf-download
30
- hf-download/bin/python -m pip install huggingface_hub
31
- hf-download/bin/python -c 'from huggingface_hub import snapshot_download; snapshot_download("HasinManjare/D-OCR-preview", local_dir="D-OCR-preview")'
32
  cd D-OCR-preview
33
- sha256sum -c SHA256SUMS
 
34
  ```
35
 
36
- For repeatable deployments, pass `revision="COMMIT_SHA"` to `snapshot_download`.
37
- Do not download only `best.pt`: the other model, tokenizer and configuration
38
- assets are required. Docker mounts the model directories read-only; keep them
39
- beside the Compose files. The model assets are not duplicated inside the image.
 
 
 
 
 
 
40
 
41
  ## 3. Create a local API key
42
 
43
  ```bash
44
  umask 077
45
- printf 'OCR_API_KEYS=%s\n' "$(openssl rand -hex 32)" > .env.runtime
46
  ```
47
 
48
- Keep `.env.runtime` private. Do not upload it or use the demo key from another
49
- person's installation. The API requires this key in the `X-API-Key` header.
 
 
 
 
 
 
 
 
 
50
 
51
- ## 4. Build and start (GPU recommended)
52
 
53
  ```bash
54
- docker compose -p docr-preview -f compose.gpu.yml build
55
- docker compose -p docr-preview -f compose.gpu.yml up -d --wait --wait-timeout 360
56
  ```
57
 
58
- For CPU instead:
 
 
 
 
 
 
 
 
 
 
 
59
 
60
  ```bash
61
- docker compose -p docr-preview -f compose.cpu.yml build
62
- docker compose -p docr-preview -f compose.cpu.yml up -d --wait --wait-timeout 360
 
 
 
63
  ```
64
 
65
- Use one configuration at a time. When switching, stop the existing stack with
66
- its Compose file first. Use the same project name to preserve the data volume;
67
- never add `-v` if you want to keep saved documents.
68
 
69
- Model inference is offline after dependencies and repository files are downloaded.
70
- GPU uses BF16 autocast for recognition; CPU uses FP32. Paddle layout/text detection
71
- runs on CPU in both modes. One OCR worker serializes inference requests.
 
72
 
73
  ## 5. Check startup and open the API UI
74
 
@@ -78,14 +109,14 @@ curl --fail http://localhost:8000/health
78
 
79
  Expected: `status: ready`, `pipeline: siglip_qwen`, no warmup failures.
80
  Open **http://localhost:8000/docs** in a browser. Select **Authorize**, enter the
81
- API key from your local `.env.runtime`, then use `POST /v1/ocr` to upload an image
82
  or PDF. This is an API testing interface, not the original browser frontend.
83
 
84
  For a shell request:
85
 
86
  ```bash
87
  set -a
88
- . ./.env.runtime
89
  set +a
90
  curl --fail-with-body --max-time 1800 \
91
  -H "X-API-Key: $OCR_API_KEYS" \
@@ -155,7 +186,9 @@ use the bundled runtime to reproduce the full pipeline.
155
  - `no_valid_grid`, `token_limit` or `repetition_stopped` requires review.
156
  - `CUDA unavailable`: check `nvidia-smi` and NVIDIA Container Toolkit. CPU mode is
157
  the fallback; an incompatible GPU cannot be enabled just by changing the flag.
158
- - `Missing ... checkpoint/configuration`: download all files and keep the supplied paths.
 
 
159
  - Startup failure: run `docker compose -p docr-preview -f compose.gpu.yml logs --tail=80`
160
  (replace with `compose.cpu.yml` for CPU). Allow model warmup to finish before requests.
161
  - Port 8000 is bound to localhost by default. This preview does not configure a
 
15
  - CPU mode is available but slow. Leave sufficient RAM for the OS and container;
16
  one tested page peaked near 6.52 GiB in the OCR container. This does not bound
17
  memory for all documents. The exact Core i5 laptop has not been benchmarked.
18
+ - Approximately 2.4 GiB of model downloads, plus runtime dependencies. Allow at
19
+ least 20 GB free on Docker's storage disk for the CPU build and more for GPU.
20
+ Build cache, image layers and unpacked files can occupy several copies during
21
+ the first build. A different project/download disk does not expand Docker storage.
22
 
23
  The runtime is compiled for CPython 3.12 and Linux x86-64. Use the supplied Docker
24
  build to obtain a compatible environment. Windows/macOS native use is not tested.
25
 
26
+ ## 2. Download just the Dockerfile and Compose file
27
 
28
+ No Python installation, source checkout, Git LFS, or manual model download is
29
+ needed on the host. Choose CPU or GPU and download the matching two small files
30
+ into an empty folder. For CPU:
31
 
32
  ```bash
33
+ mkdir D-OCR-preview
 
 
34
  cd D-OCR-preview
35
+ curl -fL -O https://huggingface.co/D-OCR/D-OCR-preview/resolve/main/Dockerfile.cpu
36
+ curl -fL -O https://huggingface.co/D-OCR/D-OCR-preview/resolve/main/compose.cpu.yml
37
  ```
38
 
39
+ For GPU, download `Dockerfile.gpu` and `compose.gpu.yml` instead.
40
+ The generic `Dockerfile` also supports `--target cpu` and `--target gpu`; its
41
+ untargeted build defaults to GPU for compatibility.
42
+
43
+ The build downloads about 2.4 GiB of models, configurations, tokenizers and the
44
+ compiled runtime from `D-OCR/D-OCR-preview`. It pins release revision
45
+ `4b557b4626bdfb39db3d7a0aed120a853092c0db` and checks every downloaded asset's
46
+ size and SHA-256 against that revision's manifest. It also includes license files.
47
+ The trained SigLIP2 encoder, connector and Qwen decoder are all inside `best.pt`.
48
+ No separate upstream model downloads are needed.
49
 
50
  ## 3. Create a local API key
51
 
52
  ```bash
53
  umask 077
54
+ printf 'OCR_API_KEYS=%s\n' "$(openssl rand -hex 32)" > .env
55
  ```
56
 
57
+ Compose reads `.env` automatically. Keep it private. The API requires this key in
58
+ the `X-API-Key` header. Existing installations can use
59
+ `docker compose --env-file .env.runtime ...` to retain their previous key file.
60
+
61
+ ## 4. Build and start
62
+
63
+ CPU:
64
+
65
+ ```bash
66
+ docker compose -f compose.cpu.yml up -d --build --wait --wait-timeout 600
67
+ ```
68
 
69
+ GPU (requires NVIDIA Container Toolkit):
70
 
71
  ```bash
72
+ docker compose -f compose.gpu.yml up -d --build --wait --wait-timeout 600
 
73
  ```
74
 
75
+ The initial build needs internet and may take a while. Completed downloads are
76
+ cached by BuildKit, and the weights are stored in the resulting image. Restarts
77
+ need no model download or host model mounts. The application runs offline after
78
+ building. CPU uses FP32; GPU recognition uses BF16, while Paddle layout/text
79
+ workers use CPU in both modes. One OCR worker serializes inference requests.
80
+
81
+ Use one configuration at a time. Stop the previous stack with its Compose file
82
+ before switching. Both use the `docr-preview` project and persistent data volume.
83
+ Do not pass `down -v` if you want to keep saved documents. Set `OCR_API_PORT` in
84
+ `.env` to change the host port, or `OCR_CPU_THREADS` to change CPU thread counts.
85
+
86
+ You can also use **only a Dockerfile**, without Compose:
87
 
88
  ```bash
89
+ docker build --platform linux/amd64 -f Dockerfile.cpu -t docr-preview:cpu-auto .
90
+ export OCR_API_KEYS="$(openssl rand -hex 32)"
91
+ docker run -d --name docr-preview --init \
92
+ -p 127.0.0.1:8000:8000 -e OCR_API_KEYS \
93
+ -v docr-preview-data:/opt/docr/data docr-preview:cpu-auto
94
  ```
95
 
96
+ For GPU use `Dockerfile.gpu`, tag `docr-preview:gpu-auto`, and add `--gpus all`
97
+ to `docker run`. Keep the generated key for authorization in `/docs`.
 
98
 
99
+ Advanced: `--build-arg HF_REVISION=COMMIT_SHA` selects another compatible release
100
+ with the same manifest/runtime layout. Inference assets are pinned; OS packages
101
+ and some dependencies still have version ranges, so builds are not bit-for-bit
102
+ reproducible. Restarting is fully offline; rebuilding can require internet.
103
 
104
  ## 5. Check startup and open the API UI
105
 
 
109
 
110
  Expected: `status: ready`, `pipeline: siglip_qwen`, no warmup failures.
111
  Open **http://localhost:8000/docs** in a browser. Select **Authorize**, enter the
112
+ API key from your local `.env`, then use `POST /v1/ocr` to upload an image
113
  or PDF. This is an API testing interface, not the original browser frontend.
114
 
115
  For a shell request:
116
 
117
  ```bash
118
  set -a
119
+ . ./.env
120
  set +a
121
  curl --fail-with-body --max-time 1800 \
122
  -H "X-API-Key: $OCR_API_KEYS" \
 
186
  - `no_valid_grid`, `token_limit` or `repetition_stopped` requires review.
187
  - `CUDA unavailable`: check `nvidia-smi` and NVIDIA Container Toolkit. CPU mode is
188
  the fallback; an incompatible GPU cannot be enabled just by changing the flag.
189
+ - `Missing ... checkpoint/configuration`: rebuild the image and check download/checksum errors in the build log.
190
+ - `no space left on device` during image export: free space on Docker's storage
191
+ disk, then rebuild. Do not delete volumes containing documents to free build space.
192
  - Startup failure: run `docker compose -p docr-preview -f compose.gpu.yml logs --tail=80`
193
  (replace with `compose.cpu.yml` for CPU). Allow model warmup to finish before requests.
194
  - Port 8000 is bound to localhost by default. This preview does not configure a
VALIDATION.md CHANGED
@@ -25,3 +25,28 @@ The published 448-crop comparison in `evaluation.json` was measured before
25
  packaging. The exported recognizer tensors are unchanged. It is a local
26
  regression comparison with unverified training/test independence, not a certified
27
  unseen benchmark. Full-page layout and table accuracy have not been scored.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  packaging. The exported recognizer tensors are unchanged. It is a local
26
  regression comparison with unverified training/test independence, not a certified
27
  unseen benchmark. Full-page layout and table accuracy have not been scored.
28
+
29
+
30
+ ## Automatic-download packaging — 25 November 2026
31
+
32
+ - Compared the public repository inventory with all current runtime model paths.
33
+ The four weight files are present; SigLIP2 (437 tensors), Qwen (320 tensors),
34
+ and the connector (6 tensors) share the recognizer checkpoint.
35
+ - A clean standalone CPU build downloaded every required asset directly from
36
+ `D-OCR/D-OCR-preview` at revision `4b557b4626bdfb39db3d7a0aed120a853092c0db`.
37
+ All downloaded sizes and SHA-256 checks passed. Runtime extraction, dependency
38
+ installation, `pip check`, and assembly of the CPU image layers passed.
39
+ - Docker's final image unpack failed because the host Docker storage disk ran
40
+ out of space. The new image was removed and only this build's cache was cleaned
41
+ up. End-to-end execution of the new automatic-download image is **not validated**.
42
+ The earlier CPU/runtime checks above do not replace that missing check.
43
+ - Both new Compose configurations validate. Five downloader tests pass, covering
44
+ complete assets, checksum failure, cache reuse/repair, missing components and
45
+ unsafe manifest paths. Independent packaging review found no blocking defect.
46
+ - The full source test suite completed with **166 passed, 2 failed**. Failures:
47
+ `test_new_data.py::test_tfrecord_crc_and_bytes_features` (missing `google_crc32c`)
48
+ and `test_siglip_qwen_cpu.py::test_cpu_int8_preserves_original_and_runs_hybrid_decoder`
49
+ (the local GPU environment invokes Triton on CPU tensors). Neither code path
50
+ was changed; the released CPU service uses FP32, not experimental INT8.
51
+ - The new GPU Docker recipe and Compose are supplied, but GPU image build and
52
+ execution remain unvalidated. This host has no NVIDIA Container Toolkit.
compose.cpu.yml CHANGED
@@ -1,15 +1,20 @@
 
1
  services:
2
  ocr:
3
- image: docr-preview:cpu
 
4
  build:
5
  context: .
 
6
  target: cpu
7
- env_file: [.env.runtime]
8
- ports: ["127.0.0.1:8000:8000"]
 
 
 
 
9
  volumes:
10
  - docr-data:/opt/docr/data
11
- - ./checkpoints:/opt/docr/checkpoints:ro
12
- - ./deploy/models:/opt/docr/deploy/models:ro
13
  restart: unless-stopped
14
  init: true
15
  stop_grace_period: 35m
 
1
+ name: docr-preview
2
  services:
3
  ocr:
4
+ image: docr-preview:cpu-auto
5
+ platform: linux/amd64
6
  build:
7
  context: .
8
+ dockerfile: Dockerfile.cpu
9
  target: cpu
10
+ environment:
11
+ OCR_API_KEYS: ${OCR_API_KEYS:?Set OCR_API_KEYS in .env or export it before starting}
12
+ OCR_DEVICE: cpu
13
+ OMP_NUM_THREADS: ${OCR_CPU_THREADS:-4}
14
+ MKL_NUM_THREADS: ${OCR_CPU_THREADS:-4}
15
+ ports: ["127.0.0.1:${OCR_API_PORT:-8000}:8000"]
16
  volumes:
17
  - docr-data:/opt/docr/data
 
 
18
  restart: unless-stopped
19
  init: true
20
  stop_grace_period: 35m
compose.gpu.yml CHANGED
@@ -1,16 +1,21 @@
 
1
  services:
2
  ocr:
3
- image: docr-preview:gpu
 
4
  build:
5
  context: .
 
6
  target: gpu
7
  gpus: all
8
- env_file: [.env.runtime]
9
- ports: ["127.0.0.1:8000:8000"]
 
 
 
 
10
  volumes:
11
  - docr-data:/opt/docr/data
12
- - ./checkpoints:/opt/docr/checkpoints:ro
13
- - ./deploy/models:/opt/docr/deploy/models:ro
14
  restart: unless-stopped
15
  init: true
16
  stop_grace_period: 35m
 
1
+ name: docr-preview
2
  services:
3
  ocr:
4
+ image: docr-preview:gpu-auto
5
+ platform: linux/amd64
6
  build:
7
  context: .
8
+ dockerfile: Dockerfile.gpu
9
  target: gpu
10
  gpus: all
11
+ environment:
12
+ OCR_API_KEYS: ${OCR_API_KEYS:?Set OCR_API_KEYS in .env or export it before starting}
13
+ OCR_DEVICE: cuda
14
+ OMP_NUM_THREADS: ${OCR_CPU_THREADS:-4}
15
+ MKL_NUM_THREADS: ${OCR_CPU_THREADS:-4}
16
+ ports: ["127.0.0.1:${OCR_API_PORT:-8000}:8000"]
17
  volumes:
18
  - docr-data:/opt/docr/data
 
 
19
  restart: unless-stopped
20
  init: true
21
  stop_grace_period: 35m