label-studio-converter 1.4.0 → 1.5.1

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.
package/README.md CHANGED
@@ -248,10 +248,11 @@ label-studio-converter --help
248
248
 
249
249
  ```
250
250
  USAGE
251
- label-studio-converter toLabelStudio [--outDir value] [--fileName value] [--backup] [--defaultLabelName value] [--toFullJson] [--createFilePerImage] [--createFileListForServing] [--fileListName value] [--baseServerUrl value] [--sortVertical value] [--sortHorizontal value] [--normalizeShape value] [--widthIncrement value] [--heightIncrement value] [--precision value] [--recursive] [--filePattern value] [--outputMode value] <args>...
252
- label-studio-converter toPPOCR [--outDir value] [--fileName value] [--backup] [--baseImageDir value] [--sortVertical value] [--sortHorizontal value] [--normalizeShape value] [--widthIncrement value] [--heightIncrement value] [--precision value] [--recursive] [--filePattern value] <args>...
253
- label-studio-converter enhance-labelstudio [--outDir value] [--fileName value] [--backup] [--sortVertical value] [--sortHorizontal value] [--normalizeShape value] [--widthIncrement value] [--heightIncrement value] [--precision value] [--recursive] [--filePattern value] [--outputMode value] <args>...
254
- label-studio-converter enhance-ppocr [--outDir value] [--fileName value] [--backup] [--sortVertical value] [--sortHorizontal value] [--normalizeShape value] [--widthIncrement value] [--heightIncrement value] [--precision value] [--recursive] [--filePattern value] <args>...
251
+ label-studio-converter toLabelStudio [--outDir value] [--fileName value] [--backup] [--recursive] [--filePattern value] [--copyImages] [--imageBaseDir value] [--sortVertical value] [--sortHorizontal value] [--normalizeShape value] [--useOrientedBox] [--widthIncrement value] [--heightIncrement value] [--adaptResize] [--adaptResizeThreshold value] [--adaptResizeMargin value] [--adaptResizeMinComponentSize value] [--adaptResizeMaxComponentSize value] [--adaptResizeOutlierPercentile value] [--adaptResizeMorphologySize value] [--adaptResizeMaxHorizontalExpansion value] [--adaptResizePaddingCheckWidth value] [--adaptResizeMinPaddingBrightness value] [--adaptResizeMinPaddingRatio value] [--adaptResizeUseAdaptiveThreshold] [--adaptResizeAdaptiveBlockSize value] [--precision value] [--defaultLabelName value] [--toFullJson] [--createFilePerImage] [--createFileListForServing] [--fileListName value] [--baseServerUrl value] [--outputMode value] <args>...
252
+ label-studio-converter toPPOCR [--outDir value] [--fileName value] [--backup] [--recursive] [--filePattern value] [--copyImages] [--imageBaseDir value] [--sortVertical value] [--sortHorizontal value] [--normalizeShape value] [--useOrientedBox] [--widthIncrement value] [--heightIncrement value] [--adaptResize] [--adaptResizeThreshold value] [--adaptResizeMargin value] [--adaptResizeMinComponentSize value] [--adaptResizeMaxComponentSize value] [--adaptResizeOutlierPercentile value] [--adaptResizeMorphologySize value] [--adaptResizeMaxHorizontalExpansion value] [--adaptResizePaddingCheckWidth value] [--adaptResizeMinPaddingBrightness value] [--adaptResizeMinPaddingRatio value] [--adaptResizeUseAdaptiveThreshold] [--adaptResizeAdaptiveBlockSize value] [--precision value] [--baseImageDir value] [--generateFileState] <args>...
253
+ label-studio-converter enhance-labelstudio [--outDir value] [--fileName value] [--backup] [--recursive] [--filePattern value] [--copyImages] [--imageBaseDir value] [--sortVertical value] [--sortHorizontal value] [--normalizeShape value] [--useOrientedBox] [--widthIncrement value] [--heightIncrement value] [--adaptResize] [--adaptResizeThreshold value] [--adaptResizeMargin value] [--adaptResizeMinComponentSize value] [--adaptResizeMaxComponentSize value] [--adaptResizeOutlierPercentile value] [--adaptResizeMorphologySize value] [--adaptResizeMaxHorizontalExpansion value] [--adaptResizePaddingCheckWidth value] [--adaptResizeMinPaddingBrightness value] [--adaptResizeMinPaddingRatio value] [--adaptResizeUseAdaptiveThreshold] [--adaptResizeAdaptiveBlockSize value] [--precision value] [--outputMode value] <args>...
254
+ label-studio-converter enhance-ppocr [--outDir value] [--fileName value] [--backup] [--recursive] [--filePattern value] [--copyImages] [--imageBaseDir value] [--sortVertical value] [--sortHorizontal value] [--normalizeShape value] [--useOrientedBox] [--widthIncrement value] [--heightIncrement value] [--adaptResize] [--adaptResizeThreshold value] [--adaptResizeMargin value] [--adaptResizeMinComponentSize value] [--adaptResizeMaxComponentSize value] [--adaptResizeOutlierPercentile value] [--adaptResizeMorphologySize value] [--adaptResizeMaxHorizontalExpansion value] [--adaptResizePaddingCheckWidth value] [--adaptResizeMinPaddingBrightness value] [--adaptResizeMinPaddingRatio value] [--adaptResizeUseAdaptiveThreshold] [--adaptResizeAdaptiveBlockSize value] [--precision value] <args>...
255
+ label-studio-converter label-studio-output-to-ppocr [--recursive] [--backup] [--filePattern value] (--outDir value) [--fileName value] [--removeBaseImageDir value] [--generateFileState] <args>...
255
256
  label-studio-converter --help
256
257
  label-studio-converter --version
257
258
 
@@ -262,10 +263,11 @@ FLAGS
262
263
  -v --version Print version information and exit
263
264
 
264
265
  COMMANDS
265
- toLabelStudio Convert PPOCRLabel files to Label Studio format
266
- toPPOCR Convert Label Studio files to PPOCRLabel format
267
- enhance-labelstudio Enhance Label Studio files with sorting, normalization, and resizing
268
- enhance-ppocr Enhance PPOCRLabel files with sorting, normalization, and resizing
266
+ toLabelStudio Convert PPOCRLabel files to Label Studio format
267
+ toPPOCR Convert Label Studio files to PPOCRLabel format
268
+ enhance-labelstudio Enhance Label Studio files with sorting, normalization, and resizing
269
+ enhance-ppocr Enhance PPOCRLabel files with sorting, normalization, and resizing
270
+ label-studio-output-to-ppocr Convert Label Studio output files to PPOCRLabel format
269
271
  ```
270
272
 
271
273
  #### Command Flags Reference
@@ -280,12 +282,14 @@ COMMANDS
280
282
  - **Example**: `--outDir ./output` saves all files to `./output/`
281
283
 
282
284
  - `--fileName <name>`: Custom output filename
