Skip to content

Commit 2b464ee

Browse files
Merge pull request #75 from StabRise/12-publish-documentation-to-the-readthedocs
12 publish documentation to the readthedocs
2 parents a20fc35 + 5bea2b4 commit 2b464ee

36 files changed

Lines changed: 1051 additions & 8 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,4 @@ cython_debug/
162162
.idea/
163163
/.vscode/settings.json
164164
/tests/testresources/pdfs/private/
165+
/.run/*

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## [unreleased]
1+
## 0.2.4 - 01.10.2025
22

33
### 🚀 Features
44

450 KB
Loading
2.81 MB
Loading
203 KB
Loading
288 KB
Loading

docs/source/conf.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,25 @@
66
# -- Project information -----------------------------------------------------
77
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
88

9+
import os
10+
import sys
11+
12+
sys.path.insert(0, os.path.abspath("../scaledp"))
13+
914
project = "ScaleDP"
10-
copyright = "2024, StabRise"
11-
author = "StabRise"
12-
release = "0.1.0"
15+
author = "Mykola Melnyk"
16+
release = "0.2.4"
1317

1418
# -- General configuration ---------------------------------------------------
1519
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
1620

1721
extensions = ["sphinx.ext.autodoc", "myst_parser"]
1822

23+
source_suffix = {
24+
".rst": "restructuredtext",
25+
".md": "markdown",
26+
}
27+
1928
templates_path = ["_templates"]
2029
exclude_patterns = []
2130

@@ -46,7 +55,13 @@
4655
"icon": "https://img.shields.io/badge/by-StabRise-orange.svg?style=flat&colorA=E1523D&colorB=007D8A",
4756
"type": "url",
4857
},
49-
]
58+
],
59+
"extra_footer": """
60+
<p style="font-size:1em; color:#777;">
61+
© Copyright 2025, <a href="https://stabrise.com"
62+
target="_blank">StabRise</a>
63+
</p>
64+
""",
5065
}
5166

5267
# -- Options for HTML output -------------------------------------------------

docs/source/detectors.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Detectors
2+
=========
3+
4+
## Overview
5+
6+
This section provides an overview of the various detectors available in ScaleDP for processing images and documents. These detectors are designed to identify and extract specific features such as text, objects, and layout structures from images.
7+
8+
## Object Detection
9+
10+
* [**Face Detector**](#FaceDetector)
11+
* [**Signature Detector**](#SignatureDetector)
12+
13+
## Text Detection
14+
15+
* [**CraftTextDetector**](#CraftTextDetector)
16+
* [**DBNetOnnxDetector**](#DBNetOnnxDetector)
17+
* **YoloOnnxTextDetector**
18+
* **DocTRTextDetector**
19+
20+
## Base Detectors
21+
22+
* **BaseDetector**
23+
* [**YoloOnnxDetector**](#YoloOnnxDetector)
24+

docs/source/image/data_to_image.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
(DataToImage)=
2+
# DataToImage
3+
4+
## Overview
5+
6+
`DataToImage` is a PySpark ML transformer that converts binary content (such as bytes from files or streams) into image objects. It is designed for use in Spark pipelines, enabling scalable and distributed image processing workflows. The transformer supports various image types and handles errors gracefully.
7+
8+
## Usage Example
9+
10+
```python
11+
from scaledp import DataToImage, PipelineModel
12+
13+
image_example = files('resources/images/Invoice.png')
14+
15+
df = spark.read.format("binaryFile") \
16+
.load(image_example)
17+
18+
data_to_image = DataToImage(
19+
inputCol="content", # Column with binary data
20+
outputCol="image", # Output column for image objects
21+
pathCol="path", # Optional: column with image paths
22+
keepInputData=True, # Keep original data in output
23+
propagateError=False, # Handle errors gracefully
24+
)
25+
26+
pipeline = PipelineModel(stages=[data_to_image])
27+
result = pipeline.transform(df) # df should have 'content' and optionally 'path' columns
28+
result.show_image("image")
29+
```
30+
31+
![ShowImageInvoice.png](../_static/ShowImageInvoice.png)
32+
33+
## Parameters
34+
35+
| Parameter | Type | Description | Default |
36+
|-------------------|---------|--------------------------------------------------|-----------------|
37+
| inputCol | str | Input column with binary content | "content" |
38+
| outputCol | str | Output column for image objects | "image" |
39+
| pathCol | str | Path column for image metadata | "path" |
40+
| keepInputData | bool | Keep input data in output | False |
41+
| imageType | Enum | Type of image (e.g., FILE, PIL) | ImageType.FILE |
42+
| propagateError | bool | Propagate errors | False |
43+
44+
## Notes
45+
- Converts binary data to image objects using the specified image type.
46+
- Handles errors gracefully; if `propagateError` is False, exceptions are logged and empty images are returned.
47+
- Can be used as the first stage in image processing pipelines to ingest raw image data.
48+
- Supports distributed processing with Spark.
49+
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
(ImageCropBoxes)=
2+
# ImageCropBoxes
3+
4+
## Overview
5+
6+
`ImageCropBoxes` is a PySpark ML transformer that crops images based on provided bounding boxes. It is designed to process images in Spark pipelines, supporting batch and distributed processing. The transformer can add padding to crops, limit the number of crops per image, and handle cases where no boxes are present.
7+
8+
## Usage Example
9+
10+
```python
11+
from scaledp import FaceDetector, ImageCropBoxes, PipelineModel
12+
13+
# Step 1: Detect faces in images
14+
detector = FaceDetector(
15+
inputCol="image",
16+
outputCol="boxes",
17+
keepInputData=True,
18+
scoreThreshold=0.25,
19+
padding=20,
20+
)
21+
22+
# Step 2: Crop images using detected face boxes
23+
cropper = ImageCropBoxes(
24+
inputCols=["image", "boxes"],
25+
outputCol="cropped_image",
26+
keepInputData=True,
27+
padding=10,
28+
limit=5,
29+
noCrop=True,
30+
autoRotate=False, # Automatically rotate crops if box height > width
31+
)
32+
33+
# Build and run the pipeline
34+
pipeline = PipelineModel(stages=[detector, cropper])
35+
result = pipeline.transform(image_df)
36+
result.show_image("cropped_image")
37+
```
38+
39+
![ShowFaceCropped.png](../_static/ShowFaceCropped.png)
40+
41+
## Parameters
42+
43+
| Parameter | Type | Description | Default |
44+
|-------------------|---------|--------------------------------------------------|-----------------|
45+
| inputCols | list | Input columns: image and boxes | ["image", "boxes"] |
46+
| outputCol | str | Output column for cropped images | "cropped_image"|
47+
| keepInputData | bool | Keep input data in output | False |
48+
| imageType | Enum | Type of image (e.g., FILE) | ImageType.FILE |
49+
| numPartitions | int | Number of partitions for Spark | 0 |
50+
| padding | int | Padding added to each crop | 0 |
51+
| pageCol | str | Page column for repartitioning | "page" |
52+
| propagateError | bool | Propagate errors | False |
53+
| noCrop | bool | Raise error if no boxes to crop | True |
54+
| limit | int | Limit number of crops per image | 0 (no limit) |
55+
| autoRotate | bool | Auto rotate crop if box height > width | True |
56+
57+
## Notes
58+
- Crops are performed using bounding boxes from the `boxes` column.
59+
- If `noCrop` is True and no boxes are present, an error is raised.
60+
- If `limit` is set, only the first N boxes are used for cropping.
61+
- If `autoRotate` is True, crops are rotated if the bounding box height is greater than its width.
62+
- Supports distributed processing with Spark.
63+
- Errors can be propagated or handled gracefully based on `propagateError`.

0 commit comments

Comments
 (0)