doctr-synth-generator 0.2.1__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/PKG-INFO +165 -69
  2. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/README.md +164 -68
  3. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/doctr_synth_generator.egg-info/PKG-INFO +165 -69
  4. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/doctr_synth_generator.egg-info/SOURCES.txt +5 -1
  5. doctr_synth_generator-0.3.0/doctr_synth_generator.egg-info/entry_points.txt +2 -0
  6. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/doctr_synth_generator.egg-info/top_level.txt +3 -0
  7. doctr_synth_generator-0.3.0/generator/__init__.py +8 -0
  8. doctr_synth_generator-0.3.0/generator/__main__.py +73 -0
  9. doctr_synth_generator-0.3.0/generator/api.py +53 -0
  10. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/generator/components/__init__.py +12 -1
  11. doctr_synth_generator-0.3.0/generator/components/config.py +324 -0
  12. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/generator/components/generator.py +11 -11
  13. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/generator/components/page_generator.py +35 -35
  14. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/generator/components/text_renderer.py +16 -13
  15. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/generator/components/text_styling.py +13 -21
  16. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/generator/components/vocab_coverage.py +89 -9
  17. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/generator/dataset_generator.py +106 -73
  18. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/generator/doctr_dataset.py +55 -6
  19. doctr_synth_generator-0.3.0/generator/version.py +1 -0
  20. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/pyproject.toml +4 -0
  21. doctr_synth_generator-0.3.0/scripts/generate_grid.py +180 -0
  22. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/setup.py +1 -1
  23. doctr_synth_generator-0.2.1/generator/__init__.py +0 -4
  24. doctr_synth_generator-0.2.1/generator/components/config.py +0 -272
  25. doctr_synth_generator-0.2.1/generator/version.py +0 -1
  26. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/LICENSE +0 -0
  27. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/doctr_synth_generator.egg-info/dependency_links.txt +0 -0
  28. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/doctr_synth_generator.egg-info/requires.txt +0 -0
  29. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/doctr_synth_generator.egg-info/zip-safe +0 -0
  30. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/generator/augmentations/__init__.py +0 -0
  31. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/generator/augmentations/augmentation_pipeline.py +0 -0
  32. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/generator/augmentations/random_blur.py +0 -0
  33. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/generator/augmentations/random_gaussian_noise.py +0 -0
  34. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/generator/augmentations/random_jpeg_compression.py +0 -0
  35. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/generator/augmentations/random_perspective.py +0 -0
  36. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/generator/augmentations/random_pixel_dropout.py +0 -0
  37. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/generator/augmentations/random_rotate.py +0 -0
  38. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/generator/components/background_downloader.py +0 -0
  39. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/generator/components/background_manager.py +0 -0
  40. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/generator/components/corpus_downloader.py +0 -0
  41. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/generator/components/dataset_balancer.py +0 -0
  42. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/generator/components/dataset_splitter.py +0 -0
  43. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/generator/components/font_downloader.py +0 -0
  44. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/generator/components/font_selector.py +0 -0
  45. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/generator/components/vocabs.py +0 -0
  46. {doctr_synth_generator-0.2.1 → doctr_synth_generator-0.3.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: doctr-synth-generator
3
- Version: 0.2.1
3
+ Version: 0.3.0
4
4
  Summary: A synthetic data generator for training OCR models
5
5
  Author-email: Felix Dittrich <felixdittrich92@gmail.com>
6
6
  Maintainer: Felix Dittrich
@@ -250,11 +250,13 @@ Dynamic: license-file
250
250
  ![Build Status](https://github.com/felixdittrich92/docTR-Synth-Generator/workflows/builds/badge.svg)
251
251
  [![codecov](https://codecov.io/gh/felixdittrich92/docTR-Synth-Generator/graph/badge.svg?token=31MDR20JGI)](https://codecov.io/gh/felixdittrich92/docTR-Synth-Generator)
252
252
  [![CodeFactor](https://www.codefactor.io/repository/github/felixdittrich92/doctr-synth-generator/badge)](https://www.codefactor.io/repository/github/felixdittrich92/doctr-synth-generator)
253
- [![Pypi](https://img.shields.io/badge/pypi-v0.2.1-blue.svg)](https://pypi.org/project/docTR-Synth-Generator/)
253
+ [![Pypi](https://img.shields.io/badge/pypi-v0.3.0a0-blue.svg)](https://pypi.org/project/docTR-Synth-Generator/)
254
254
 
255
255
  # docTR-Synth-Generator
256
256
  A tool to generate synthetic OCR datasets - made for docTR
257
257
 
258
+ ![Examples: detection pages and recognition crops](https://github.com/felixdittrich92/docTR-Synth-Generator/raw/main/docs/examples_grid.png)
259
+
258
260
  ## Features
259
261
 
260
262
  - **Zero-config**: generate a dataset with nothing but an output directory - real
@@ -275,87 +277,98 @@ A tool to generate synthetic OCR datasets - made for docTR
275
277
  - **Fast & memory-bounded**: font objects and decoded backgrounds are cached, with
276
278
  a configurable cache size.
277
279
 
278
- ## Quickstart (zero configuration)
280
+ ## Quickstart
279
281
 
280
- You no longer need to provide a wordlist or a font directory. With nothing but an
281
- output directory and a count, the generator downloads real words for the
282
- requested language(s) and automatically fetches matching open-source fonts:
282
+ One call - the words, fonts and backgrounds it needs are downloaded and cached
283
+ automatically. English by default:
283
284
 
284
285
  ```python
285
- from generator import GenerationConfig, SyntheticDatasetGenerator
286
+ from generator import generate_dataset
286
287
 
287
- config = GenerationConfig(output_dir="output_dataset", num_images=1000) # English by default
288
- SyntheticDatasetGenerator(config).generate_dataset()
288
+ generate_dataset("output_dataset", num_images=1000)
289
289
  ```
290
290
 
291
- Multilingual is a one-liner - a language code selects both its words *and* its
292
- script, so the correct fonts are pulled in for you:
291
+ Multilingual is just a list of ISO 639-1 codes; each code selects its words *and*
292
+ its script, so matching fonts are pulled in and complex scripts are shaped
293
+ correctly:
293
294
 
294
295
  ```python
295
- config = GenerationConfig(
296
- output_dir="output_dataset",
297
- num_images=10000,
298
- languages=["en", "de", "ru", "el", "ar"], # words + fonts resolved automatically
299
- bg_image_dir="resources/background_images", # optional; blank backgrounds otherwise
300
- )
301
- SyntheticDatasetGenerator(config).generate_dataset()
296
+ generate_dataset("output_dataset", num_images=10000, languages=["en", "de", "ru", "el", "ar"])
302
297
  ```
303
298
 
304
- > The first run downloads word lists and fonts from public mirrors and caches
305
- > them (`corpus_cache_dir` / `font_cache_dir`). Subsequent runs are offline. To
306
- > run fully offline from the start, supply your own `wordlist_path` and
307
- > `font_dir`.
299
+ Detection pages instead of recognition crops:
308
300
 
309
- ## Bring your own resources (classic usage)
301
+ ```python
302
+ generate_dataset("pages", num_images=5000, task="detection", languages=["en", "de"])
303
+ ```
310
304
 
311
- Supplying a `wordlist_path` and/or `font_dir` still works and takes precedence
312
- over the automatic downloads:
305
+ ...or straight from the command line (installs as `doctr-synth`, also runnable as `python -m generator`):
313
306
 
314
- ```python
315
- config = GenerationConfig(
316
- wordlist_path="resources/corpus/latin_ext_balanced_words.txt",
317
- font_dir="resources/font", # e.g. the extracted fonts_v1 release
318
- bg_image_dir="resources/background_images", # bundled with the repo
319
- output_dir="output_dataset",
320
- num_images=1000,
321
- val_percent=0.2,
322
- num_workers=6,
323
- # If a word contains characters none of your local fonts cover, download a
324
- # matching font instead of dropping the word (default: True):
325
- auto_download_fonts=True,
326
- )
327
- SyntheticDatasetGenerator(config).generate_dataset()
307
+ ```bash
308
+ doctr-synth output_dataset -n 10000 -l en de ru
309
+ doctr-synth pages -t detection -l en de --layout newspaper
328
310
  ```
329
311
 
330
- ## Automatic fonts
312
+ > The first run downloads word lists, fonts and backgrounds from public mirrors
313
+ > and caches them; later runs are offline. To stay fully offline from the start,
314
+ > supply your own `wordlist_path` and `font_dir` (see below).
315
+
316
+ `generate_dataset(...)` is a thin wrapper over the `GenerationConfig` +
317
+ `SyntheticDatasetGenerator` pair you can still use directly for full control. The
318
+ config is organised into focused sub-configs (`core`, `resources`, `corpus`,
319
+ `balance`, `coverage`, `recognition`, `realism`, `detection`) - build it nested,
320
+ or use `GenerationConfig.flat(...)` to pass flat keyword names. Any of those
321
+ keywords can also be passed straight to `generate_dataset(...)`:
331
322
 
332
- When no local font covers every character of a word, a matching open-source font
333
- (from the [Noto](https://fonts.google.com/noto) family, which spans the whole
334
- Unicode range) is downloaded, verified for coverage and cached. This prevents
335
- words from being silently skipped - the main cause of biased, latin-only
336
- datasets. Disable with `auto_download_fonts=False`.
323
+ ```python
324
+ from generator import GenerationConfig, CoreConfig, DetectionConfig
337
325
 
338
- ## Automatic words
326
+ # nested - group related options together
327
+ cfg = GenerationConfig(
328
+ core=CoreConfig(num_images=10_000, task="detection", languages=["en", "de"]),
329
+ detection=DetectionConfig(layout="newspaper"),
330
+ )
339
331
 
340
- When no `wordlist_path` is given, real frequency-ranked words for `languages`
341
- are downloaded (from the open
342
- [FrequencyWords](https://github.com/hermitdave/FrequencyWords) project, ~85
343
- languages) and cleaned (script filtering, length bounds, punctuation removal).
344
- Two realism helpers are applied by default and can be tuned or disabled:
332
+ # ...or flat, routed into the sub-configs for you
333
+ cfg = GenerationConfig.flat(num_images=10_000, task="detection", det_layout="newspaper")
345
334
 
346
- - `casing_variant_prob` (0.3): adds Title/UPPERCASE variants so the model sees
347
- capital letters (frequency lists are almost all lowercase).
348
- - `numeric_token_ratio` (0.05): mixes in realistic numbers, dates, prices and
349
- codes - the kind of content real documents are full of.
335
+ # ...or just the one-liner
336
+ generate_dataset("output_dataset", num_images=10_000, languages=["en", "de"], output_jpeg=True, num_workers=8)
337
+ ```
350
338
 
351
- ## Automatic backgrounds
339
+ ### Bring your own resources
352
340
 
353
- When no `bg_image_dir` is given, a curated set of background images is downloaded
354
- and cached automatically (instead of producing blank backgrounds). Supplying your
355
- own `bg_image_dir` takes precedence and skips the download entirely - exactly like
356
- fonts and word lists. Disable with `auto_download_backgrounds=False`, point
357
- `background_cache_dir` somewhere persistent, or pass a `background_manifest_url`
358
- (a newline-separated list of filenames/URLs) to use a different collection.
341
+ `wordlist_path` and/or `font_dir` take precedence over the automatic downloads
342
+ (e.g. the bundled `resources/` or the `fonts_v1` release):
343
+
344
+ ```python
345
+ generate_dataset(
346
+ "output_dataset",
347
+ num_images=1000,
348
+ wordlist_path="resources/corpus/latin_ext_balanced_words.txt",
349
+ font_dir="resources/font",
350
+ bg_image_dir="resources/background_images",
351
+ )
352
+ ```
353
+
354
+ ## Automatic resources
355
+
356
+ On the first run anything you don't provide is fetched from public mirrors and
357
+ cached (later runs are offline). Providing your own `font_dir` / `wordlist_path`
358
+ / `bg_image_dir` takes precedence and skips the matching download.
359
+
360
+ - **Fonts** - when no local font covers every character of a word, a matching
361
+ open-source [Noto](https://fonts.google.com/noto) font is downloaded, verified
362
+ and cached, so words are never silently skipped (the usual cause of biased,
363
+ latin-only datasets). Disable with `auto_download_fonts=False`.
364
+ - **Words** - with no `wordlist_path`, real frequency-ranked words come from
365
+ [FrequencyWords](https://github.com/hermitdave/FrequencyWords) (~85 languages)
366
+ and are cleaned (script filter, length bounds, punctuation removal). Two realism
367
+ helpers are on by default: `casing_variant_prob` (0.3) adds Title/UPPERCASE
368
+ variants, and `numeric_token_ratio` (0.05) mixes in numbers, dates and prices.
369
+ - **Backgrounds** - with no `bg_image_dir`, a curated background set is downloaded
370
+ instead of blank pages. Disable with `auto_download_backgrounds=False`, or pass
371
+ a `background_manifest_url` for your own collection.
359
372
 
360
373
  ## Dataset balancing
361
374
 
@@ -363,7 +376,7 @@ For multilingual runs the language mix is explicit and controllable instead of
363
376
  being dominated by whichever language has the most words:
364
377
 
365
378
  ```python
366
- config = GenerationConfig(
379
+ config = GenerationConfig.flat(
367
380
  output_dir="output_dataset",
368
381
  num_images=30000,
369
382
  languages=["en", "de", "ru"],
@@ -379,6 +392,51 @@ generation (per-language train/val counts, train/val overlap, distinct/rare
379
392
  characters, word-length statistics); silence it with
380
393
  `print_balance_report=False`.
381
394
 
395
+ ## Supported languages
396
+
397
+ Pass ISO 639-1 codes in `languages=[...]`. Each code resolves three things
398
+ automatically: real words from a public frequency list (when one exists), a
399
+ script-matching open-source font (downloaded on demand), and the docTR vocab
400
+ used for coverage and for the recognition vocab restriction. Complex scripts are
401
+ shaped correctly - Arabic, Hebrew and Urdu run right-to-left, and Indic, Thai and
402
+ Myanmar clusters (consonant conjuncts, matras, medials, vowel signs and viramas)
403
+ are built as valid grapheme clusters, including in synthesised coverage tokens.
404
+
405
+ | Script | Languages (ISO 639-1 code) |
406
+ | --- | --- |
407
+ | Latin | Afrikaans (`af`), Azerbaijani (`az`), Catalan (`ca`), Czech (`cs`), Danish (`da`), Dutch (`nl`), English (`en`), Estonian (`et`), Basque (`eu`), Finnish (`fi`), French (`fr`), German (`de`), Hungarian (`hu`), Icelandic (`is`), Indonesian (`id`), Irish (`ga`), Italian (`it`), Latvian (`lv`), Lithuanian (`lt`), Maltese (`mt`), Norwegian (`no`/`nb`), Polish (`pl`), Portuguese (`pt`), Romanian (`ro`), Slovak (`sk`), Slovene (`sl`), Spanish (`es`), Albanian (`sq`), Swedish (`sv`), Croatian (`hr`), Turkish (`tr`), Vietnamese (`vi`) |
408
+ | Cyrillic | Belarusian (`be`), Bulgarian (`bg`), Macedonian (`mk`), Russian (`ru`), Ukrainian (`uk`) |
409
+ | Greek | Greek (`el`) |
410
+ | Perso-Arabic | Arabic (`ar`), Persian (`fa`), Urdu (`ur`) |
411
+ | Hebrew | Hebrew (`he`) |
412
+ | Armenian | Armenian (`hy`) |
413
+ | Georgian | Georgian (`ka`) |
414
+ | Devanagari | Hindi (`hi`), Marathi (`mr`) |
415
+ | Bengali | Bengali (`bn`) |
416
+ | Gujarati | Gujarati (`gu`) |
417
+ | Tamil | Tamil (`ta`) |
418
+ | Telugu | Telugu (`te`) |
419
+ | Kannada | Kannada (`kn`) |
420
+ | Malayalam | Malayalam (`ml`) |
421
+ | Oriya | Odia (`or`) |
422
+ | Sinhala | Sinhala (`si`) |
423
+ | Thai | Thai (`th`) |
424
+ | Myanmar | Burmese (`my`) |
425
+ | CJK | Japanese (`ja`), Korean (`ko`) - corpus-driven only (no fixed small vocab, so vocab-coverage synthesis is skipped) |
426
+
427
+ A few notes:
428
+
429
+ - A handful of languages have a vocab and a font but no public frequency list
430
+ (e.g. Burmese `my`, Odia `or`). They render correctly and their full character
431
+ set is still guaranteed through synthesised coverage tokens - you just won't
432
+ get a real-word corpus unless you supply your own via `wordlist_path`.
433
+ - For **recognition**, any of the 214 keys in ``VOCABS`` (e.g. `"german"`,
434
+ `"arabic"`, `"hindi"`) can be used as ``target_vocab`` / the ``vocab`` argument,
435
+ and several may be combined for a multilingual model
436
+ (`["german", "urdu", "odia"]`); every generated label is then restricted to
437
+ that exact character set so a docTR model trained on the matching vocab never
438
+ sees an un-encodable character (see the docTR training section).
439
+
382
440
  ## Vocabulary coverage (recognition)
383
441
 
384
442
  A recognition model is trained against a fixed character set (docTR's `VOCABS`).
@@ -390,7 +448,7 @@ tokens are synthesised so **every renderable vocab character appears in both the
390
448
  train and val splits**:
391
449
 
392
450
  ```python
393
- config = GenerationConfig(
451
+ config = GenerationConfig.flat(
394
452
  output_dir="dataset",
395
453
  num_images=50000,
396
454
  languages=["de"], # mapped to the "german" vocab automatically
@@ -430,7 +488,7 @@ polygon for every word, ready for
430
488
  [docTR detection training](https://github.com/mindee/doctr/tree/main/references/detection):
431
489
 
432
490
  ```python
433
- config = GenerationConfig(
491
+ config = GenerationConfig.flat(
434
492
  task="detection",
435
493
  output_dir="detection_dataset",
436
494
  num_images=5000, # = number of pages
@@ -521,7 +579,7 @@ treat them the same: recognition yields the label string; detection yields
521
579
  from generator.components import GenerationConfig
522
580
  from generator.doctr_dataset import build_detection_datasets, synth_worker_init_fn
523
581
 
524
- cfg = GenerationConfig(
582
+ cfg = GenerationConfig.flat(
525
583
  task="detection",
526
584
  languages=["en", "de"],
527
585
  num_images=50_000, # POOL size (word variety + vocab coverage)
@@ -543,15 +601,28 @@ train_set, val_set = build_detection_datasets(
543
601
  from generator.components import GenerationConfig
544
602
  from generator.doctr_dataset import build_recognition_datasets, synth_worker_init_fn
545
603
 
546
- cfg = GenerationConfig(task="recognition", languages=["en", "de"], num_images=100_000)
604
+ cfg = GenerationConfig.flat(task="recognition", num_images=100_000)
547
605
  train_set, val_set = build_recognition_datasets(
548
606
  cfg,
549
607
  train_samples=50_000,
550
608
  val_samples=5_000,
609
+ vocab=args.vocab, # e.g. ["german", "urdu", "odia"] - the model's vocab
551
610
  img_transforms=img_transforms, # the script's existing resize/aug
552
611
  )
553
612
  ```
554
613
 
614
+ Pass `vocab` the **same vocab you train the model on** - a `VOCABS` key, a
615
+ literal charset, or a list of keys whose union is the model's vocab (e.g.
616
+ `["german", "urdu", "odia"]`). Every generated label is then guaranteed to
617
+ contain only characters in that vocab, so docTR's label encoder never hits an
618
+ out-of-vocab character (which would otherwise crash training on the first batch).
619
+ Corpus words outside the vocab are dropped, character coverage is guaranteed
620
+ *within* the vocab, and the corpus languages are derived from the vocab keys
621
+ automatically (`german` -> `de`); a key with no corpus (e.g. `odia`) still has
622
+ its characters covered via synthesis. Set `config.languages` explicitly to pull
623
+ different corpora. The same restriction applies to the offline generator via
624
+ `GenerationConfig.flat(target_vocab=[...])`.
625
+
555
626
  The `DataLoader` lines stay as they are - just keep
556
627
  `collate_fn=train_set.collate_fn` and add `worker_init_fn=synth_worker_init_fn`
557
628
  so every worker gets an independent RNG stream:
@@ -618,8 +689,33 @@ improvement over re-loading them per sample. Memory stays bounded and tunable:
618
689
 
619
690
  ## Configuration reference
620
691
 
621
- All behaviour is controlled through `GenerationConfig`; see the dataclass
622
- docstring in `generator/components/config.py` for every field and its default.
692
+ The config is organised into focused sub-configs - `core`, `resources`,
693
+ `corpus`, `balance`, `coverage`, `recognition`, `realism` and `detection` -
694
+ each a small dataclass you can construct on its own. Build `GenerationConfig`
695
+ nested (`GenerationConfig(detection=DetectionConfig(layout="form"))`), or pass
696
+ flat keyword names via `GenerationConfig.flat(...)` / `generate_dataset(...)`,
697
+ which route each keyword into the right sub-config.
698
+
699
+ Most runs need only a handful of options - the ones you are most likely to set
700
+ (as flat keywords):
701
+
702
+ | Option | Sub-config | Default | What it does |
703
+ | --- | --- | --- | --- |
704
+ | `output_dir` | core | - | where the dataset is written (`train/`, `val/`) |
705
+ | `num_images` | core | `1000` | total samples (split by `val_percent`) |
706
+ | `task` | core | `"recognition"` | `"recognition"` crops or `"detection"` pages |
707
+ | `languages` | core | `["en"]` | ISO 639-1 codes; resolves words, fonts and shaping |
708
+ | `val_percent` | core | `0.2` | validation fraction |
709
+ | `num_workers` | core | `4` | parallel worker processes |
710
+ | `output_jpeg` | core | `False` | write JPEG instead of PNG |
711
+ | `target_vocab` | coverage | `None` | recognition: restrict labels to a `VOCABS` key / list (the `vocab=` arg) |
712
+ | `det_layout` | detection | `"mixed"` | detection: `mixed`/`paragraph`/`newspaper`/`form`/`id_card` |
713
+ | `language_balance` | balance | `"balanced"` | `"balanced"` or `"proportional"` allocation across languages |
714
+ | `min_char_coverage` | balance | `0` | ensure every character appears >= N times (0 = off) |
715
+ | `wordlist_path` / `font_dir` / `bg_image_dir` | resources | `None` | bring your own resources (skips the matching download) |
716
+
717
+ For the complete set of options (realism, augmentation and detection-layout
718
+ knobs), see the sub-config dataclasses in `generator/components/config.py`.
623
719
 
624
720
  ## Resources
625
721