283
- - **Behavior**: Renames output file (without extension for JSON, with extension for txt)
285
+ - **Behavior**: Renames output file (without extension for JSON, with
286
+ extension for txt)
284
287
  - **Default**:
285
288
  - toLabelStudio: `{source}_full.json` or `{source}_min.json`
286
289
  - toPPOCR: `Label.txt`
287
290
  - enhance commands: Same as input filename
288
- - **Example**: `--fileName MyLabels.txt` creates `MyLabels.txt` instead of `Label.txt`
291
+ - **Example**: `--fileName MyLabels.txt` creates `MyLabels.txt` instead of
292
+ `Label.txt`
289
293
 
290
294
  - `--backup` / `--noBackup`: Create backup before overwriting
291
295
  - **Behavior**: Copies existing file to `{filename}.backup` before overwriting
@@ -295,20 +299,41 @@ COMMANDS
295
299
  - `--recursive` / `--noRecursive`: Search subdirectories
296
300
  - **Behavior**: Processes files in all subdirectories recursively
297
301
  - **Default**: `false` (current directory only)
298
- - **Example**: `--recursive` processes `./data/train/Label.txt` and `./data/test/Label.txt`
302
+ - **Example**: `--recursive` processes `./data/train/Label.txt` and
303
+ `./data/test/Label.txt`
299
304
 
300
305
  - `--filePattern <regex>`: Pattern to match input files
301
306
  - **Behavior**: Only processes files matching regex pattern
302
307
  - **Default**:
303
308
  - PPOCRLabel commands: `.*\.txt$` (all .txt files)
304
309
  - Label Studio commands: `.*\.json$` (all .json files)
305
- - **Example**: `--filePattern "train_.*\.txt$"` only processes files starting with `train_`
310
+ - **Example**: `--filePattern "train_.*\.txt$"` only processes files starting
311
+ with `train_`
306
312
 
307
313
  - `--copyImages` / `--noCopyImages`: Copy images when using --outDir
308
- - **Behavior**: When --outDir is specified, automatically copies/moves images to output directory alongside converted files
314
+ - **Behavior**: When --outDir is specified, automatically copies/moves images
315
+ to output directory alongside converted files
309
316
  - **Default**: `true` (copy images)
310
- - **Example**: `--noCopyImages` keeps images in original location, only copies task files
311
- - **Note**: Only applies to toLabelStudio and toPPOCR converters when --outDir is used
317
+ - **Example**: `--noCopyImages` keeps images in original location, only copies
318
+ task files
319
+ - **Note**: Only applies to toLabelStudio and toPPOCR converters when --outDir
320
+ is used
321
+ - **Note**: Not available for `label-studio-output-to-ppocr` command since it
322
+ only processes Label Studio output files which have no image paths
323
+
324
+ - `--imageBaseDir <dir>`: Controls output directory structure when copying images
325
+ - **Behavior**: Determines how the directory structure is preserved when
326
+ copying images to output directory
327
+ - **Options**: `task-file` (relative to task file), `input-dir` (relative to
328
+ input directory)
329
+ - **Default**: `task-file`
330
+ - **Example**: `--imageBaseDir input-dir --copyImages` preserves full path
331
+ structure from input directory
332
+ - **Use case**: Control whether copied images maintain full path from input
333
+ directory or relative to task file
334
+ - **Note**: Only affects output when --copyImages is used with --outDir
335
+ - **Note**: Not available for `label-studio-output-to-ppocr` command since it
336
+ only processes Label Studio output files which have no image paths
312
337
 
313
338
  **Enhancement Flags:**
314
339
 
@@ -319,16 +344,19 @@ COMMANDS
319
344
  - **Example**: `--sortVertical top-bottom` sorts boxes from top to bottom
320
345
 
321
346
  - `--sortHorizontal <order>`: Horizontal sorting order
322
- - **Behavior**: Sorts bounding boxes by horizontal position (applied after vertical sort)
347
+ - **Behavior**: Sorts bounding boxes by horizontal position (applied after
348
+ vertical sort)
323
349
  - **Options**: `none`, `ltr` (left-to-right), `rtl` (right-to-left)
324
350
  - **Default**: `none` (no sorting)
325
- - **Example**: `--sortHorizontal rtl` sorts boxes right-to-left (for vertical text)
351
+ - **Example**: `--sortHorizontal rtl` sorts boxes right-to-left (for vertical
352
+ text)
326
353
 
327
354
  - `--normalizeShape <option>`: Shape normalization
328
355
  - **Behavior**: Converts diamond/rotated shapes to axis-aligned rectangles
329
356
  - **Options**: `none`, `rectangle`
330
357
  - **Default**: `none` (preserve original shapes)
331
- - **Example**: `--normalizeShape rectangle` converts all polygons to rectangles
358
+ - **Example**: `--normalizeShape rectangle` converts all polygons to
359
+ rectangles
332
360
 
333
361
  - `--widthIncrement <pixels>`: Adjust box width
334
362
  - **Behavior**: Adds pixels to box width (can be negative to shrink)
@@ -352,15 +380,18 @@ COMMANDS
352
380
  **Adaptive Resize Flags (Advanced):**
353
381
 
354
382
  - `--adaptResize` / `--noAdaptResize`: Enable intelligent box resizing
355
- - **Behavior**: Uses image analysis to shrink oversized boxes to fit actual text
383
+ - **Behavior**: Uses image analysis to shrink oversized boxes to fit actual
384
+ text
356
385
  - **Default**: `false` (disabled)
357
386
  - **Use Case**: Sino-Nom OCR datasets with excessive padding
358
387
  - **Example**: `--adaptResize` enables feature with default parameters
359
388
 
360
389
  - `--adaptResizeThreshold <0-255>`: Grayscale threshold
361
- - **Behavior**: Pixels ≥ threshold are considered text (white), < threshold are background (black)
390
+ - **Behavior**: Pixels ≥ threshold are considered text (white), < threshold
391
+ are background (black)
362
392
  - **Default**: `128`
363
- - **Example**: `--adaptResizeThreshold 140` for darker text on light background
393
+ - **Example**: `--adaptResizeThreshold 140` for darker text on light
394
+ background
364
395
 
365
396
  - `--adaptResizeMargin <pixels>`: Padding around detected content
366
397
  - **Behavior**: Additional pixels added on all sides after detection
@@ -378,9 +409,11 @@ COMMANDS
378
409
  - **Example**: `--adaptResizeMaxComponentSize 50000` for smaller characters
379
410
 
380
411
  - `--adaptResizeOutlierPercentile <%>`: Outlier removal
381
- - **Behavior**: Ignores this % of smallest and largest pixels when calculating boundaries
412
+ - **Behavior**: Ignores this % of smallest and largest pixels when calculating
413
+ boundaries
382
414
  - **Default**: `2` (ignore 2% on each end)
