A Python package for manipulating PNG files exported or imported using the Theia web application
Project description
Theia PNG
A Python package for manipulating PNG files exported or imported using the Theia web application. These files have data embedded in the PNG in a COCO JSON format compatible form. This package unpacks and makes the data readily usable.
Quick Start
-
Create a virtual environment.
python3 -m venv .venv
-
Activate the virtual environment.
source .venv/bin/activate
-
Install tspng.
python3 -m pip install tspng
-
Create a
png_dump.py
script to extract inference results from a PNG file,import json from tspng.extraction import extract print(json.dumps(extract(PATH_TO_FILE), indent=2))
where
PATH_TO_FILE
is replaced with the path to a.ts.png
file on disk. -
Run the
png_dump.py
script.$ python3 ./png_dump.py { "info": { "description": "Theiascope image", "url": "http://www.theiascientific.com", "version": "1.0", "year": 2023, "contributor": "Theia Scientific, LLC", "date_created": "2023-05-10 19:22:47.722802+00:00" }, "licenses": { "url": "http://www.theiascientific.com", "id": 1, "name": "Proprietary" }, "images": [ { "license": 1, "file_name": "20230510T192247Z.722_crimson-notebook (PML).ts.png", "height": 512, "width": 512, "date_captured": "2023-05-10 19:22:47.722802+00:00", "id": 3783, "field_of_view": [ 0, 0, 512, 512 ], "scale_bar": { "dimensions": [ 25, 501, 128, 1 ], "length": 100.0, "units_abbr": "nm", "units_name": "nanometers" } } ], "annotations": [...], // Omitted for clarity "models": [ { "id": 17, "configuration": { "image_processing": { "brightness": 0, "clahe": false, "contrast": 1.0, "gamma": 1.0, "gray": false, "invert": false }, "max_concurrency": 2, "num_cpus": 0, "num_gpus": 1.0, "box_nms_thresh": 0.7, "crop_n_layers": 0, "crop_nms_thresh": 0.7, "crop_overlap_ratio": 0.3413333333333333, "crop_n_points_downscale_factor": 1, "min_mask_region_area": 0, "points_per_side": 32, "points_per_batch": 64, "pred_iou_thresh": 0.88, "stability_score_thresh": 0.95, "stability_score_offset": 1.0, "weights_file": { "filename": "sam_vit_b_01ec64.pth", "version": "default", "path": "/sam/vit-b" } }, "created": "2023-05-09 19:46:18.309323+00:00", "family": "SAM", "name": "vit-b", "pid": 1 } ], "categories": [ { "supercategory": "defect", "id": 1, "name": "" } ] }
Contributing
-
Clone this repository.
git clone https://github.com/Theia-Scientific/theia-png.git && cd theia-png
-
Install the dependencies.
python3 -m pip install .[dev]
-
Build the package.
python3 -m build
Testing
Testing is divided into unit and integration tests. Unit tests are located in
the package source code tree and are defined on a per-module basis with a
test_<module>.py
format, while the integration tests are defined in the
tests
directory.
License
Acknowledgments
This material is based upon work supported by the U.S. Department of Energy, Office of Nuclear Energy under Award Number DE-SC0021529.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tspng-0.0.1.tar.gz
.
File metadata
- Download URL: tspng-0.0.1.tar.gz
- Upload date:
- Size: 442.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2186178749d195de5117619c9aba5a1e2904ddde7df4e27e5abde782b0036862 |
|
MD5 | 2ac911b8e46932dd02ed5b314118acab |
|
BLAKE2b-256 | 0a621119e94321b5c067dc40d5f0809974bf78a821497a8f4d52e79289b8390f |
Provenance
File details
Details for the file tspng-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: tspng-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b3051b4a7a1df955e823bb191849494e11e6887fce241bdf712e1e303a68d2b |
|
MD5 | f54bb3740859e9ff8de9edc80da704c0 |
|
BLAKE2b-256 | befc48ed34221829852655175fcd6d82c4d007c17990ebcb38453a1b1213e7e7 |