https://github.com/stemann/imageannotationsio.jl
Julia package for handling image annotation I/O
https://github.com/stemann/imageannotationsio.jl
Last synced: 6 months ago
JSON representation
Julia package for handling image annotation I/O
- Host: GitHub
- URL: https://github.com/stemann/imageannotationsio.jl
- Owner: stemann
- License: mit
- Created: 2016-05-05T17:47:23.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-01-22T19:05:11.000Z (over 2 years ago)
- Last Synced: 2025-01-20T18:53:16.404Z (over 1 year ago)
- Language: Julia
- Homepage:
- Size: 64.5 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ImageAnnotationsIO
[](https://github.com/IHPSystems/ImageAnnotationsIO.jl/actions/workflows/CI.yml?query=branch%3Amaster)
[](https://codecov.io/gh/IHPSystems/ImageAnnotationsIO.jl)
[](https://github.com/invenia/BlueStyle)
ImageAnnotationsIO provides methods for loading and saving [image annotations](https://github.com/IHPSystems/ImageAnnotations.jl) using common formats, like the [CVAT XML annotation format](https://opencv.github.io/cvat/docs/manual/advanced/xml_format/), or the [LabelMe XML format](https://github.com/CSAILVision/LabelMeAnnotationTool/blob/master/Annotations/example_folder/img1.xml).
There is currently support for loading and saving:
- Bounding box annotations (for object detection).
- Image annotations (for image classification).
- Oriented bounding box annotations (for object detection).
- Polygon annotations (for object detection).
## Usage
### CVAT XML using decimal floating-point coordinates
The following example loads and saves CVAT XML using decimal floating-point representation of coordinates:
```julia
using DecFP
using ImageAnnotationsIO
cvat_xml_serializer = CVATXMLSerializer{Dec128}()
dataset = load(input_path, cvat_xml_serializer)
save(output_path, dataset, cvat_xml_serializer)
```
### Converting LabelMe XML to CVAT XML
The following example loads a dataset in the form of directories containing LabelMe XML format files, and saves it in the form of a single CVAT XML file.
```julia
using Downloads
using ImageAnnotations
using ImageAnnotationsIO
using ImageIO
base_path = mktempdir()
# Download LabelMe XML dummy data
input_path = joinpath(base_path, "example_folder")
mkdir(input_path)
Downloads.download("https://raw.githubusercontent.com/CSAILVision/LabelMeAnnotationTool/master/Annotations/example_folder/img1.xml", joinpath(input_path, "img1.xml"))
Downloads.download("https://raw.githubusercontent.com/CSAILVision/LabelMeAnnotationTool/master/Images/example_folder/img1.jpg", joinpath(input_path, "img1.jpg"))
output_path = joinpath(base_path, "example_folder_cvat.xml")
labelme_xml_serializer = LabelMeXMLSerializer{Float64}() # Serialize/Deserialize LabelMe XML using Float64 coordinate type
cvat_xml_serializer = CVATXMLSerializer{Float64}() # Serialize/Deserialize CVAT XML using Float64 coordinate type
data_set = load_dataset_dir(input_path, labelme_xml_serializer; base_path = base_path, image_base_path = base_path)
save(output_path, data_set, cvat_xml_serializer)
```
Please note that the example will issue a few warnings related to the current lack of support for object segmentation annotations.