383
- - **Example**: `--adaptResizeOutlierPercentile 3` for more aggressive outlier removal
415
+ - **Example**: `--adaptResizeOutlierPercentile 3` for more aggressive outlier
416
+ removal
384
417
 
385
418
  - `--adaptResizeMorphologySize <pixels>`: Stroke connection
386
419
  - **Behavior**: Kernel size for connecting broken character strokes
@@ -388,7 +421,8 @@ COMMANDS
388
421
  - **Example**: `--adaptResizeMorphologySize 3` connects larger gaps
389
422
 
390
423
  - `--adaptResizeMaxHorizontalExpansion <pixels>`: Column overlap prevention
391
- - **Behavior**: Maximum pixels boxes can expand horizontally (CRITICAL for vertical text)
424
+ - **Behavior**: Maximum pixels boxes can expand horizontally (CRITICAL for
425
+ vertical text)
392
426
  - **Default**: `50`
393
427
  - **Example**: `--adaptResizeMaxHorizontalExpansion 30` for closely-spaced columns
394
428
 
@@ -397,10 +431,12 @@ COMMANDS
397
431
  - `--defaultLabelName <name>`: Default label for annotations
398
432
  - **Behavior**: Label assigned to all text regions
399
433
  - **Default**: `"Text"`
400
- - **Example**: `--defaultLabelName "Handwriting"` labels all regions as Handwriting
434
+ - **Example**: `--defaultLabelName "Handwriting"` labels all regions as
435
+ Handwriting
401
436
 
402
437
  - `--toFullJson` / `--noToFullJson`: Output format
403
- - **Behavior**: `true` = Full format (more metadata), `false` = Min format (compact)
438
+ - **Behavior**: `true` = Full format (more metadata), `false` = Min format
439
+ (compact)
404
440
  - **Default**: `true` (Full format)
405
441
  - **Example**: `--noToFullJson` creates minimal format files
406
442
 
@@ -409,7 +445,8 @@ COMMANDS
409
445
  - **Default**: `false` (single file)
410
446
  - **Example**: `--createFilePerImage` creates `image1.json`, `image2.json`, etc.
411
447
 
412
- - `--createFileListForServing` / `--noCreateFileListForServing`: Generate file list
448
+ - `--createFileListForServing` / `--noCreateFileListForServing`: Generate file
449
+ list
413
450
  - **Behavior**: Creates `files.txt` with image URLs for Label Studio import
414
451
  - **Default**: `true` (create file list)
415
452
  - **Example**: `--noCreateFileListForServing` skips file list creation
@@ -420,7 +457,8 @@ COMMANDS
420
457
  - **Example**: `--fileListName "images.txt"` creates `images.txt` instead
421
458
 
422
459
  - `--baseServerUrl <url>`: Base URL for images
423
- - **Behavior**: Prepended to image paths in output JSON (e.g., for local HTTP server)
460
+ - **Behavior**: Prepended to image paths in output JSON (e.g., for local HTTP
461
+ server)
424
462
  - **Default**: `"http://localhost:8081"`
425
463
  - **Example**: `--baseServerUrl "http://192.168.1.100:8080"` for network access
426
464
 
@@ -436,17 +474,44 @@ COMMANDS
436
474
  - `--baseImageDir <path>`: Image directory prefix
437
475
  - **Behavior**: Prepended to image filenames in output `Label.txt`
438
476
  - **Default**: Empty string (no prefix)
439
- - **Example**: `--baseImageDir "images/ch"` writes `images/ch/example.jpg` in Label.txt
477
+ - **Example**: `--baseImageDir "images/ch"` writes `images/ch/example.jpg` in
478
+ Label.txt
479
+
480
+ - `--generateFileState` / `--noGenerateFileState`: Generate file state
481
+ - **Behavior**: Creates `fileState.txt` for each input directory, listing all
482
+ processed files
483
+ - **Default**: `true`
484
+ - **Example**: `--generateFileState` creates `fileState.txt` in each input
485
+ directory
440
486
 
441
487
  ##### Flags Specific to enhance-labelstudio Command
442
488
 
443
489
  - `--outputMode <mode>`: Same as toLabelStudio command
444
490
  - See toLabelStudio flags section above
445
491
 
492
+ ##### Flags Specific to label-studio-output-to-ppocr Command
493
+
494
+ - `--removeBaseImageDir <dir>`: Remove base directory from image paths
495
+ - **Behavior**: Strips specified base directory from image paths in output
496
+ `Label.txt`
497
+ - **Default**: `"/data/local-files/?d="` (removes Label Studio's default local
498
+ file prefix)
499
+ - **Example**: `--removeBaseImageDir "data/"` converts `data/example.jpg` to
500
+ `example.jpg` in Label.txt
501
+
502
+ - `--generateFileState` / `--noGenerateFileState`: Generate file state
503
+ - **Behavior**: Creates `fileState.txt` for each input directory, listing all
504
+ processed files
505
+ - **Default**: `true`
506
+ - **Example**: `--generateFileState` creates `fileState.txt` in each input
507
+ directory
508
+
446
509
  #### Image Path Resolution Logic
447
510
 
448
511
  Understanding how image paths are resolved is critical for organizing your files before conversion. The key is knowing **where you run the command** and **what input parameter you provide**.
449
512
 
513
+ > **New in v1.5.0**: The `--imageBaseDir` flag controls the output directory structure when copying images. It determines whether copied images maintain their path relative to the task file (`task-file`, default) or the input directory (`input-dir`).
514
+
450
515
  ##### toLabelStudio: PPOCRLabel → Label Studio
451
516
 
452
517
  **INPUT Resolution (Reading PPOCRLabel files):**
@@ -459,7 +524,7 @@ Understanding how image paths are resolved is critical for organizing your files
459
524
  - Converter finds: `project/data/Label.txt` (and other Label.txt files in subdirectories if --recursive)
460
525
  - Task file being processed: `project/data/Label.txt`
461
526
 
462
- **How Resolvers Work:**
527
+ **How Image Paths Are Read:**
463
528
 
464
529
  1. **What's in the Label.txt file**:
465
530
  - Path format: `data/example.jpg` (PPOCRLabel standard: folder/filename)
@@ -473,22 +538,30 @@ Understanding how image paths are resolved is critical for organizing your files
473
538
  - YES → resolve from parent: `dirname(project/data/) + data/example.jpg` = `project/data/example.jpg`
474
539
  - NO → resolve from task dir: `project/data/ + example.jpg` = `project/data/example.jpg`
475
540
 
476
- 3. **What the processor receives**:
477
- - Path relative to CWD: `data/example.jpg`
478
- - (This is `relative(project/, project/data/example.jpg)` = `data/example.jpg`)
541
+ **OUTPUT Resolution (Copying images with --copyImages --outDir):**
479
542
 
480
- **OUTPUT Resolution (Writing Label Studio JSON):**
543
+ **With `--imageBaseDir task-file` (default):**
481
544
 
482
- **Command Execution Context:**
545
+ When copying images to output directory, paths are maintained **relative to the task file location**:
483
546
 
484
- - Output location: Same as task file location (no --outDir specified)
485
- - Output file: `project/data/Label_full.json`
547
+ - Input directory: `project/data/` (provided to command)
548
+ - Source image: `project/data/foo/bar/baz/example.jpg`
549
+ - Task file: `project/data/Label.txt`
550
+ - Output dir: `project/output/`
551
+ - Relative from task: `relative(project/data/, project/data/foo/bar/baz/example.jpg)` = `foo/bar/baz/example.jpg`
552
+ - Destination: `project/output/data/foo/bar/baz/example.jpg` (maintains structure relative to task file)
486
553
 
487
- **How Resolvers Work:**
554
+ **With `--imageBaseDir input-dir`:**
488
555
 
489
- 1. **What the processor has**:
490
- - Path relative to CWD: `data/example.jpg`
491
- - (From input resolution step)
556
+ When copying images to output directory, paths are maintained **relative to input directory**:
557
+
558
+ - Input directory: `project/data/` (provided to command)
559
+ - Source image: `project/data/foo/bar/baz/example.jpg`
560
+ - Output dir: `project/output/`
561
+ - Relative from input: `relative(project/data/, project/data/foo/bar/baz/example.jpg)` = `foo/bar/baz/example.jpg`
562
+ - Destination: `project/output/foo/bar/baz/example.jpg` (maintains path from input directory)
563
+ - Path relative to CWD: `data/example.jpg`
564
+ - (From input resolution step)
492
565
 
493
566
  2. **How output resolver formats paths**:
494
567
  - No --outDir: Compute relative path from output JSON to image
@@ -619,7 +692,7 @@ project/
619
692
  - Converter finds: `project/data/export.json` (and other JSON files in subdirectories if --recursive)
620
693
  - Task file being processed: `project/data/export.json`
621
694
 
622
- **How Resolvers Work:**
695
+ **How Image Paths Are Read:**
623
696
 
624
697
  1. **What's in the JSON file**:
625
698
  - Local path: `"ocr": "/example.jpg"` or `"ocr": "example.jpg"`
@@ -634,16 +707,28 @@ project/
634
707
  - Extract filename: `basename(URL)` = `example.jpg`
635
708
  - Download to task directory: `project/data/example.jpg`
636
709
 
637
- 3. **What the processor receives**:
638
- - Path relative to CWD: `data/example.jpg`
639
- - (This is `relative(project/, project/data/example.jpg)` = `data/example.jpg`)
710
+ **OUTPUT Resolution (Copying images with --copyImages --outDir):**
640
711
 
641
- **OUTPUT Resolution (Writing PPOCRLabel Label.txt):**
712
+ **With `--imageBaseDir task-file` (default):**
642
713
 
643
- **Command Execution Context:**
714
+ When copying images to output directory, paths are maintained **relative to the task file location**:
715
+
716
+ - Input directory: `project/data/` (provided to command)
717
+ - Source image: `project/data/foo/bar/baz/example.jpg`
718
+ - Task file: `project/data/export.json`
719
+ - Output dir: `project/output/`
720
+ - Relative from task: `relative(project/data/, project/data/foo/bar/baz/example.jpg)` = `foo/bar/baz/example.jpg`
721
+ - Destination: `project/output/data/foo/bar/baz/example.jpg` (maintains structure relative to task file)
644
722
 
645
- - No --outDir specified: Output at task file location
646
- - Output file: `project/data/Label.txt`
723
+ **With `--imageBaseDir input-dir`:**
724
+
725
+ When copying images to output directory, paths are maintained **relative to input directory**:
726
+
727
+ - Input directory: `project/data/` (provided to command)
728
+ - Source image: `project/data/foo/bar/baz/example.jpg`
729
+ - Output dir: `project/output/`
730
+ - Relative from input: `relative(project/data/, project/data/foo/bar/baz/example.jpg)` = `foo/bar/baz/example.jpg`
731
+ - Destination: `project/output/foo/bar/baz/example.jpg` (maintains path from input directory)
647
732
 
648
733
  **How Resolvers Work:**
649
734
 
@@ -793,6 +878,19 @@ output/example.jpg [{"transcription":"Text","points":[[...]],"dt_score":1}]
793
878
  - Uses `baseImageDir` or output directory basename as folder prefix
794
879
  - Extracts filename from resolved path, prepends folder name
795
880
 
881
+ ##### label-studio-output-to-ppocr: Label Studio Output → PPOCRLabel
882
+
883
+ **INPUT Resolution**:
884
+
885
+ - Reads Label Studio output JSON files
886
+ - Strips `removeBaseImageDir` prefix from image paths (e.g.,
887
+ `data/local-files/?d=example.jpg` → `example.jpg`)
888
+
889
+ **OUTPUT Resolution**:
890
+
891
+ - Generates PPOCRLabel Label.txt with `folder/filename.jpg` format
892
+ - Generates fileState.txt if `--generateFileState` is specified
893
+
796
894
  ---
797
895
 
798
896
  **Key Concepts:**
@@ -839,31 +937,47 @@ label-studio-converter toLabelStudio --help
839
937
 
840
938
  ```
841
939
  USAGE
842
- label-studio-converter toLabelStudio [--outDir value] [--fileName value] [--backup] [--defaultLabelName value] [--toFullJson] [--createFilePerImage] [--createFileListForServing] [--fileListName value] [--baseServerUrl value] [--sortVertical value] [--sortHorizontal value] [--normalizeShape value] [--widthIncrement value] [--heightIncrement value] [--precision value] [--recursive] [--filePattern value] [--outputMode value] <args>...
940
+ label-studio-converter toLabelStudio [--outDir value] [--fileName value] [--backup] [--recursive] [--filePattern value] [--copyImages] [--imageBaseDir value] [--sortVertical value] [--sortHorizontal value] [--normalizeShape value] [--useOrientedBox] [--widthIncrement value] [--heightIncrement value] [--adaptResize] [--adaptResizeThreshold value] [--adaptResizeMargin value] [--adaptResizeMinComponentSize value] [--adaptResizeMaxComponentSize value] [--adaptResizeOutlierPercentile value] [--adaptResizeMorphologySize value] [--adaptResizeMaxHorizontalExpansion value] [--adaptResizePaddingCheckWidth value] [--adaptResizeMinPaddingBrightness value] [--adaptResizeMinPaddingRatio value] [--adaptResizeUseAdaptiveThreshold] [--adaptResizeAdaptiveBlockSize value] [--precision value] [--defaultLabelName value] [--toFullJson] [--createFilePerImage] [--createFileListForServing] [--fileListName value] [--baseServerUrl value] [--outputMode value] <args>...
843
941
  label-studio-converter toLabelStudio --help
844
942
 
845
943
  Convert PPOCRLabel files to Label Studio format
846
944
 
847
945
  FLAGS
848
- [--outDir] Output directory. If not specified, files are saved in the same directory as the source files
849
- [--fileName] Custom output filename (without extension). If not specified, uses source filename with format suffix
850
- [--backup/--noBackup] Create backup of existing files before overwriting. Default: false
851
- [--defaultLabelName] Default label name for text annotations. Default: "Text"
852
- [--toFullJson/--noToFullJson] Convert to Full OCR Label Studio format. Default: "true"
853
- [--createFilePerImage/--noCreateFilePerImage] Create a separate Label Studio JSON file for each image. Default: "false"
854
- [--createFileListForServing/--noCreateFileListForServing] Create a file list for serving in Label Studio. Default: "true"
855
- [--fileListName] Name of the file list for serving. Default: "files.txt"
856
- [--baseServerUrl] Base server URL for constructing image URLs in the file list. Default: "http://localhost:8081"
857
- [--sortVertical] Sort bounding boxes vertically. Options: "none", "top-bottom", "bottom-top". Default: "none"
858
- [--sortHorizontal] Sort bounding boxes horizontally. Options: "none", "ltr", "rtl". Default: "none"
859
- [--normalizeShape] Normalize diamond-like shapes to axis-aligned rectangles. Options: "none", "rectangle". Default: "none"
860
- [--widthIncrement] Increase bounding box width by this amount (in pixels). Can be negative to decrease. Default: 0
861
- [--heightIncrement] Increase bounding box height by this amount (in pixels). Can be negative to decrease. Default: 0
862
- [--precision] Number of decimal places for coordinates. Use -1 for full precision (no rounding). Default: -1
863
- [--recursive/--noRecursive] Recursively search directories for files. Default: false
864
- [--filePattern] Regex pattern to match PPOCRLabel files (should match .txt files). Default: ".*\.txt$"
865
- [--outputMode] Output mode: "annotations" for editable annotations (ground truth) or "predictions" for read-only predictions (pre-annotations). Default: "annotations"
866
- -h --help Print help information and exit
946
+ [--outDir] Output directory. If not specified, files are saved in the same directory as the source files
947
+ [--fileName] Custom output filename (without extension). If not specified, uses source filename with format suffix
948
+ [--backup/--noBackup] Create backup of existing files before overwriting. Default: false
949
+ [--recursive/--noRecursive] Recursively search directories for files. Default: false
950
+ [--filePattern] Regex pattern to match PPOCRLabel files (should match .txt files). Default: ".*\.txt$"
951
+ [--copyImages/--noCopyImages] Copy images to output directory when --outDir is specified. Only applies to toLabelStudio and toPPOCR commands. Default: true
952
+ [--imageBaseDir] Base directory for resolving image paths. Options: "task-file" (relative to task file location), "input-dir" (relative to command execution directory). Default: "task-file"
953
+ [--sortVertical] Sort bounding boxes vertically. Options: "none", "top-bottom", "bottom-top". Default: "none"
954
+ [--sortHorizontal] Sort bounding boxes horizontally. Options: "none", "ltr", "rtl". Default: "none"
955
+ [--normalizeShape] Normalize diamond-like shapes to axis-aligned rectangles. Options: "none", "rectangle". Default: "none"
956
+ [--useOrientedBox/--noUseOrientedBox] Use oriented (rotated) bounding box when normalizing shapes. Useful for skewed text. Default: false
957
+ [--widthIncrement] Increase bounding box width by this amount (in pixels). Can be negative to decrease. Default: 0
958
+ [--heightIncrement] Increase bounding box height by this amount (in pixels). Can be negative to decrease. Default: 0
959
+ [--adaptResize/--noAdaptResize] Apply adaptive resize to automatically adjust bounding boxes based on image content. Default: false
960
+ [--adaptResizeThreshold] Grayscale threshold for adaptive resize (0-255). Default: 128
961
+ [--adaptResizeMargin] Margin pixels around detected content for adaptive resize. Default: 5
962
+ [--adaptResizeMinComponentSize] Minimum component size in pixels (filters dirt/noise). Default: 10
963
+ [--adaptResizeMaxComponentSize] Maximum component size in pixels (filters large artifacts). Default: 100000
964
+ [--adaptResizeOutlierPercentile] Percentile for outlier removal (0-100). Default: 2
965
+ [--adaptResizeMorphologySize] Morphological operation kernel size. Default: 2
966
+ [--adaptResizeMaxHorizontalExpansion] Maximum horizontal expansion in pixels (prevents column overlap). Default: 50
967
+ [--adaptResizePaddingCheckWidth] Width of padding strip to validate (in pixels). Default: 3
968
+ [--adaptResizeMinPaddingBrightness] Minimum brightness for white padding pixels (0-255). Default: 200
969
+ [--adaptResizeMinPaddingRatio] Minimum ratio of white pixels in padding strip (0-1). Default: 0.85
970
+ [--adaptResizeUseAdaptiveThreshold/--noAdaptResizeUseAdaptiveThreshold] Use adaptive thresholding based on image histogram (recommended). Default: true
971
+ [--adaptResizeAdaptiveBlockSize] Block size for adaptive thresholding. Default: 50
972
+ [--precision] Number of decimal places for coordinates. Use -1 for full precision (no rounding). Default: 0 (integers)
973
+ [--defaultLabelName] Default label name for text annotations. Default: "Text"
974
+ [--toFullJson/--noToFullJson] Convert to Full OCR Label Studio format. Default: "true"
975
+ [--createFilePerImage/--noCreateFilePerImage] Create a separate Label Studio JSON file for each image. Default: "false"
976
+ [--createFileListForServing/--noCreateFileListForServing] Create a file list for serving in Label Studio. Default: "true"
977
+ [--fileListName] Name of the file list for serving. Default: "files.txt"
978
+ [--baseServerUrl] Base server URL for constructing image URLs in the file list. Default: "http://localhost:8081"
979
+ [--outputMode] Output mode: "annotations" for editable annotations (ground truth) or "predictions" for read-only predictions (pre-annotations). Default: "annotations"
980
+ -h --help Print help information and exit
867
981
 
868
982
  ARGUMENTS
869
983
  args... Input directories containing PPOCRLabel files
@@ -879,25 +993,42 @@ label-studio-converter toPPOCR --help
879
993
 
880
994
  ```
881
995
  USAGE
882
- label-studio-converter toPPOCR [--outDir value] [--fileName value] [--backup] [--baseImageDir value] [--sortVertical value] [--sortHorizontal value] [--normalizeShape value] [--widthIncrement value] [--heightIncrement value] [--precision value] [--recursive] [--filePattern value] <args>...
996
+ label-studio-converter toPPOCR [--outDir value] [--fileName value] [--backup] [--recursive] [--filePattern value] [--copyImages] [--imageBaseDir value] [--sortVertical value] [--sortHorizontal value] [--normalizeShape value] [--useOrientedBox] [--widthIncrement value] [--heightIncrement value] [--adaptResize] [--adaptResizeThreshold value] [--adaptResizeMargin value] [--adaptResizeMinComponentSize value] [--adaptResizeMaxComponentSize value] [--adaptResizeOutlierPercentile value] [--adaptResizeMorphologySize value] [--adaptResizeMaxHorizontalExpansion value] [--adaptResizePaddingCheckWidth value] [--adaptResizeMinPaddingBrightness value] [--adaptResizeMinPaddingRatio value] [--adaptResizeUseAdaptiveThreshold] [--adaptResizeAdaptiveBlockSize value] [--precision value] [--baseImageDir value] [--generateFileState] <args>...
883
997
  label-studio-converter toPPOCR --help
884
998
 
885
999
  Convert Label Studio files to PPOCRLabel format
886
1000
 
887
1001
  FLAGS
888
- [--outDir] Output directory. If not specified, files are saved in the same directory as the source files
889
- [--fileName] Output PPOCR file name. Default: "Label.txt"
890
- [--backup/--noBackup] Create backup of existing files before overwriting. Default: false
891
- [--baseImageDir] Base directory path to prepend to image filenames in output (e.g., "ch" or "images/ch")
892
- [--sortVertical] Sort bounding boxes vertically. Options: "none", "top-bottom", "bottom-top". Default: "none"
893
- [--sortHorizontal] Sort bounding boxes horizontally. Options: "none", "ltr", "rtl". Default: "none"
894
- [--normalizeShape] Normalize diamond-like shapes to axis-aligned rectangles. Options: "none", "rectangle". Default: "none"
895
- [--widthIncrement] Increase bounding box width by this amount (in pixels). Can be negative to decrease. Default: 0
896
- [--heightIncrement] Increase bounding box height by this amount (in pixels). Can be negative to decrease. Default: 0
897
- [--precision] Number of decimal places for coordinates. Use -1 for full precision (no rounding). Default: 0 (integers)
898
- [--recursive/--noRecursive] Recursively search directories for files. Default: false
899
- [--filePattern] Regex pattern to match Label Studio files (should match .json files). Default: ".*\.json$"
900
- -h --help Print help information and exit
1002
+ [--outDir] Output directory. If not specified, files are saved in the same directory as the source files
1003
+ [--fileName] Output PPOCR file name. Default: "Label.txt"
1004
+ [--backup/--noBackup] Create backup of existing files before overwriting. Default: false
1005
+ [--recursive/--noRecursive] Recursively search directories for files. Default: false
1006
+ [--filePattern] Regex pattern to match Label Studio files (should match .json files). Default: ".*\.json$"
1007
+ [--copyImages/--noCopyImages] Copy images to output directory when --outDir is specified. Only applies to toLabelStudio and toPPOCR commands. Default: true
1008
+ [--imageBaseDir] Base directory for resolving image paths. Options: "task-file" (relative to task file location), "input-dir" (relative to command execution directory). Default: "task-file"
1009
+ [--sortVertical] Sort bounding boxes vertically. Options: "none", "top-bottom", "bottom-top". Default: "none"
1010
+ [--sortHorizontal] Sort bounding boxes horizontally. Options: "none", "ltr", "rtl". Default: "none"
1011
+ [--normalizeShape] Normalize diamond-like shapes to axis-aligned rectangles. Options: "none", "rectangle". Default: "none"
1012
+ [--useOrientedBox/--noUseOrientedBox] Use oriented (rotated) bounding box when normalizing shapes. Useful for skewed text. Default: false
1013
+ [--widthIncrement] Increase bounding box width by this amount (in pixels). Can be negative to decrease. Default: 0
1014
+ [--heightIncrement] Increase bounding box height by this amount (in pixels). Can be negative to decrease. Default: 0
1015
+ [--adaptResize/--noAdaptResize] Apply adaptive resize to automatically adjust bounding boxes based on image content. Default: false
1016
+ [--adaptResizeThreshold] Grayscale threshold for adaptive resize (0-255). Default: 128
1017
+ [--adaptResizeMargin] Margin pixels around detected content for adaptive resize. Default: 5
1018
+ [--adaptResizeMinComponentSize] Minimum component size in pixels (filters dirt/noise). Default: 10
1019
+ [--adaptResizeMaxComponentSize] Maximum component size in pixels (filters large artifacts). Default: 100000
1020
+ [--adaptResizeOutlierPercentile] Percentile for outlier removal (0-100). Default: 2
1021
+ [--adaptResizeMorphologySize] Morphological operation kernel size. Default: 2
1022
+ [--adaptResizeMaxHorizontalExpansion] Maximum horizontal expansion in pixels (prevents column overlap). Default: 50
1023
+ [--adaptResizePaddingCheckWidth] Width of padding strip to validate (in pixels). Default: 3
1024
+ [--adaptResizeMinPaddingBrightness] Minimum brightness for white padding pixels (0-255). Default: 200
1025
+ [--adaptResizeMinPaddingRatio] Minimum ratio of white pixels in padding strip (0-1). Default: 0.85
1026
+ [--adaptResizeUseAdaptiveThreshold/--noAdaptResizeUseAdaptiveThreshold] Use adaptive thresholding based on image histogram (recommended). Default: true
1027
+ [--adaptResizeAdaptiveBlockSize] Block size for adaptive thresholding. Default: 50
1028
+ [--precision] Number of decimal places for coordinates. Use -1 for full precision (no rounding). Default: 0 (integers)
1029
+ [--baseImageDir] Base directory path to prepend to image filenames in output (e.g., "ch" or "images/ch")
1030
+ [--generateFileState/--noGenerateFileState] Generate a file state file for each input directory
1031
+ -h --help Print help information and exit
901
1032
 
902
1033
  ARGUMENTS
903
1034
  args... Input directories containing Label Studio files
@@ -913,25 +1044,41 @@ label-studio-converter enhance-labelstudio --help
913
1044
 
914
1045
  ```
915
1046
  USAGE
916
- label-studio-converter enhance-labelstudio [--outDir value] [--fileName value] [--backup] [--sortVertical value] [--sortHorizontal value] [--normalizeShape value] [--widthIncrement value] [--heightIncrement value] [--precision value] [--recursive] [--filePattern value] [--outputMode value] <args>...
1047
+ label-studio-converter enhance-labelstudio [--outDir value] [--fileName value] [--backup] [--recursive] [--filePattern value] [--copyImages] [--imageBaseDir value] [--sortVertical value] [--sortHorizontal value] [--normalizeShape value] [--useOrientedBox] [--widthIncrement value] [--heightIncrement value] [--adaptResize] [--adaptResizeThreshold value] [--adaptResizeMargin value] [--adaptResizeMinComponentSize value] [--adaptResizeMaxComponentSize value] [--adaptResizeOutlierPercentile value] [--adaptResizeMorphologySize value] [--adaptResizeMaxHorizontalExpansion value] [--adaptResizePaddingCheckWidth value] [--adaptResizeMinPaddingBrightness value] [--adaptResizeMinPaddingRatio value] [--adaptResizeUseAdaptiveThreshold] [--adaptResizeAdaptiveBlockSize value] [--precision value] [--outputMode value] <args>...
917
1048
  label-studio-converter enhance-labelstudio --help
918
1049
 
919
1050
  Enhance Label Studio files with sorting, normalization, and resizing
920
1051
 
921
1052
  FLAGS
922
- [--outDir] Output directory. If not specified, files are saved in the same directory as the source files
923
- [--fileName] Custom output filename. If not specified, uses the same name as the source file
924
- [--backup/--noBackup] Create backup of existing files before overwriting. Default: false
925
- [--sortVertical] Sort bounding boxes vertically. Options: "none", "top-bottom", "bottom-top". Default: "none"
926
- [--sortHorizontal] Sort bounding boxes horizontally. Options: "none", "ltr", "rtl". Default: "none"
927
- [--normalizeShape] Normalize diamond-like shapes to axis-aligned rectangles. Options: "none", "rectangle". Default: "none"
928
- [--widthIncrement] Increase bounding box width by this amount (in pixels). Can be negative to decrease. Default: 0
929
- [--heightIncrement] Increase bounding box height by this amount (in pixels). Can be negative to decrease. Default: 0
930
- [--precision] Number of decimal places for coordinates. Use -1 for full precision (no rounding). Default: -1
931
- [--recursive/--noRecursive] Recursively search directories for files. Default: false
932
- [--filePattern] Regex pattern to match Label Studio files (should match .json files). Default: ".*\.json$"
933
- [--outputMode] Output mode: "annotations" for editable annotations (ground truth) or "predictions" for read-only predictions (pre-annotations). Default: "annotations"
934
- -h --help Print help information and exit
1053
+ [--outDir] Output directory. If not specified, files are saved in the same directory as the source files
1054
+ [--fileName] Custom output filename. If not specified, uses the same name as the source file
1055
+ [--backup/--noBackup] Create backup of existing files before overwriting. Default: false
1056
+ [--recursive/--noRecursive] Recursively search directories for files. Default: false
1057
+ [--filePattern] Regex pattern to match Label Studio files (should match .json files). Default: ".*\.json$"
1058
+ [--copyImages/--noCopyImages] Copy images to output directory when --outDir is specified. Only applies to toLabelStudio and toPPOCR commands. Default: true
1059
+ [--imageBaseDir] Base directory for resolving image paths. Options: "task-file" (relative to task file location), "input-dir" (relative to command execution directory). Default: "task-file"
1060
+ [--sortVertical] Sort bounding boxes vertically. Options: "none", "top-bottom", "bottom-top". Default: "none"
1061
+ [--sortHorizontal] Sort bounding boxes horizontally. Options: "none", "ltr", "rtl". Default: "none"
1062
+ [--normalizeShape] Normalize diamond-like shapes to axis-aligned rectangles. Options: "none", "rectangle". Default: "none"
1063
+ [--useOrientedBox/--noUseOrientedBox] Use oriented (rotated) bounding box when normalizing shapes. Useful for skewed text. Default: false
1064
+ [--widthIncrement] Increase bounding box width by this amount (in pixels). Can be negative to decrease. Default: 0
1065
+ [--heightIncrement] Increase bounding box height by this amount (in pixels). Can be negative to decrease. Default: 0
1066
+ [--adaptResize/--noAdaptResize] Apply adaptive resize to automatically adjust bounding boxes based on image content. Default: false
1067
+ [--adaptResizeThreshold] Grayscale threshold for adaptive resize (0-255). Default: 128
1068
+ [--adaptResizeMargin] Margin pixels around detected content for adaptive resize. Default: 5
1069
+ [--adaptResizeMinComponentSize] Minimum component size in pixels (filters dirt/noise). Default: 10
1070
+ [--adaptResizeMaxComponentSize] Maximum component size in pixels (filters large artifacts). Default: 100000
1071
+ [--adaptResizeOutlierPercentile] Percentile for outlier removal (0-100). Default: 2
1072
+ [--adaptResizeMorphologySize] Morphological operation kernel size. Default: 2
1073
+ [--adaptResizeMaxHorizontalExpansion] Maximum horizontal expansion in pixels (prevents column overlap). Default: 50
1074
+ [--adaptResizePaddingCheckWidth] Width of padding strip to validate (in pixels). Default: 3
1075
+ [--adaptResizeMinPaddingBrightness] Minimum brightness for white padding pixels (0-255). Default: 200
1076
+ [--adaptResizeMinPaddingRatio] Minimum ratio of white pixels in padding strip (0-1). Default: 0.85
1077
+ [--adaptResizeUseAdaptiveThreshold/--noAdaptResizeUseAdaptiveThreshold] Use adaptive thresholding based on image histogram (recommended). Default: true
1078
+ [--adaptResizeAdaptiveBlockSize] Block size for adaptive thresholding. Default: 50
1079
+ [--precision] Number of decimal places for coordinates. Use -1 for full precision (no rounding). Default: 0 (integers)
1080
+ [--outputMode] Output mode: "annotations" for editable annotations (ground truth) or "predictions" for read-only predictions (pre-annotations). Default: "annotations"
1081
+ -h --help Print help information and exit
935
1082
 
936
1083
  ARGUMENTS
937
1084
  args... Input directories containing Label Studio JSON files
@@ -947,29 +1094,74 @@ label-studio-converter enhance-ppocr --help
947
1094
 
948
1095
  ```
949
1096
  USAGE
950
- label-studio-converter enhance-ppocr [--outDir value] [--fileName value] [--backup] [--sortVertical value] [--sortHorizontal value] [--normalizeShape value] [--widthIncrement value] [--heightIncrement value] [--precision value] [--recursive] [--filePattern value] <args>...
1097
+ label-studio-converter enhance-ppocr [--outDir value] [--fileName value] [--backup] [--recursive] [--filePattern value] [--copyImages] [--imageBaseDir value] [--sortVertical value] [--sortHorizontal value] [--normalizeShape value] [--useOrientedBox] [--widthIncrement value] [--heightIncrement value] [--adaptResize] [--adaptResizeThreshold value] [--adaptResizeMargin value] [--adaptResizeMinComponentSize value] [--adaptResizeMaxComponentSize value] [--adaptResizeOutlierPercentile value] [--adaptResizeMorphologySize value] [--adaptResizeMaxHorizontalExpansion value] [--adaptResizePaddingCheckWidth value] [--adaptResizeMinPaddingBrightness value] [--adaptResizeMinPaddingRatio value] [--adaptResizeUseAdaptiveThreshold] [--adaptResizeAdaptiveBlockSize value] [--precision value] <args>...
951
1098
  label-studio-converter enhance-ppocr --help
952
1099
 
953
1100
  Enhance PPOCRLabel files with sorting, normalization, and resizing
954
1101
 
955
1102
  FLAGS
956
- [--outDir] Output directory. If not specified, files are saved in the same directory as the source files
957
- [--fileName] Custom output filename. If not specified, uses the same name as the source file
958
- [--backup/--noBackup] Create backup of existing files before overwriting. Default: false
959
- [--sortVertical] Sort bounding boxes vertically. Options: "none", "top-bottom", "bottom-top". Default: "none"
960
- [--sortHorizontal] Sort bounding boxes horizontally. Options: "none", "ltr", "rtl". Default: "none"
961
- [--normalizeShape] Normalize diamond-like shapes to axis-aligned rectangles. Options: "none", "rectangle". Default: "none"
962
- [--widthIncrement] Increase bounding box width by this amount (in pixels). Can be negative to decrease. Default: 0
963
- [--heightIncrement] Increase bounding box height by this amount (in pixels). Can be negative to decrease. Default: 0
964
- [--precision] Number of decimal places for coordinates. Use -1 for full precision (no rounding). Default: 0 (integers)
965
- [--recursive/--noRecursive] Recursively search directories for files. Default: false
966
- [--filePattern] Regex pattern to match PPOCRLabel files (should match .txt files). Default: ".*\.txt$"
967
- -h --help Print help information and exit
1103
+ [--outDir] Output directory. If not specified, files are saved in the same directory as the source files
1104
+ [--fileName] Custom output filename. If not specified, uses the same name as the source file
1105
+ [--backup/--noBackup] Create backup of existing files before overwriting. Default: false
1106
+ [--recursive/--noRecursive] Recursively search directories for files. Default: false
1107
+ [--filePattern] Regex pattern to match PPOCRLabel files (should match .txt files). Default: ".*\.txt$"
1108
+ [--copyImages/--noCopyImages] Copy images to output directory when --outDir is specified. Only applies to toLabelStudio and toPPOCR commands. Default: true
1109
+ [--imageBaseDir] Base directory for resolving image paths. Options: "task-file" (relative to task file location), "input-dir" (relative to command execution directory). Default: "task-file"
1110
+ [--sortVertical] Sort bounding boxes vertically. Options: "none", "top-bottom", "bottom-top". Default: "none"
1111
+ [--sortHorizontal] Sort bounding boxes horizontally. Options: "none", "ltr", "rtl". Default: "none"
1112
+ [--normalizeShape] Normalize diamond-like shapes to axis-aligned rectangles. Options: "none", "rectangle". Default: "none"
1113
+ [--useOrientedBox/--noUseOrientedBox] Use oriented (rotated) bounding box when normalizing shapes. Useful for skewed text. Default: false
1114
+ [--widthIncrement] Increase bounding box width by this amount (in pixels). Can be negative to decrease. Default: 0
1115
+ [--heightIncrement] Increase bounding box height by this amount (in pixels). Can be negative to decrease. Default: 0
1116
+ [--adaptResize/--noAdaptResize] Apply adaptive resize to automatically adjust bounding boxes based on image content. Default: false
1117
+ [--adaptResizeThreshold] Grayscale threshold for adaptive resize (0-255). Default: 128
1118
+ [--adaptResizeMargin] Margin pixels around detected content for adaptive resize. Default: 5
1119
+ [--adaptResizeMinComponentSize] Minimum component size in pixels (filters dirt/noise). Default: 10
1120
+ [--adaptResizeMaxComponentSize] Maximum component size in pixels (filters large artifacts). Default: 100000
1121
+ [--adaptResizeOutlierPercentile] Percentile for outlier removal (0-100). Default: 2
1122
+ [--adaptResizeMorphologySize] Morphological operation kernel size. Default: 2
1123
+ [--adaptResizeMaxHorizontalExpansion] Maximum horizontal expansion in pixels (prevents column overlap). Default: 50
1124
+ [--adaptResizePaddingCheckWidth] Width of padding strip to validate (in pixels). Default: 3
1125
+ [--adaptResizeMinPaddingBrightness] Minimum brightness for white padding pixels (0-255). Default: 200
1126
+ [--adaptResizeMinPaddingRatio] Minimum ratio of white pixels in padding strip (0-1). Default: 0.85
1127
+ [--adaptResizeUseAdaptiveThreshold/--noAdaptResizeUseAdaptiveThreshold] Use adaptive thresholding based on image histogram (recommended). Default: true
1128
+ [--adaptResizeAdaptiveBlockSize] Block size for adaptive thresholding. Default: 50
1129
+ [--precision] Number of decimal places for coordinates. Use -1 for full precision (no rounding). Default: 0 (integers)
1130
+ -h --help Print help information and exit
968
1131
 
969
1132
  ARGUMENTS
970
1133
  args... Input directories containing PPOCRLabel files
971
1134
  ```
972
1135
 
1136
+ ##### label-studio-output-to-ppocr Command
1137
+
1138
+ ```bash
1139
+ label-studio-converter label-studio-output-to-ppocr --help
1140
+ ```
1141
+
1142
+ **Output:**
1143
+
1144
+ ```
1145
+ USAGE
1146
+ label-studio-converter label-studio-output-to-ppocr [--recursive] [--backup] [--filePattern value] (--outDir value) [--fileName value] [--removeBaseImageDir value] [--generateFileState] <args>...
1147
+ label-studio-converter label-studio-output-to-ppocr --help
1148
+
1149
+ Convert Label Studio output files to PPOCRLabel format
1150
+
1151
+ FLAGS
1152
+ [--recursive/--noRecursive] Recursively search directories for files. Default: false
1153
+ [--backup/--noBackup] Create backup of existing files before overwriting. Default: false
1154
+ [--filePattern] Regex pattern to match input files
1155
+ --outDir Output directory.
1156
+ [--fileName] Output PPOCR file name. Default: "Label.txt"
1157
+ [--removeBaseImageDir] Remove base image directory from image paths in output. Default: "/data/local-files/?d="
1158
+ [--generateFileState/--noGenerateFileState] Generate a file state file for each input directory
1159
+ -h --help Print help information and exit
1160
+
1161
+ ARGUMENTS
1162
+ args... Input directories containing Label Studio files
1163
+ ```
1164
+
973
1165
  #### Examples
974
1166
 
975
1167
  ##### Basic Conversion
@@ -1030,6 +1222,16 @@ label-studio-converter toLabelStudio ./dataset \
1030
1222
  label-studio-converter toPPOCR ./data \
1031
1223
  --outDir ./output \
1032
1224
  --fileName MyLabels.txt
1225
+
1226
+ # Using imageBaseDir for flexible path resolution
1227
+ # Default: resolve from task file location
1228
+ label-studio-converter toLabelStudio ./annotations/
1229
+
1230
+ # Copy images maintaining full directory structure from execution directory
1231
+ label-studio-converter toLabelStudio ./annotations/ \
1232
+ --copyImages \
1233
+ --imageBaseDir input-dir \
1234
+ --outDir ./output
1033
1235
  ```
1034
1236
 
1035
1237
  ##### Shape Normalization