├── logo
├── logo.png
└── tiles.png
├── plakakia
├── __init__.py
├── config_example.yaml
├── images.py
├── make_tiles.py
├── settings.py
├── annotations.py
└── tiling.py
├── .pre-commit-config.yaml
├── requirements.txt
├── CONTRIBUTING.md
├── setup.py
├── .gitignore
├── demo
└── explore_tiling_output.py
├── requirements_conda.yaml
├── README.md
├── tests
├── test_utils_tiling.py
└── Test_outputs.ipynb
└── LICENSE
/logo/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kalfasyan/plakakia/HEAD/logo/logo.png
--------------------------------------------------------------------------------
/logo/tiles.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kalfasyan/plakakia/HEAD/logo/tiles.png
--------------------------------------------------------------------------------
/plakakia/__init__.py:
--------------------------------------------------------------------------------
1 | # __init__.py
2 | from .annotations import *
3 | from .tiling import *
4 | from .settings import *
5 | from .make_tiles import *
--------------------------------------------------------------------------------
/.pre-commit-config.yaml:
--------------------------------------------------------------------------------
1 | # See https://pre-commit.com for more information
2 | # See https://pre-commit.com/hooks.html for more hooks
3 | repos:
4 | - repo: https://github.com/pre-commit/pre-commit-hooks
5 | rev: v3.2.0
6 | hooks:
7 | - id: trailing-whitespace
8 | - id: end-of-file-fixer
9 | - id: check-yaml
10 | - id: check-added-large-files
11 | - id: pytest
12 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | certifi==2022.12.7
2 | charset-normalizer==3.1.0
3 | contourpy==1.0.7
4 | cycler==0.11.0
5 | fonttools==4.39.0
6 | idna==3.4
7 | kiwisolver==1.4.4
8 | matplotlib==3.7.1
9 | numpy==1.24.2
10 | opencv-python==4.7.0.72
11 | packaging==23.0
12 | pandas==1.5.3
13 | Pillow==9.4.0
14 | pip==23.0.1
15 | psutil==5.9.4
16 | pyparsing==3.0.9
17 | python-dateutil==2.8.2
18 | pytz==2022.7.1
19 | PyYAML==6.0
20 | requests==2.28.2
21 | scipy==1.10.1
22 | seaborn==0.12.2
23 | sentry-sdk==1.16.0
24 | setuptools==65.6.3
25 | six==1.16.0
26 | tqdm==4.65.0
27 | urllib3==1.26.14
28 | wheel==0.38.4
29 | pre-commit
30 | imagesize
31 | pytest
32 | lxml==4.9.2
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | ## How to contribute
2 |
3 | At the moment, the project is in its early stages. If you want to contribute, you can do so by:
4 | - [Opening an issue](https://github.com/kalfasyan/plakakia/issues) to report a bug or request a feature.
5 | - [Opening a pull request](https://github.com/kalfasyan/plakakia/pulls) to fix a bug or add a feature.
6 | - [Contacting me](mailto:kalfasyan@gmail.com) to discuss the project.
7 |
8 | The response time might be a bit slow depending on my [postdoc duties](https://www.kuleuven.be/wieiswie/en/person/00107087), but I will try to get back to you as soon as possible.
9 |
10 | My goal is to make this library as useful as possible for the community, while trying to learn new things myself. Note that this is my first open-source "library", so I am still learning how to do things properly. Any feedback is welcome!
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | # setup.py
2 |
3 | from setuptools import setup
4 |
5 | setup(
6 | name='plakakia',
7 | version='0.2.1',
8 | author='Yannis Kalfas',
9 | author_email='kalfasyan@gmail.com',
10 | description='Python image tiling library for image processing, object detection, etc.',
11 | packages=['plakakia'],
12 | install_requires=[
13 | 'numpy>=1.24.2',
14 | 'pandas>=1.5.3',
15 | 'matplotlib>=3.7.1',
16 | 'opencv-python>=4.7.0.72',
17 | 'scipy>=1.10.1',
18 | 'seaborn>=0.12.2',
19 | 'lxml>=4.9.2',
20 | 'imagesize>=1.4.1',
21 | 'psutil>=5.9.5',
22 | 'tqdm>=4.65.0',
23 | 'PyYAML>=6.0',
24 | 'pyarrow>=12.0.0',
25 | 'fastparquet>=2023.4.0',
26 | ],
27 | entry_points={
28 | 'console_scripts': [
29 | 'make_tiles = plakakia.make_tiles:main',
30 | ],
31 | },
32 | )
--------------------------------------------------------------------------------
/plakakia/config_example.yaml:
--------------------------------------------------------------------------------
1 | {
2 | "input_extension_images": "jpg",
3 | "output_extension_images": "jpg",
4 | "tile_size": 70, # tile size in pixels
5 | "step_size": 70, # step size in pixels for sliding window
6 | "input_dir_images": "/home/kalfasyan/data/OBJECT_DETECTION/solar-panels/images",
7 | "input_dir_annotations": "/home/kalfasyan/data/OBJECT_DETECTION/solar-panels/annotations",
8 | "input_format_annotations": "yolo", # yolo, pascal_voc, coco or segmentation
9 | "output_dir_images": "output/images",
10 | "output_dir_annotations": "output/annotations",
11 | "output_format_annotations": "yolo", # yolo or pascal_voc
12 | "annotation_mapping": { # mapping of annotation classes to integers
13 | "kernel": 0,
14 | "person": 1,
15 | "bottle": 2,
16 | "empty": 3,
17 | "trafficlight": 4,
18 | "speedlimit": 5,
19 | "crosswalk": 6,
20 | "stop": 7
21 | },
22 | "validate_settings": true, # validate settings before running
23 | "log": false, # log to file
24 | "log_folder": "logs", # folder to save logs
25 | "num_workers": -1, # number of workers for multiprocessing
26 | "clear_duplicates": false, # clear duplicate images in the output folder
27 | "draw_boxes": true, # draw bounding boxes on the output images
28 | }
29 |
--------------------------------------------------------------------------------
/plakakia/images.py:
--------------------------------------------------------------------------------
1 | import cv2
2 | from pathlib import Path
3 |
4 | def read_input_image(im_fname=None, settings=None):
5 | extension = settings.input_extension_images
6 |
7 | if extension in ['jpg', 'png']:
8 | image_filename = str(Path(settings.input_dir_images).joinpath(f"{im_fname}.{extension}"))
9 |
10 | image = cv2.imread(image_filename)
11 | # Pad the image if needed
12 | if settings.pad_image:
13 | image = add_border(image, settings=settings, color=[0, 0, 0])
14 | else:
15 | raise NotImplementedError(f"Extension {extension} not implemented.")
16 |
17 | return image
18 |
19 | def read_input_mask(im_fname=None, settings=None):
20 | extension = settings.format_to_extension['segmentation']
21 |
22 | if extension in ['png']:
23 | mask_filename = str(Path(settings.input_dir_annotations).joinpath(f"{im_fname}.{extension}"))
24 |
25 | mask = cv2.imread(mask_filename)
26 | # Pad the mask if needed
27 | if settings.pad_image:
28 | mask = add_border(mask, settings=settings, color=[0, 0, 0])
29 | else:
30 | raise NotImplementedError(f"Extension {extension} not implemented for reading masks.")
31 |
32 | return mask
33 |
34 | def add_border(image, settings, color=[0, 0, 0]):
35 | """ Add border to an image. """
36 |
37 | top=settings.pad_size
38 | bottom=settings.pad_size
39 | left=settings.pad_size
40 | right=settings.pad_size
41 |
42 | if isinstance(image, str):
43 | image = cv2.imread(image)
44 |
45 | # Create border
46 | border = cv2.copyMakeBorder(image, top, bottom, left, right, cv2.BORDER_CONSTANT, value=color)
47 |
48 | return border
49 |
--------------------------------------------------------------------------------
/plakakia/make_tiles.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # coding: utf-8
3 |
4 | # Author: Ioannis Kalfas (@kalfasyan) (kalfasyan at gmail dot com)
5 |
6 | import argparse
7 | import multiprocessing as mp
8 | import os
9 | import random
10 | import shutil
11 | from pathlib import Path
12 | from time import perf_counter
13 |
14 | import yaml
15 | from tqdm import tqdm
16 |
17 | from plakakia.settings import Settings
18 | from plakakia.tiling import clear_duplicates, process_tiles
19 |
20 | random.seed(3)
21 |
22 | def process_tiles_wrapper(args):
23 | """Wrapper function for the process_tile function."""
24 | t, input_image, input_annotation, settings = args
25 | return process_tiles(t, input_image, input_annotation, settings)
26 |
27 |
28 | def main():
29 | # Parse command-line arguments
30 | parser = argparse.ArgumentParser()
31 | parser.add_argument('--config', help='Path to config.yaml file')
32 | args = parser.parse_args()
33 | print(100*'-')
34 | config_path=args.config
35 |
36 | start_time = perf_counter()
37 |
38 | if config_path is None:
39 | print(f"No config file provided. Using default file.")
40 | # If no config_path is provided, use the default config.yaml file in the package
41 | package_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'plakakia')
42 | config_file = os.path.join(package_dir, 'config_example.yaml')
43 | else:
44 | config_file = config_path
45 |
46 | with open(config_file, 'r', encoding='utf-8') as f:
47 | config = yaml.load(f, Loader=yaml.FullLoader)
48 |
49 | # Create a settings object
50 | settings = Settings(**config)
51 |
52 | # Create a process pool with the desired number of workers
53 | with mp.Pool(processes=settings.num_workers) as pool:
54 | # Prepare the arguments for each task
55 | args = [(t, input_image, input_annotation, settings) \
56 | for t, (input_image, input_annotation) in \
57 | enumerate(zip(settings.input_images, settings.input_annotations))]
58 |
59 | # Submit the tasks to the pool
60 | results = pool.map(process_tiles_wrapper, args)
61 |
62 | end_time = perf_counter() - start_time
63 |
64 | print(f"Finished making tiles! Elapsed time: {end_time:.2f} seconds")
65 |
66 | if settings.clear_duplicates:
67 | clear_duplicates(settings)
68 |
69 | if __name__ == '__main__':
70 | # Call the main function with the provided config path
71 | main()
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | pip-wheel-metadata/
24 | share/python-wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 | MANIFEST
29 |
30 | # PyInstaller
31 | # Usually these files are written by a python script from a template
32 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
33 | *.manifest
34 | *.spec
35 |
36 | # Installer logs
37 | pip-log.txt
38 | pip-delete-this-directory.txt
39 |
40 | # Unit test / coverage reports
41 | htmlcov/
42 | .tox/
43 | .nox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | *.py,cover
51 | .hypothesis/
52 | .pytest_cache/
53 |
54 | # Translations
55 | *.mo
56 | *.pot
57 |
58 | # Django stuff:
59 | *.log
60 | local_settings.py
61 | db.sqlite3
62 | db.sqlite3-journal
63 |
64 | # Flask stuff:
65 | instance/
66 | .webassets-cache
67 |
68 | # Scrapy stuff:
69 | .scrapy
70 |
71 | # Sphinx documentation
72 | docs/_build/
73 |
74 | # PyBuilder
75 | target/
76 |
77 | # Jupyter Notebook
78 | .ipynb_checkpoints
79 |
80 | # IPython
81 | profile_default/
82 | ipython_config.py
83 |
84 | # pyenv
85 | .python-version
86 |
87 | # pipenv
88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
91 | # install all needed dependencies.
92 | #Pipfile.lock
93 |
94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95 | __pypackages__/
96 |
97 | # Celery stuff
98 | celerybeat-schedule
99 | celerybeat.pid
100 |
101 | # SageMath parsed files
102 | *.sage.py
103 |
104 | # Environments
105 | .env
106 | .venv
107 | env/
108 | venv/
109 | ENV/
110 | env.bak/
111 | venv.bak/
112 |
113 | # Spyder project settings
114 | .spyderproject
115 | .spyproject
116 |
117 | # Rope project settings
118 | .ropeproject
119 |
120 | # mkdocs documentation
121 | /site
122 |
123 | # mypy
124 | .mypy_cache/
125 | .dmypy.json
126 | dmypy.json
127 |
128 | # Pyre type checker
129 | .pyre/
130 |
131 | .ipynb_checkpoints/
132 | runs/
133 | datasets/
134 | tiles/
135 | output/
136 | images/
137 | annotations/
138 | src/
139 | logs/
140 | __pycache__/
141 | *.jpg
142 | *.Identifier
143 | *.xlsx
144 | *.csv
145 | #*.txt
146 | *.xml
147 | *.json
148 | *.log
149 |
--------------------------------------------------------------------------------
/demo/explore_tiling_output.py:
--------------------------------------------------------------------------------
1 | import streamlit as st
2 | import cv2
3 | import numpy as np
4 | from natsort import natsorted
5 | import os
6 |
7 | st.set_page_config(page_title="Plakakia Tiling Explorer", layout="centered")
8 |
9 | st.title("Plakakia Tiling Explorer")
10 |
11 | # Let the user select the image they want to use
12 | image = st.file_uploader("Choose an image...", type=["jpg", "png", "jpeg"])
13 | if image is None: st.info("Please upload an image file."); st.stop()
14 |
15 | image = cv2.imdecode(np.frombuffer(image.read(), np.uint8), 1)
16 | # Delete any existing image.png file and altered.png file
17 | try: os.remove("image.png")
18 | except: pass
19 | try: os.remove("altered.png")
20 | except: pass
21 |
22 |
23 | with st.form(key='my_form', clear_on_submit=False):
24 | st.subheader("Crop & Resize Image")
25 | col1, col2 = st.columns(2)
26 | top_crop = col1.number_input("Top Crop %", 0, 100, 0)
27 | bottom_crop = col2.number_input("Bottom Crop %", 0, 100, 0)
28 | col1, col2 = st.columns(2)
29 | left_crop = col1.number_input("Left Crop", 0, 100, 0)
30 | right_crop = col2.number_input("Right Crop", 0, 100, 0)
31 |
32 | # Resize the image to a user selected size
33 | resize = st.slider('Resize', 0, 100, 100)
34 |
35 | # Select the tile size and step size
36 | col1, col2 = st.columns(2)
37 | with col1: tile_size = st.slider('Tile Size', 0, 1000, 50, step=5)
38 | with col2: step_size = st.slider('Step Size', 0, 1000, 50, step=5)
39 |
40 | # Add a submit button
41 | submit_button = st.form_submit_button(label='▶️ Run')
42 |
43 | if submit_button:
44 | # Crop the image
45 | image = image[:, int(image.shape[1] * (left_crop / 100.0)):int(image.shape[1] * (1 - (right_crop / 100.0))), :]
46 | # Crop the image
47 | image = image[int(image.shape[0] * (top_crop / 100.0)):int(image.shape[0] * (1 - (bottom_crop / 100.0))), :, :]
48 | image = cv2.resize(image, (0, 0), fx=(resize / 100.0), fy=(resize / 100.0))
49 | cv2.imwrite("image.png", image)
50 |
51 | try:
52 | from plakakia.tiling import tile_image
53 | tiles, coordinates = tile_image(image, tile_size, step_size)
54 | except Exception as e:
55 | st.error("Error: " + str(e))
56 | st.stop()
57 |
58 | # Draw a rectangle around each tile and make it smaller by 1 pixel to see the grid
59 | tile_size = int(tile_size)
60 | step_size = int(step_size)
61 | for i in range(len(coordinates)):
62 | x1, y1, x2, y2 = coordinates[i]
63 | # Make the color the inverse of the average color of the tile
64 | inv_color = (255 - int(np.average(tiles[i, :, :, 0])), 255 - int(np.average(tiles[i, :, :, 1])), 255 - int(np.average(tiles[i, :, :, 2])))
65 | # Make the rectangle 1 pixel smaller to see the grid
66 | cv2.rectangle(image, (x1, y1), (x2-1, y2-1), inv_color, 1)
67 | st.write("Image size: ", image.shape)
68 |
69 | if image is not None:
70 | cv2.imwrite("altered.png", image)
71 | else:
72 | st.error("Please initialize")
73 |
74 | if image is not None:
75 | st.image("altered.png", use_column_width=True)
76 |
77 | else:
78 | st.stop()
79 |
--------------------------------------------------------------------------------
/requirements_conda.yaml:
--------------------------------------------------------------------------------
1 | name: plakakia
2 | channels:
3 | - anaconda
4 | - conda-forge
5 | - defaults
6 | dependencies:
7 | - appnope=0.1.3=pyhd8ed1ab_0
8 | - asttokens=2.4.1=pyhd8ed1ab_0
9 | - backports=1.0=pyhd8ed1ab_3
10 | - backports.functools_lru_cache=1.6.5=pyhd8ed1ab_0
11 | - blas=1.0=openblas
12 | - bottleneck=1.3.5=py311ha0d4635_0
13 | - brotli=1.1.0=hb547adb_1
14 | - brotli-bin=1.1.0=hb547adb_1
15 | - bzip2=1.0.8=h620ffc9_4
16 | - c-ares=1.21.0=h93a5062_0
17 | - ca-certificates=2023.08.22=hca03da5_0
18 | - cairo=1.16.0=h29d4eff_2
19 | - colorama=0.4.6=pyhd8ed1ab_0
20 | - comm=0.1.4=pyhd8ed1ab_0
21 | - contourpy=1.0.5=py311h48ca7d4_0
22 | - cycler=0.12.1=pyhd8ed1ab_0
23 | - debugpy=1.6.7=py311h313beb8_0
24 | - decorator=5.1.1=pyhd8ed1ab_0
25 | - eigen=3.4.0=h1995070_0
26 | - exceptiongroup=1.1.3=pyhd8ed1ab_0
27 | - executing=2.0.1=pyhd8ed1ab_0
28 | - ffmpeg=4.2.2=h04105a8_0
29 | - fontconfig=2.13.94=heb65262_0
30 | - fonttools=4.25.0=pyhd3eb1b0_0
31 | - freetype=2.10.4=h17b34a0_1
32 | - gettext=0.21.1=h0186832_0
33 | - giflib=5.2.1=h1a8c8d9_3
34 | - glib=2.69.1=h514c7bf_2
35 | - gmp=6.2.1=h9f76cd9_0
36 | - gnutls=3.6.15=h887c41c_0
37 | - graphite2=1.3.14=hc377ac9_1
38 | - gst-plugins-base=1.14.1=h313beb8_1
39 | - gstreamer=1.14.1=h80987f9_1
40 | - harfbuzz=4.3.0=he9eebac_1
41 | - hdf5=1.12.1=h05c076b_3
42 | - icu=68.2=hbdafb3b_0
43 | - imagesize=1.4.1=py311hca03da5_0
44 | - importlib-metadata=6.8.0=pyha770c72_0
45 | - importlib_metadata=6.8.0=hd8ed1ab_0
46 | - ipykernel=6.26.0=pyh3cd1d5f_0
47 | - ipython=8.17.2=pyh31c8845_0
48 | - jedi=0.19.1=pyhd8ed1ab_0
49 | - jpeg=9e=h1a8c8d9_3
50 | - jupyter_client=8.5.0=pyhd8ed1ab_0
51 | - jupyter_core=5.5.0=py311hca03da5_0
52 | - kiwisolver=1.4.4=py311h313beb8_0
53 | - krb5=1.20.1=h69eda48_0
54 | - lame=3.100=h1a8c8d9_1003
55 | - lcms2=2.15=h481adae_0
56 | - lerc=3.0=hc377ac9_0
57 | - libbrotlicommon=1.1.0=hb547adb_1
58 | - libbrotlidec=1.1.0=hb547adb_1
59 | - libbrotlienc=1.1.0=hb547adb_1
60 | - libclang=12.0.0=default_hc321e17_4
61 | - libcurl=8.4.0=h3e2b118_0
62 | - libcxx=16.0.6=h4653b0c_0
63 | - libdeflate=1.17=h80987f9_1
64 | - libedit=3.1.20191231=hc8eb9b7_2
65 | - libev=4.33=h642e427_1
66 | - libffi=3.4.4=hca03da5_0
67 | - libgfortran=5.0.0=11_3_0_hca03da5_28
68 | - libgfortran5=11.3.0=h009349e_28
69 | - libiconv=1.17=he4db4b2_0
70 | - libidn2=2.3.4=h1a8c8d9_0
71 | - libllvm12=12.0.1=h93073aa_2
72 | - libnghttp2=1.57.0=h62f6fdd_0
73 | - libopenblas=0.3.21=h269037a_0
74 | - libopus=1.3.1=h27ca646_1
75 | - libpng=1.6.39=h80987f9_0
76 | - libpq=12.15=h02f6b3c_1
77 | - libsodium=1.0.18=h27ca646_1
78 | - libssh2=1.10.0=h02f6b3c_2
79 | - libtasn1=4.19.0=h1a8c8d9_0
80 | - libtiff=4.5.1=h313beb8_0
81 | - libunistring=0.9.10=h3422bc3_0
82 | - libvpx=1.10.0=hc377ac9_0
83 | - libwebp=1.3.2=ha3663a8_0
84 | - libwebp-base=1.3.2=hb547adb_0
85 | - libxml2=2.10.4=h372ba2a_0
86 | - libxslt=1.1.37=h1bd8bc4_0
87 | - llvm-openmp=14.0.6=hc6e5704_0
88 | - lz4-c=1.9.4=hb7217d7_0
89 | - matplotlib=3.8.0=py311hca03da5_0
90 | - matplotlib-base=3.8.0=py311h7aedaa7_0
91 | - matplotlib-inline=0.1.6=pyhd8ed1ab_0
92 | - munkres=1.1.4=pyh9f0ad1d_0
93 | - ncurses=6.4=h313beb8_0
94 | - nest-asyncio=1.5.8=pyhd8ed1ab_0
95 | - nettle=3.7.3=h84b5d62_1
96 | - nspr=4.35=hb7217d7_0
97 | - nss=3.89.1=h313beb8_0
98 | - numexpr=2.8.7=py311h6dc990b_0
99 | - numpy=1.26.0=py311he598dae_0
100 | - numpy-base=1.26.0=py311hfbfe69c_0
101 | - opencv=4.6.0=py311hbae66a1_5
102 | - openh264=1.8.0=h98b2900_0
103 | - openssl=3.0.11=h1a28f6b_2
104 | - packaging=23.2=pyhd8ed1ab_0
105 | - pandas=2.1.1=py311h7aedaa7_0
106 | - parso=0.8.3=pyhd8ed1ab_0
107 | - pcre=8.45=hbdafb3b_0
108 | - pexpect=4.8.0=pyh1a96a4e_2
109 | - pickleshare=0.7.5=py_1003
110 | - pillow=9.4.0=py311h313beb8_1
111 | - pip=23.3=py311hca03da5_0
112 | - pixman=0.42.2=h13dd4ca_0
113 | - platformdirs=3.11.0=pyhd8ed1ab_0
114 | - prompt-toolkit=3.0.39=pyha770c72_0
115 | - prompt_toolkit=3.0.39=hd8ed1ab_0
116 | - psutil=5.9.0=py311h80987f9_0
117 | - ptyprocess=0.7.0=pyhd3deb0d_0
118 | - pure_eval=0.2.2=pyhd8ed1ab_0
119 | - pygments=2.16.1=pyhd8ed1ab_0
120 | - pyparsing=3.0.9=pyhd8ed1ab_0
121 | - python=3.11.5=hb885b13_0
122 | - python-dateutil=2.8.2=pyhd8ed1ab_0
123 | - python-tzdata=2023.3=pyhd3eb1b0_0
124 | - pytz=2023.3.post1=py311hca03da5_0
125 | - pyzmq=25.1.0=py311h313beb8_0
126 | - qt-main=5.15.2=ha2d02b5_7
127 | - qt-webengine=5.15.9=h2903aaf_7
128 | - qtwebkit=5.212=h19f419d_5
129 | - readline=8.2=h1a28f6b_0
130 | - setuptools=68.0.0=py311hca03da5_0
131 | - six=1.16.0=pyh6c4a22f_0
132 | - sqlite=3.41.2=h80987f9_0
133 | - stack_data=0.6.2=pyhd8ed1ab_0
134 | - tk=8.6.12=hb8d0fd4_0
135 | - tornado=6.3.3=py311h80987f9_0
136 | - tqdm=4.66.1=pyhd8ed1ab_0
137 | - traitlets=5.13.0=pyhd8ed1ab_0
138 | - typing-extensions=4.8.0=hd8ed1ab_0
139 | - typing_extensions=4.8.0=pyha770c72_0
140 | - tzdata=2023c=h04d1e81_0
141 | - wcwidth=0.2.9=pyhd8ed1ab_0
142 | - wheel=0.41.2=py311hca03da5_0
143 | - x264=1!152.20180806=h1a28f6b_0
144 | - xz=5.4.2=h80987f9_0
145 | - zeromq=4.3.5=h965bd2d_0
146 | - zipp=3.17.0=pyhd8ed1ab_0
147 | - zlib=1.2.13=h5a0b063_0
148 | - zstd=1.5.5=hd90d995_0
149 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 | 
3 | 
4 | 
5 |
6 | # plakakia
7 | ### /πλακάκια
8 | *Python image tiling library for image processing, object detection, etc.*
9 |
10 | 
11 |
12 | ## What is this? What is it going to be?
13 | `plakakia` is an efficient image tiling tool designed to handle bounding boxes within images. It divides images into rectangular tiles based on specified parameters, seamlessly handling overlapping tiles. The tool assigns bounding boxes to tiles that fully contain them, and it also offers an option to eliminate duplicate bounding boxes. While the current version only supports fully contained bounding boxes, future updates will include support for partial overlap. `plakakia` can handle object detection and segmentation datasets.
14 |
15 | Currently, the library offers online and offline modes for processing data (refer to the [Usage section](https://github.com/kalfasyan/plakakia#usage) section below for more details):
16 |
17 | - In the offline mode, one can use a config file and run a script once to process all data.
18 | - In the online mode, the `tile_image` function allows processing of images of any dimension.
19 |
20 | There are plans to expand `plakakia`'s capabilities in the offline mode to handle images with more than 3 channels.
21 |
22 | ## Performance
23 | To ensure optimal performance, `plakakia` utilizes the `multiprocessing` and `numpy` libraries. This enables efficient processing of thousands of images without the use of nested for-loops commonly used in tiling tasks. For detailed benchmarks on various public datasets, please refer to the information provided below.
24 |
25 |
26 | # Installation
27 |
28 | It is **highly** recommended that you create a new virtual environment for the installation:
29 | 1. Download and install [Mamba](https://mamba.readthedocs.io/en/latest/installation.html) (or [Anaconda](https://www.anaconda.com/products/distribution)).
30 | 2. Create a virtual environment:
31 | `mamba create -n plakakia jupyterlab nb_conda_kernels ipykernel ipywidgets pip -y`
32 | 3. Activate the environment:
33 | `mamba activate plakakia`
34 | 4. Run the following command to install the library:
35 | `pip install plakakia`
36 |
37 | # Usage
38 |
39 | ##### A. Offline tile generation with a config file
40 |
41 | `make_tiles --config path/to/config.yaml`
42 | > Here's an [example config file](plakakia/config_example.yaml).
43 |
44 | ##### B. Online tile generation
45 |
46 | ```
47 | from plakakia.utils_tiling import tile_image
48 |
49 | tiles, coordinates = tile_image(img, tile_size=100, step_size=100)
50 | ```
51 |
52 | For more examples, check the [examples](examples/) folder.
53 |
54 | ### Streamlit Demo App
55 | You can run the demo app with the following command:
56 | ```
57 | streamlit run demo/explore_tiling_output.py
58 | ```
59 | And when you open http://localhost:8501 in your browser, you should see the following:
60 |
61 |
62 |
63 | # Benchmarks
64 |
65 | **Benchmarked on HP Laptop with specs**: AMD Ryzen 5 PRO 6650U; 6 cores; 12 threads; 2.9 GHz
66 |
67 | | Dataset | Source | Formats (images/labels) | Number of images | tile_size | step_size | tiles generated | plakakia performance |
68 | | ------------- | ------------- | ------------- | ------------- | ------------- | ------------- | ------------- | ------------- |
69 | | Solar Panels v2 | [RoboFlow](https://universe.roboflow.com/roboflow-100/solar-panels-taxvb/dataset/2) | jpg/COCO | 112 | 150 | 50 | 3.075 | 1,11 sec |
70 | | Traffic Signs | [Kaggle](https://www.kaggle.com/datasets/valentynsichkar/traffic-signs-dataset-in-yolo-format) | jpg/YOLO | 741 | 300 | 200 | 1.695 | 2,8 sec |
71 | | Hard Hat Workers v2 | [RoboFlow](https://public.roboflow.com/object-detection/hard-hat-workers/2) | jpg/YOLO | 5.269 | 100 | 50 | 21.678 | 6,94 sec|
72 | | Microsoft COCO dataset | [RoboFlow](https://public.roboflow.com/object-detection/microsoft-coco-subset) | jpg/YOLO | 121.408 | 200 | 150 | 177.039 | 3 min 4 sec|
73 |
74 | # TODO list
75 |
76 | ☑️ ~~Fix reading of classes from annotations (create a 'mapper' dictionary to map classes to numerical values).~~
77 | ☑️ ~~Read settings from a file (e.g. json).~~
78 | ☑️ ~~Removing all tiles with duplicate bounding boxes (that appear in other tiles).~~
79 | ☑️ ~~Support other annotation formats (e.g. coco).~~ (only input for now)
80 | ☑️ ~~Provide tiling functionality without any labels needed.~~
81 | ☑️ ~~Add support for segmentation tasks (tile both input images and masks).~~
82 | ☑️ ~~Add a demo app for the users to be able to see the tiling applied on an image.~~
83 | ⬜️ Add less strict (flexible) duplicate removal methods to avoid missing bounding boxes.
84 | ⬜️ Consider bounding boxes in tiles if they *partially* belong to one.
85 | ⬜️ Support reading annotations from a dataframe/csv file.
86 | ⬜️ Make tiles with multidimensional data offline with config file (e.g. hdf5 hyperspectral images).
87 |
88 |
89 | # Want to contribute?
90 | If you want to contribute to this project, please check the [CONTRIBUTING.md](CONTRIBUTING.md) file.
91 |
--------------------------------------------------------------------------------
/tests/test_utils_tiling.py:
--------------------------------------------------------------------------------
1 | # content of test_sysexit.py
2 | import os
3 | import sys
4 |
5 | sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
6 |
7 |
8 | import json
9 | import tempfile
10 | from pathlib import Path
11 | from tempfile import NamedTemporaryFile
12 |
13 | import numpy as np
14 | import pandas as pd
15 | import pytest
16 | import yaml
17 | from lxml import etree as ET
18 |
19 | from plakakia.settings import Settings
20 | from plakakia.annotations import (read_coco_coordinates_from_json,
21 | read_pascalvoc_coordinates_from_xml,
22 | read_yolo_coordinates_from_txt)
23 | from plakakia.tiling import add_border, tile_image
24 |
25 | # Read the settings from the config.yaml file
26 | with open('plakakia/config_example.yaml', 'r') as f:
27 | config = yaml.load(f, Loader=yaml.FullLoader)
28 |
29 | # Create a settings object
30 | settings = Settings(**config)
31 |
32 | def test_add_border():
33 | """
34 | Test function for the add_border() function.
35 |
36 | Creates a 10x10 numpy array with random values and adds a border of one pixel width to each side using
37 | the add_border() function. The resulting array should have a shape of (12, 12). This test checks whether
38 | the resulting shape is as expected.
39 | """
40 |
41 | tmp = np.random.randn(10, 10)
42 | settings.pad_size = 1
43 | tmp = add_border(tmp, settings=settings)
44 | assert tmp.shape == (12, 12)
45 |
46 | import os
47 | import xml.etree.ElementTree as ET
48 |
49 |
50 | def create_sample_xml():
51 | """
52 | Creates a sample XML file with two objects.
53 |
54 | Returns:
55 | None
56 | """
57 | root = ET.Element("annotation")
58 |
59 | obj1 = ET.SubElement(root, "object")
60 | name1 = ET.SubElement(obj1, "name")
61 | name1.text = "cat"
62 | bbox1 = ET.SubElement(obj1, "bndbox")
63 | xmin1 = ET.SubElement(bbox1, "xmin")
64 | xmin1.text = "10"
65 | ymin1 = ET.SubElement(bbox1, "ymin")
66 | ymin1.text = "20"
67 | xmax1 = ET.SubElement(bbox1, "xmax")
68 | xmax1.text = "30"
69 | ymax1 = ET.SubElement(bbox1, "ymax")
70 | ymax1.text = "40"
71 |
72 | obj2 = ET.SubElement(root, "object")
73 | name2 = ET.SubElement(obj2, "name")
74 | name2.text = "car"
75 | bbox2 = ET.SubElement(obj2, "bndbox")
76 | xmin2 = ET.SubElement(bbox2, "xmin")
77 | xmin2.text = "50"
78 | ymin2 = ET.SubElement(bbox2, "ymin")
79 | ymin2.text = "60"
80 | xmax2 = ET.SubElement(bbox2, "xmax")
81 | xmax2.text = "80"
82 | ymax2 = ET.SubElement(bbox2, "ymax")
83 | ymax2.text = "90"
84 |
85 | tree = ET.ElementTree(root)
86 | tree.write("sample.xml")
87 |
88 | def test_read_pascalvoc_coordinates_from_xml():
89 | """
90 | Tests the function read_pascalvoc_coordinates_from_xml by creating a sample XML file,
91 | reading it, and comparing the results with expected values. The XML file contains two
92 | objects: a cat and a car. The function is tested with a settings object that maps the
93 | "cat" class to "animal" and the "car" class to "vehicle".
94 |
95 | Returns:
96 | None
97 | """
98 | create_sample_xml()
99 | settings.annotation_mapping = {"cat": "animal", "car": "vehicle"}
100 | boxes, classes = read_pascalvoc_coordinates_from_xml("sample.xml", settings=settings)
101 |
102 | assert boxes == [[10, 20, 30, 40], [50, 60, 80, 90]]
103 | assert classes == ["animal", "vehicle"]
104 |
105 | os.remove("sample.xml") # delete the sample.xml file once we're done with the test
106 |
107 | def test_read_pascalvoc_coordinates_from_xml_invalid_file():
108 | """
109 | Tests the function read_pascalvoc_coordinates_from_xml with an invalid file path,
110 | expecting a FileNotFoundError to be raised.
111 |
112 | Returns:
113 | None
114 | """
115 | with pytest.raises(FileNotFoundError):
116 | read_pascalvoc_coordinates_from_xml('nonexistent.xml')
117 |
118 | def test_read_yolo_coordinates_from_txt():
119 | """
120 | Tests the function read_yolo_coordinates_from_txt by creating a temporary file with
121 | some YOLO-formatted data, reading it, and comparing the results with expected values.
122 | The YOLO data contains two objects: a bounding box around the center of the image
123 | with width and height equal to half the image size, and a smaller bounding box in
124 | the top-left corner. The function is tested with an image shape of (800, 600, 3)
125 | and no settings object.
126 |
127 | Returns:
128 | None
129 | """
130 | # Create a temporary file with some data in YOLO format
131 | data = "0 0.5 0.5 0.5 0.5\n1 0.3 0.3 0.2 0.2\n"
132 | with tempfile.NamedTemporaryFile(mode='w', delete=False) as tmp_file:
133 | tmp_file.write(data)
134 | tmp_file.flush()
135 | path = tmp_file.name
136 |
137 | # Call the read_yolo_coordinates_from_txt function with the temporary file
138 | image_shape = (800, 600, 3)
139 | boxes, classes = read_yolo_coordinates_from_txt(path=path, image_shape=image_shape)
140 |
141 | # Check that the output is as expected
142 | expected_boxes = [[150, 200, 450, 600], [119, 160, 240, 320]]
143 | expected_classes = [0, 1]
144 | assert boxes == expected_boxes
145 | assert classes == expected_classes
146 |
147 | # Delete the temporary file
148 | os.remove(path)
149 |
150 | def test_read_yolo_coordinates_from_txt_invalid_file():
151 | """
152 | Tests the function read_yolo_coordinates_from_txt with an invalid file path,
153 | expecting a FileNotFoundError to be raised.
154 |
155 | Returns:
156 | None
157 | """
158 | with pytest.raises(FileNotFoundError):
159 | read_yolo_coordinates_from_txt('nonexistent.txt')
160 |
161 | def test_read_yolo_coordinates_from_txt_invalid_image_shape():
162 | """
163 | Tests the function read_yolo_coordinates_from_txt with an invalid image shape,
164 | expecting a ValueError to be raised.
165 |
166 | Returns:
167 | None
168 | """
169 | # Create a temporary file with some data in YOLO format
170 | data = "0 0.5 0.5 0.5 0.5\n1 0.3 0.3 0.2 0.2\n"
171 | with tempfile.NamedTemporaryFile(mode='w', delete=False) as tmp_file:
172 | tmp_file.write(data)
173 | tmp_file.flush()
174 | path = tmp_file.name
175 |
176 | # Call the read_yolo_coordinates_from_txt function with the temporary file
177 | image_shape = (800, 600)
178 | with pytest.raises(ValueError):
179 | read_yolo_coordinates_from_txt(path=path, image_shape=image_shape)
180 |
181 | # Delete the temporary file
182 | os.remove(path)
183 |
184 | def test_tile_image():
185 | """
186 | Tests the function tile_image by creating a random input image, tiling it, and
187 | comparing the results with expected values. The input image has a size of 512x512
188 | and the tiles have a size of 128x128 with a step size of 64. The output tiles and
189 | coordinates are checked for correctness.
190 |
191 | Returns:
192 | None
193 | """
194 |
195 | # Create a random input image
196 | image = np.random.randint(0, 256, size=(512, 512, 3), dtype=np.uint8)
197 |
198 | # Call the tile_image function with the random image
199 | tile_size = 128
200 | step_size = 64
201 |
202 | tiles, coordinates = tile_image(image, tile_size=tile_size, step_size=step_size)
203 |
204 | # Check that the output shape and type is correct
205 | assert tiles.shape == (49, 128, 128, 3)
206 | assert coordinates.shape == (49, 4)
207 | assert tiles.dtype == image.dtype
208 |
209 | # Check that the coordinates correspond to the correct tiles
210 | for i, (x1, y1, x2, y2) in enumerate(coordinates):
211 | assert x2 - x1 == tile_size
212 | assert y2 - y1 == tile_size
213 | assert x1 % step_size == 0
214 | assert y1 % step_size == 0
215 | assert x2 <= image.shape[1]
216 | assert y2 <= image.shape[0]
217 | tile = tiles[i]
218 | assert tile.shape == (tile_size, tile_size, 3)
219 | assert np.array_equal(tile, image[y1:y2, x1:x2])
220 |
--------------------------------------------------------------------------------
/plakakia/settings.py:
--------------------------------------------------------------------------------
1 | import logging
2 | from dataclasses import dataclass, field
3 | from logging.handlers import RotatingFileHandler
4 | from pathlib import Path
5 |
6 | import imagesize
7 | import psutil
8 | from tqdm import tqdm
9 | from .annotations import read_coco_coordinates_from_json
10 |
11 | # Create a dataclass for storing the settings
12 | @dataclass
13 | class Settings():
14 | """ Settings for the tiling process. """
15 | # Define the image input file extensions
16 | input_extension_images: str = 'jpg'
17 | # Define the image output file extension
18 | output_extension_images: str = 'jpg'
19 | # Set the annotation file extensions
20 | input_extension_annotations: str = 'txt'
21 | # Whether to pad the image with a border
22 | pad_image: bool = False
23 | # Size of the border to add to the image
24 | pad_size: int = 10
25 | # Size of the tile; only square tiles supported for now
26 | tile_size: int = 200
27 | # Step size to move the tile in a windowed manner
28 | step_size: int = 50
29 | # Check if bounding boxes are partially inside the tile
30 | check_partial: bool = False
31 | # Set the overlap threshold for the bounding boxes to be considered partially inside the tile
32 | partial_overlap_threshold: float = 0.8
33 | # Set the input directory for the images
34 | input_dir_images: str = 'input_images'
35 | # Set the input directory for the annotations
36 | input_dir_annotations: str = 'input_annotations'
37 | # Set the input annotation file format
38 | input_format_annotations: str = 'yolo' # 'yolo', 'pascal_voc', or 'coco'
39 | # Set the output directory for the images
40 | output_dir_images: str = 'output_images'
41 | # Set the output directory for the annotations
42 | output_dir_annotations: str = 'output_annotations'
43 | # Define the annotation file format
44 | output_format_annotations: str = 'yolo' # 'yolo' or 'pascal_voc'
45 | # Define a mapping for the annotation labels
46 | annotation_mapping: dict = field(default_factory=dict)
47 | # Whether to draw rectangels in the tile images
48 | draw_boxes: bool = False
49 | # Set a flag for logging output
50 | log: bool = False
51 | # Define a folder for saving the logs
52 | log_folder: str = 'logs'
53 | # Boolean flag for validating the settings
54 | validate_settings: bool = True
55 | # Define the number of threads to use
56 | num_workers: int = 1
57 | # Define a flag for removing duplicate tiles
58 | clear_duplicates: bool = False
59 | # Define dictionary for annotations and extension formats
60 | format_to_extension: dict = field(default_factory=dict)
61 |
62 | # Define the initialization method of this dataclass
63 | def __post_init__(self):
64 | self.format_to_extension = {
65 | 'yolo': 'txt',
66 | 'pascal_voc': 'xml',
67 | 'coco': 'json',
68 | 'segmentation': 'png',
69 | }
70 | assert Path(self.input_dir_images).exists(), \
71 | f"{self.input_dir_images} image input directory does not exist."
72 | assert Path(self.input_dir_annotations).exists(), \
73 | f"{self.input_dir_annotations} annotations directory does not exist."
74 | # Create the output directories for the images and annotations
75 | Path(self.output_dir_images).mkdir(parents=True, exist_ok=True)
76 | Path(self.output_dir_annotations).mkdir(parents=True, exist_ok=True)
77 | Path(self.log_folder).mkdir(parents=True, exist_ok=True)
78 |
79 | # Settings the annotations' file extension
80 | self.input_extension_annotations = self.format_to_extension[self.input_format_annotations]
81 |
82 | # Settings the annotations' output file extension
83 | self.output_extension_annotations = self.format_to_extension[self.output_format_annotations]\
84 | if self.input_format_annotations != 'coco' else 'txt'
85 |
86 | # Get the list of images and annotations
87 | self.input_images = list(Path(self.input_dir_images).\
88 | glob(f"*.{self.input_extension_images}"))
89 | self.input_images = [i.as_posix() for i in self.input_images]
90 | self.input_annotations = list(Path(self.input_dir_annotations).\
91 | glob(f"*.{self.input_extension_annotations}"))
92 | input_annotations = [i.as_posix() for i in self.input_annotations]
93 |
94 | # Check if there are any images with the given extension
95 | assert self.input_images, f"No images found with extension: {self.input_extension_images}."
96 | # Check if there are any annotations with the given extension
97 | # Perform checks for 'yolo' and 'pascal_voc' formats
98 | if self.input_format_annotations in ['yolo', 'pascal_voc']:
99 | assert len(input_annotations), \
100 | f"No annotations found with \'input' extension: {self.input_extension_annotations}."
101 | # Check if the number of annotations is equal to the number of images
102 | assert len(self.input_images) == len(input_annotations), \
103 | "The number of images is not equal to the number of annotations."
104 | # Sort the images and annotations
105 | self.input_annotations.sort()
106 | self.input_images.sort()
107 | elif self.input_format_annotations == 'coco':
108 | self.input_annotations = ['' for i in range(len(self.input_images))]
109 | # Find the annotation json file in the input directory
110 | try:
111 | json_filepath = list(Path(self.input_dir_annotations).glob('*.json'))
112 | assert len(json_filepath) == 1, \
113 | "More than one json files found in the input directory."
114 | json_filepath = json_filepath[0].as_posix()
115 | except AssertionError as err:
116 | print(err)
117 | exit()
118 | print(f"Reading the annotations from {json_filepath}")
119 | self.df_coco = read_coco_coordinates_from_json(json_filepath, self.input_dir_images)
120 |
121 | if self.validate_settings:
122 | # Calculate the minimum image dimension
123 | minimum_image_dim = float('inf')
124 | for img in tqdm(self.input_images,
125 | desc='Validating settings..',
126 | total=len(self.input_images)):
127 | width, height = imagesize.get(img)
128 | minimum_image_dim = min(minimum_image_dim, width, height)
129 | if self.input_format_annotations in ['yolo', 'pascal_voc']:
130 | # Check if there is an annotation for each image
131 | assert Path(img).stem in [Path(a).stem for a in self.input_annotations], \
132 | f"No annotation found for image {img}."
133 | # Check if the tile size is smaller than the smallest image dimension
134 | assert minimum_image_dim >= self.tile_size, \
135 | f"The tile size is larger than the smallest image dimension: {minimum_image_dim}. \n\
136 | Try setting a smaller tile size."
137 |
138 | # Create the inverse mapping for the annotation labels
139 | self.inv_annotation_mapping = {v: k for k, v in self.annotation_mapping.items()}
140 |
141 | # Logging settings
142 | self.logger = logging.getLogger(__name__)
143 | self.logger.setLevel(logging.DEBUG)
144 | formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
145 | # Create a rotating file handler with 5 files that have up to 5 MB size each
146 | file_handler = RotatingFileHandler(f'{self.log_folder}/app.log',
147 | maxBytes=5*1024*1024,
148 | backupCount=5)
149 | file_handler.setFormatter(formatter)
150 | self.logger.addHandler(file_handler)
151 |
152 | # Set check_partial to False by default
153 | self.check_partial = False
154 |
155 | # Set default value for pad_size
156 | self.pad_size = 10
157 |
158 | self.num_workers = psutil.cpu_count() if self.num_workers == -1 else self.num_workers
159 |
160 | if self.clear_duplicates:
161 | self.output_dir_duplicates = Path(self.output_dir_images).parent / "duplicates"
162 | Path(f"{self.output_dir_duplicates}").mkdir(parents=True, exist_ok=True)
163 |
--------------------------------------------------------------------------------
/plakakia/annotations.py:
--------------------------------------------------------------------------------
1 | import pandas as pd
2 | import xml.etree.ElementTree as ET
3 | import os
4 | import numpy as np
5 | from tqdm import tqdm
6 | from pathlib import Path
7 | import json
8 | import cv2
9 |
10 | def read_pascalvoc_coordinates_from_xml(filename=str, settings=None):
11 | ''' Read coordinates from PascalVOC xml file. '''
12 | tree = ET.parse(filename) # type: ignore
13 | root = tree.getroot()
14 |
15 | boxes, classes = [], []
16 |
17 | for obj in root.iter('object'):
18 | class_name = settings.annotation_mapping[obj.find('name').text] \
19 | if isinstance(obj.find('name').text, str) else str(obj.find('name').text)
20 |
21 | # Get bounding box coordinates
22 | xmlbox = obj.find('bndbox')
23 | x_1 = int(float(xmlbox.find('xmin').text)) # type: ignore
24 | y_1 = int(float(xmlbox.find('ymin').text)) # type: ignore
25 | x_2 = int(float(xmlbox.find('xmax').text)) # type: ignore
26 | y_2 = int(float(xmlbox.find('ymax').text)) # type: ignore
27 |
28 | # Append to boxes and classes lists
29 | boxes.append([x_1, y_1, x_2, y_2])
30 | classes.append(class_name)
31 |
32 | return boxes, classes
33 |
34 | def read_yolo_coordinates_from_txt(path=None, image_shape=()):
35 | """ Read coordinates from YOLO txt file. """
36 | with open(path, mode='r', encoding="utf-8") as file: # type: ignore
37 | lines = file.readlines()
38 |
39 | image_height, image_width, _ = image_shape
40 |
41 | # Transform yolo_x, yolo_y, yolo_width, yolo_height to x_1, y_1, x_2, y_2
42 | boxes, classes = [], []
43 |
44 | for line in lines:
45 | line = line.strip()
46 | if line == '':
47 | continue
48 | line = line.split(' ')
49 | class_id = int(line[0])
50 | classes.append(class_id)
51 |
52 | x = float(line[1])
53 | y = float(line[2])
54 | w = float(line[3])
55 | h = float(line[4])
56 | x_1 = int((x - w/2) * image_width)
57 | y_1 = int((y - h/2) * image_height)
58 | x_2 = int((x + w/2) * image_width)
59 | y_2 = int((y + h/2) * image_height)
60 | boxes.append([x_1, y_1, x_2, y_2])
61 | return boxes, classes
62 |
63 | def read_coco_coordinates_from_json(filename, dir_images) -> pd.DataFrame:
64 | """Read coordinates from COCO format json file."""
65 | with open(filename, 'r', encoding='utf-8') as f:
66 | data = json.load(f)
67 |
68 | df_anns = pd.DataFrame(data['annotations'])
69 | df_ims = pd.DataFrame(data['images'])
70 | boxes = []
71 | for annotation in data['annotations']:
72 | x, y, w, h = annotation['bbox']
73 | x_1, y_1 = int(x), int(y)
74 | x_2, y_2 = int(x+w), int(y+h)
75 | boxes.append([x_1, y_1, x_2, y_2])
76 |
77 | df_merged = pd.merge(df_anns, df_ims, left_on='image_id', right_on='id')
78 | df_merged['boxes'] = boxes
79 | df_merged['file_name'] = df_merged['file_name'].apply(lambda x: (Path(dir_images) / x).as_posix())
80 |
81 | return df_merged
82 |
83 | def read_coordinates_from_annotations(im_path=None,
84 | ant_path=None,
85 | image_shape=None,
86 | settings=None) -> tuple:
87 | """ Read coordinates from annotations. """
88 | if settings.input_format_annotations == 'yolo':
89 | boxes, classes = read_yolo_coordinates_from_txt(ant_path, image_shape)
90 | elif settings.input_format_annotations == 'pascal_voc':
91 | boxes, classes = read_pascalvoc_coordinates_from_xml(ant_path, settings)
92 | elif settings.input_format_annotations == 'coco':
93 | boxes = settings.df_coco.query("file_name == @im_path").boxes.tolist()
94 | classes = settings.df_coco.query("file_name == @im_path").category_id.tolist()
95 | else:
96 | raise ValueError(f"Annotation format {settings.input_format_annotations} not supported")
97 |
98 | box_classes = [int(i) for i in classes]
99 |
100 | return np.array(boxes), box_classes
101 |
102 | def export_yolo_annotation_from_csv(filename=None, output_dir=None) -> None:
103 | """ Export YOLO annotation from csv file. """
104 | csv_filename = f"df_{filename}.csv"
105 | dataframe = pd.read_csv(f"{csv_filename}")
106 | dataframe = dataframe[dataframe.user_verification].copy().reset_index()
107 | dataframe['prediction_verified'] = np.random.randint(10,size=len(dataframe)).tolist()
108 | dataframe[['prediction_verified','yolo_x','yolo_y','yolo_width','yolo_height']]\
109 | .to_csv(f"{output_dir}/{filename}.txt", index=False, header=False, sep=' ')
110 |
111 | def save_yolo_annotations_from_df(dataframe,
112 | filename=None,
113 | settings=None,
114 | disable_progress_bar=True) -> None:
115 | """
116 | Save YOLO annotations from a dataframe containing the tile coordinates and the bounding boxes.
117 | """
118 | # Compute the coordinates of the center of the box and the width and height of the box
119 | x_1, y_1, x_2, y_2 = dataframe.box_x1, dataframe.box_y1, dataframe.box_x2, dataframe.box_y2
120 | image_width = dataframe['tile_x2'] - dataframe['tile_x1']
121 | image_height = dataframe['tile_y2'] - dataframe['tile_y1']
122 | dataframe['yolo_x'] = (x_1 + x_2) / 2 / image_width
123 | dataframe['yolo_y'] = (y_1 + y_2) / 2 / image_height
124 | dataframe['yolo_w'] = (x_2 - x_1) / image_width
125 | dataframe['yolo_h'] = (y_2 - y_1) / image_height
126 |
127 | group = dataframe.groupby(['tile_x1', 'tile_y1', 'tile_x2', 'tile_y2'])
128 | output_dir = settings.output_dir_annotations
129 |
130 | for i, sub in tqdm(group,
131 | desc='Saving YOLO annotations',
132 | disable=disable_progress_bar,
133 | total=len(group.count())):
134 | file_name = f"tile_{filename}_{i[0]}_{i[1]}_{i[2]}_{i[3]}.txt"
135 | with open(Path(output_dir) / file_name, mode="a+", encoding="utf-8") as file:
136 | for _, row in sub.iterrows():
137 | file.write(f"{int(row['box_class'])} {row['yolo_x']} {row['yolo_y']} {row['yolo_w']} {row['yolo_h']}\n")
138 |
139 | def save_to_pascal_voc_from_df(dataframe,
140 | filename=None,
141 | settings=None,
142 | disable_progress_bar=True) -> None:
143 | """
144 | Saves a dataframe containing bounding box information in Pascal VOC format.
145 | """
146 | # fix this function
147 |
148 | f_n = filename
149 |
150 | # Group by tile and iterate over groups
151 | group = dataframe.groupby(["tile_x1", "tile_y1", "tile_x2", "tile_y2"])
152 | for _, tile_df in tqdm(group,
153 | desc="Saving Pascal VOC annotations",
154 | disable=disable_progress_bar,
155 | total=len(group.count())):
156 | # Create the XML structure
157 | tile_x1 = tile_df["tile_x1"].iloc[0]
158 | tile_y1 = tile_df["tile_y1"].iloc[0]
159 | tile_x2 = tile_df["tile_x2"].iloc[0]
160 | tile_y2 = tile_df["tile_y2"].iloc[0]
161 |
162 | tile_name = f"tile_{f_n}_{tile_x1}_{tile_y1}_{tile_x2}_{tile_y2}"
163 | assert 'at' not in str(tile_name), "Something went wrong with the tile name."
164 |
165 | annotation = ET.Element("annotation")
166 | folder = ET.SubElement(annotation, "folder")
167 | folder.text = settings.output_dir_annotations
168 | filename = ET.SubElement(annotation, "filename")
169 | filename.text = f"{tile_name}.{settings.output_extension_images}"
170 | size = ET.SubElement(annotation, "size")
171 | width = ET.SubElement(size, "width")
172 | width.text = str(np.abs(tile_x2 - tile_x1))
173 | height = ET.SubElement(size, "height")
174 | height.text = str(np.abs(tile_y2 - tile_y1))
175 | depth = ET.SubElement(size, "depth")
176 | depth.text = "3"
177 |
178 | # Iterate over rows in the group and add bounding box information
179 | for _, row in tile_df.iterrows():
180 | obj = ET.SubElement(annotation, "object")
181 | name = ET.SubElement(obj, "name")
182 | name.text = str(row["box_class"])
183 | bndbox = ET.SubElement(obj, "bndbox")
184 | xmin = ET.SubElement(bndbox, "xmin")
185 | xmin.text = str(row["box_x1"])
186 | ymin = ET.SubElement(bndbox, "ymin")
187 | ymin.text = str(row["box_y1"])
188 | xmax = ET.SubElement(bndbox, "xmax")
189 | xmax.text = str(row["box_x2"])
190 | ymax = ET.SubElement(bndbox, "ymax")
191 | ymax.text = str(row["box_y2"])
192 |
193 | # Write the XML to a file
194 | xml_tile_name = f"{tile_name}.xml"
195 | output_path = os.path.join(settings.output_dir_annotations, xml_tile_name)
196 | tree = ET.ElementTree(annotation)
197 | tree.write(output_path,
198 | encoding="utf-8",
199 | xml_declaration=True,
200 | short_empty_elements=False,
201 | method="xml")
202 |
203 | def save_annotations(dataframe=None, filename=None, settings=None, disable_progress_bar=True) -> None:
204 | """ Save the annotations in the format specified in the settings. """
205 | if settings.output_format_annotations == 'yolo':
206 | save_yolo_annotations_from_df(dataframe,
207 | filename=filename,
208 | settings=settings,
209 | disable_progress_bar=disable_progress_bar)
210 | elif settings.output_format_annotations == 'pascal_voc':
211 | save_to_pascal_voc_from_df(dataframe,
212 | filename=filename,
213 | settings=settings,
214 | disable_progress_bar=disable_progress_bar)
215 | else:
216 | raise ValueError("The output format of the annotations is not valid.")
217 |
218 | def convert_yolo_to_xyxy(yolo_x,
219 | yolo_y,
220 | yolo_w,
221 | yolo_h,
222 | image_width,
223 | image_height):
224 | """ Convert YOLO format to XYXY format. """
225 | x_1 = int((yolo_x - yolo_w/2) * image_width)
226 | y_1 = int((yolo_y - yolo_h/2) * image_height)
227 | x_2 = int((yolo_x + yolo_w/2) * image_width)
228 | y_2 = int((yolo_y + yolo_h/2) * image_height)
229 | return x_1, y_1, x_2, y_2
230 |
231 | def save_image_tiles(filename=None, tiles=None, coordinates=None, settings=None, prefix=None):
232 | """ Save the mask tiles. """
233 |
234 | if prefix == 'mask':
235 | output_dir = settings.output_dir_annotations
236 | extension = settings.output_extension_images
237 | elif prefix in ['tile', 'image']:
238 | output_dir = settings.output_dir_images
239 | extension = settings.output_extension_images
240 | else:
241 | raise ValueError(f"The prefix is not valid. The only accepted values are 'mask', 'tile' and 'image'.")
242 |
243 | for i, (tile, tile_coord) in tqdm(enumerate(zip(tiles, coordinates)),
244 | desc="Saving mask tiles",
245 | total=len(tiles)):
246 | # Save the tile
247 | file_path = f"{prefix}_{filename}_{tile_coord[0]}_{tile_coord[1]}_{tile_coord[2]}_{tile_coord[3]}.{extension}"
248 | save_path = Path(output_dir) / Path(file_path)
249 |
250 | cv2.imwrite(save_path.as_posix(), tile)
251 |
--------------------------------------------------------------------------------
/plakakia/tiling.py:
--------------------------------------------------------------------------------
1 | import logging
2 | import random
3 | from pathlib import Path
4 |
5 | import cv2
6 | import matplotlib.pyplot as plt
7 | import numpy as np
8 | import pandas as pd
9 | from tqdm import tqdm
10 |
11 | from .annotations import *
12 | from .images import *
13 |
14 | logger = logging.getLogger(__name__)
15 |
16 | def tile_image(image, tile_size=250, step_size=50):
17 | """ Tile an image into overlapping tiles. """
18 |
19 | # Check if the image is grayscale (1 channel)
20 | if len(image.shape) == 2:
21 | image = image[..., np.newaxis] # Add a third dimension for compatibility
22 |
23 | # Compute the number of rows and columns of tiles
24 | rows = (image.shape[0] - tile_size) // step_size + 1
25 | cols = (image.shape[1] - tile_size) // step_size + 1
26 |
27 | # Compute the shape and strides of the tile view
28 | tile_shape = (rows, cols, tile_size, tile_size, image.shape[2])
29 | tile_strides = (step_size * image.strides[0], step_size * image.strides[1], *image.strides)
30 |
31 | # Create a view of the input image with the tile shape and strides
32 | tile_view = np.lib.stride_tricks.as_strided(image, shape=tile_shape, strides=tile_strides)
33 |
34 | # Reshape the tile view to a flat array of tiles
35 | tiles = tile_view.reshape(-1, tile_size, tile_size, image.shape[2])
36 |
37 | # Compute the corresponding tile indices and pixel coordinates
38 | indices = np.arange(tiles.shape[0])
39 | i, j = np.unravel_index(indices, (rows, cols))
40 | x_1 = j * step_size
41 | y_1 = i * step_size
42 | x_2 = x_1 + tile_size
43 | y_2 = y_1 + tile_size
44 |
45 | # Stack the tile indices and coordinates into a single array
46 | coordinates = np.stack((x_1, y_1, x_2, y_2), axis=-1)
47 |
48 | # If the input was grayscale, convert the tiles to grayscale
49 | if len(image.shape) == 2:
50 | tiles = tiles[..., 0]
51 |
52 | return tiles, coordinates
53 |
54 | def get_boxes_inside_tiles(bboxes,
55 | tile_coordinates,
56 | settings):
57 | """ Get the bounding boxes that are inside the tiles. """
58 |
59 | partial_boxes=settings.check_partial
60 | overlap_threshold=settings.partial_overlap_threshold
61 |
62 | boxes_inside_tiles = [[] for _ in range(len(tile_coordinates))]
63 |
64 | for i, tile_coord in enumerate(tile_coordinates):
65 | if partial_boxes:
66 | # Create a boolean mask indicating which boxes partially overlap with the tile
67 | mask = is_partial_square_inside_array(bboxes,
68 | tile_coord,
69 | overlap_threshold=overlap_threshold)
70 | else:
71 | # Create a boolean mask indicating which boxes are completely inside the tile
72 | mask = is_square_inside_array(bboxes, tile_coord)
73 |
74 | # Add the boxes that satisfy the condition to the corresponding tile
75 | boxes_inside_tiles[i] = bboxes[mask].tolist()
76 |
77 | return boxes_inside_tiles
78 |
79 | def is_partial_square_inside_array(bboxes, tile_coord, overlap_threshold=None):
80 | """ Check if a square is partially inside an array. """
81 | # Compute the coordinates of the intersection between the box and the tile
82 | x_1 = np.maximum(bboxes[:, 0], tile_coord[0])
83 | y_1 = np.maximum(bboxes[:, 1], tile_coord[1])
84 | x_2 = np.minimum(bboxes[:, 2], tile_coord[2])
85 | y_2 = np.minimum(bboxes[:, 3], tile_coord[3])
86 |
87 | # Compute the areas of the intersection and the box
88 | intersection_area = (x_2 - x_1) * (y_2 - y_1)
89 | box_area = (bboxes[:, 2] - bboxes[:, 0]) * \
90 | (bboxes[:, 3] - bboxes[:, 1])
91 |
92 | # Compute the overlap between the box and the tile
93 | overlap = intersection_area / box_area
94 |
95 | # Return a boolean mask indicating which boxes have overlap above the threshold
96 | return overlap > overlap_threshold
97 |
98 | def is_square_inside_array(bboxes, tile_coord):
99 | """ Check if a square is completely inside an array. """
100 | # Return a boolean mask indicating which boxes are inside the tile
101 | return np.logical_and.reduce((
102 | bboxes[:, 0] >= tile_coord[0],
103 | bboxes[:, 1] >= tile_coord[1],
104 | bboxes[:, 2] <= tile_coord[2],
105 | bboxes[:, 3] <= tile_coord[3]
106 | ))
107 |
108 | def save_boxes(tiles=np.array([]),
109 | filename=None,
110 | coordinates=np.array([]),
111 | boxes_in_tiles=[],
112 | box_classes=[],
113 | settings=None,
114 | disable_progress_bar=True):
115 | '''
116 | Save the tiles with the boxes drawn on them.
117 | '''
118 |
119 | # Initialize an array to store the class and coordinates of the boxes and the tile coordinates
120 | results = np.zeros((0, 13), dtype=np.int32)
121 |
122 | # Loop through each tile and save it with a name that includes the tile coordinates
123 | for i, (tile, tile_coord, boxes) in tqdm(enumerate(zip(tiles, coordinates, boxes_in_tiles)),
124 | desc="Saving tiles",
125 | total=len(tiles),
126 | disable=disable_progress_bar):
127 | # Save boxes only if there are boxes in the tile
128 | if len(boxes_in_tiles[i]) == 0:
129 | continue
130 |
131 | # Draw the boxes on the tile with yellow borders
132 | for b, box in enumerate(boxes):
133 | new_x1 = box[0] - tile_coord[0]
134 | new_y1 = box[1] - tile_coord[1]
135 | new_x2 = box[2] - tile_coord[0]
136 | new_y2 = box[3] - tile_coord[1]
137 |
138 | if settings.draw_boxes:
139 | cv2.rectangle(tile, (new_x1, new_y1), (new_x2, new_y2), (0, 255, 255), 2)
140 | # Add the class on top of the rectangle
141 | cv2.putText(tile,
142 | str(box_classes[b]),
143 | (new_x1, new_y1),
144 | cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 2)
145 |
146 | # Stack the class+coordinates of the boxes w/ results array and tile coordinates
147 | results = np.vstack((results,
148 | [tile_coord[0], tile_coord[1], tile_coord[2], tile_coord[3],
149 | box_classes[b],
150 | new_x1, new_y1, new_x2, new_y2,
151 | box[0], box[1], box[2], box[3]]))
152 |
153 | # Save the tile with the tile coordinates in the filename
154 | extension = settings.output_extension_images
155 | output_dir = settings.output_dir_images
156 | file_path = f"tile_{filename}_{tile_coord[0]}_{tile_coord[1]}_{tile_coord[2]}_{tile_coord[3]}.{extension}"
157 | save_path = Path(output_dir) / Path(file_path)
158 |
159 | cv2.imwrite(save_path.as_posix(), tile)
160 |
161 | # Create a dataframe with the results
162 | results_df = pd.DataFrame(results,
163 | columns=['tile_x1','tile_y1','tile_x2','tile_y2',
164 | 'box_class',
165 | 'box_x1','box_y1','box_x2','box_y2',
166 | 'old_box_x1','old_box_y1','old_box_x2','old_box_y2'])
167 |
168 | # Save the dataframe as a parquet file
169 | if settings.clear_duplicates:
170 | results_df.to_parquet(Path(settings.output_dir_duplicates) / f"tile_{filename}.parquet",
171 | index=False)
172 |
173 | return results_df
174 |
175 | def plot_example_tile_with_yolo_annotation(settings=None):
176 | """ Plot an example tile with the corresponding YOLO annotation. """
177 |
178 | # Get all image files from the tiles folder
179 | tile_imagepaths = list(Path(settings.output_dir_images).glob('*.{settings.output_extension_images}'))
180 |
181 | # Randomly select a tile from tile_imagepaths list
182 | im_selection = random.choice(tile_imagepaths)
183 | logger.info(im_selection)
184 | assert Path(im_selection).exists(), "does not exist"
185 | tile = cv2.imread(str(im_selection))
186 |
187 | # Read the corresponding annotation file
188 | annotation_selection = Path(settings.output_dir_annotations) / f"{im_selection.stem}.txt"
189 | logger.info(annotation_selection)
190 | assert Path(annotation_selection).exists(), "does not exist"
191 | with open(annotation_selection, mode='r', encoding="utf-8") as file:
192 | lines = file.readlines()
193 | for line in lines:
194 | line = line.strip().split()
195 | yolo_x = float(line[1])
196 | yolo_y = float(line[2])
197 | yolo_w = float(line[3])
198 | yolo_h = float(line[4])
199 | x_1, y_1, x_2, y_2 = convert_yolo_to_xyxy(yolo_x,
200 | yolo_y,
201 | yolo_w,
202 | yolo_h,
203 | tile.shape[0],
204 | tile.shape[1])
205 | cv2.rectangle(tile, (x_1, y_1), (x_2, y_2), (0, 255, 0), 2)
206 |
207 | # Plot the tile in RGB
208 | tile_rgb = cv2.cvtColor(tile, cv2.COLOR_BGR2RGB)
209 | plt.imshow(tile_rgb)
210 | plt.show()
211 |
212 | def process_tiles(t, input_im, input_annotation, settings=None):
213 | """ The main function to process a tile. """
214 | # Get the file name
215 | file_name = Path(input_im).stem
216 |
217 | # Read the image
218 | im = read_input_image(im_fname=file_name, settings=settings)
219 |
220 | # Split the image into tiles and get the coordinates of the tiles
221 | tiles, coordinates = tile_image(im.copy(), tile_size=settings.tile_size, step_size=settings.step_size)
222 |
223 | if settings.input_format_annotations == "segmentation":
224 | # raise NotImplementedError("Segmentation annotations are not supported yet.")
225 | settings.output_format_annotations = "segmentation"
226 | # assert spatial dimensions of image and mask are the same
227 | mask = read_input_mask(im_fname=file_name, settings=settings)
228 | assert (im.shape[0]==mask.shape[0]) and (im.shape[1]==mask.shape[1]), "spatial dimensions of image and mask are not the same"
229 | # Split the mask into tiles
230 | mask_tiles, mask_coordinates = tile_image(mask.copy(), tile_size=settings.tile_size, step_size=settings.step_size)
231 | # Save the mask tiles in the output directory for masks
232 | save_image_tiles(filename=file_name,
233 | tiles=mask_tiles,
234 | coordinates=mask_coordinates,
235 | settings=settings,
236 | prefix="mask")
237 |
238 | # Save the image tiles in the output directory for images
239 | save_image_tiles(filename=file_name,
240 | tiles=tiles,
241 | coordinates=coordinates,
242 | settings=settings,
243 | prefix="tile")
244 | return t
245 |
246 | else:
247 | # Read the coordinates of the bounding boxes from the annotation files
248 | bboxes, box_classes = read_coordinates_from_annotations(im_path=input_im,
249 | ant_path=input_annotation,
250 | image_shape=im.shape,
251 | settings=settings)
252 |
253 | # Get the bounding boxes inside the tiles
254 | if bboxes.shape[0] > 0:
255 | boxes_in_tiles = get_boxes_inside_tiles(bboxes=bboxes,
256 | tile_coordinates=coordinates,
257 | settings=settings)
258 | else:
259 | return t
260 |
261 | # Generate the tiles with the bounding boxes
262 | df_results = save_boxes(filename=file_name,
263 | tiles=tiles,
264 | coordinates=coordinates,
265 | boxes_in_tiles=boxes_in_tiles,
266 | box_classes=box_classes,
267 | settings=settings)
268 |
269 | # Save the annotations in Pascal VOC format or YOLO format
270 | save_annotations(df_results,
271 | filename=file_name,
272 | settings=settings,
273 | disable_progress_bar=True)
274 | return t
275 |
276 | def clear_duplicates(settings):
277 | """ Clear the duplicate tiles. """
278 |
279 | # Gather all the results from the different processes
280 | # since settings.duplicates is set to True
281 | # the results are saved in parquet files
282 | # in the settings.output_dir_duplicates folder
283 | all_subs = []
284 | results = Path(settings.output_dir_duplicates).glob("*.parquet")
285 | for file in tqdm(results, desc="Gathering results for duplicate removal.."):
286 | sub = pd.read_parquet(file)
287 | sub['filename'] = file.stem
288 | all_subs.append(sub)
289 | # Delete the file
290 | file.unlink()
291 | results_df = pd.concat(all_subs, ignore_index=True)
292 |
293 | # Format the filename to match the format of the saved
294 | # images and annotations
295 | results_df['filename'] = results_df['filename']+"_"+ \
296 | results_df['tile_x1'].astype(str)+"_"+ \
297 | results_df['tile_y1'].astype(str)+"_"+ \
298 | results_df['tile_x2'].astype(str)+"_"+ \
299 | results_df['tile_y2'].astype(str)
300 |
301 | # Define two sets to store all unique filenames and
302 | # filenames without duplicates so that we only keep the latter.
303 | all_filenames = set(results_df['filename'].unique().tolist())
304 | no_duplicates = set(results_df[
305 | ~results_df[
306 | ['old_box_x1', 'old_box_y1', 'old_box_x2', 'old_box_y2']
307 | ].duplicated()].filename.tolist())
308 |
309 | # Loop through all images and annotations and remove duplicates
310 | for filename in tqdm(all_filenames, desc="Removing duplicates..", total=len(all_filenames)):
311 | if filename in no_duplicates:
312 | continue
313 | else:
314 | annotation_file = Path(settings.output_dir_annotations) / \
315 | f"{filename}.{settings.output_extension_annotations}"
316 | image_file = Path(settings.output_dir_images) / \
317 | f"{filename}.{settings.output_extension_images}"
318 | annotation_file.unlink()
319 | image_file.unlink()
320 |
--------------------------------------------------------------------------------
/tests/Test_outputs.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "id": "b71cee3c-8b2c-406b-b690-4a26d3073e7b",
7 | "metadata": {
8 | "tags": []
9 | },
10 | "outputs": [],
11 | "source": [
12 | "%reset -f\n",
13 | "%load_ext autoreload\n",
14 | "%autoreload 2\n",
15 | "%matplotlib inline"
16 | ]
17 | },
18 | {
19 | "cell_type": "code",
20 | "execution_count": 2,
21 | "id": "b458e039-6a97-4653-9e03-c6aa2ae307ab",
22 | "metadata": {
23 | "tags": []
24 | },
25 | "outputs": [
26 | {
27 | "data": {
28 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaAAAAGgCAYAAADsNrNZAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8pXeV/AAAACXBIWXMAAA9hAAAPYQGoP6dpAABeg0lEQVR4nO29eZQd5Xnu+9Swp54lIXVLIAkxGDEPAkQHnBiQrcN1OHDQdexcEhOHFd84km0gZyVRlo19WIlFfO4JhCwZxw4LcGJCQnLAdhyDHWHkEyKBJZDBDEKAjMZujT3vsaruHzKNut/nw3urJapbfn5r7bWkt6u++r6avl37fep5vSRJEgghhBDvMX7aHRBCCPHLiSYgIYQQqaAJSAghRCpoAhJCCJEKmoCEEEKkgiYgIYQQqaAJSAghRCpoAhJCCJEKmoCEEEKkgiYgIYQQqXDMJqDVq1fj5JNPRj6fx+LFi/Hss88eq00JIYSYgnjHwgvuH//xH/Hxj38cX/3qV7F48WLcfffdeOSRR7B582bMmjXrXdeN4xi7du1Ca2srPM872l0TQghxjEmSBIODg5gzZw58/12ec5JjwKWXXposX7589P9RFCVz5sxJVq1a9QvX3b59ewJAH3300UefKf7Zvn37u97vQxxlKpUKNm7ciJUrV47GfN/HkiVLsG7dOrN8uVxGuVwe/X/y8weyu+75DAqF3Gj8N37jRrq9AB0kmrehataEnvzPDbTNM7ovNbG/f+xRE7v/b79J1y8N99keJRUTSyoDJtbe3kTbzAZ2fb9m1/fiGl3/+g8vM7GPf+L3TKzthJNMrIoMbXNPb8nEtr+1x8Q2PbuJrv/MM0+bWLF/r10wHjY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6fYs6PHggUL0NXVNWaMAwMDeOaZZybtGJMkwYoVK/Doo4/iySefxIIFC8b8fdGiRchkMmPGtHnzZmzbtm3SjokRxzHK5fKUHM/VV1+NF198EZs2bRr9XHzxxbjxxhtH/z3VxjSeoaEhvPHGG5g9e/aUPEYAcPnll5tXGF577TXMnz8fwNS8PxwxaasgGA8//HCSy+WSBx54IHn55ZeTT37yk0lHR0fS09OTdtfqZnBwMHn++eeT559/PgGQ/OVf/mXy/PPPJ2+99VaSJEly5513Jh0dHcm3vvWt5IUXXkiuu+66ZMGCBUmxWEy555xPfepTSXt7e/LUU08lu3fvHv2MjIyMLvP7v//7ybx585Inn3wy2bBhQ9Ld3Z10d3en2Ot350/+5E+StWvXJlu3bk1eeOGF5E/+5E8Sz/OS73//+0mSTL3xMA5XwSXJ1BvTH/7hHyZPPfVUsnXr1uTpp59OlixZkpxwwgnJnj17kiSZeuNJkiR59tlnkzAMkz//8z9PtmzZknzzm99Mmpqakr//+78fXWaq3R+OlEk5ASVJkvz1X/91Mm/evCSbzSaXXnppsn79+rS71BA//OEPEwDmc9NNNyVJckhq+fnPfz7p7OxMcrlccvXVVyebN29Ot9PvAhsLgOT+++8fXaZYLCZ/8Ad/kEybNi1pampK/tt/+2/J7t270+v0L+B3f/d3k/nz5yfZbDaZOXNmcvXVV49OPkky9cbDGD8BTbUxffSjH01mz56dZLPZ5MQTT0w++tGPJq+//vro36faeN7mO9/5TnLOOeckuVwuWbhwYfK1r31tzN+n2v3hSFE5BiGEEKkw6XJAQgghfjnQBCSEECIVNAEJIYRIBU1AQgghUkETkBBCiFTQBCSEECIVNAEJIYRIBU1AQgghUkETkBBCiFTQBCSEECIVNAEJIYRIBU1AQgghUuH/B3a2gTT1Te1VAAAAAElFTkSuQmCC",
29 | "text/plain": [
30 | ""
31 | ]
32 | },
33 | "metadata": {},
34 | "output_type": "display_data"
35 | }
36 | ],
37 | "source": [
38 | "import cv2\n",
39 | "import numpy as np\n",
40 | "import random\n",
41 | "import os\n",
42 | "import matplotlib.pyplot as plt\n",
43 | "import xml.etree.ElementTree as ET\n",
44 | "\n",
45 | "pascal_yolo = 'pascal'\n",
46 | "\n",
47 | "def read_pascal_voc_and_plot(image_path, annotations_path):\n",
48 | " # Read the image using OpenCV\n",
49 | " image = cv2.imread(image_path)\n",
50 | " if image is None:\n",
51 | " print(\"Error: Unable to read the image.\")\n",
52 | " return\n",
53 | "\n",
54 | " # Read the Pascal VOC annotations from the XML file\n",
55 | " tree = ET.parse(annotations_path)\n",
56 | " root = tree.getroot()\n",
57 | "\n",
58 | " annotations = []\n",
59 | " for obj in root.findall('object'):\n",
60 | " label = obj.find('name').text\n",
61 | " bbox = obj.find('bndbox')\n",
62 | " x_min = int(bbox.find('xmin').text)\n",
63 | " y_min = int(bbox.find('ymin').text)\n",
64 | " x_max = int(bbox.find('xmax').text)\n",
65 | " y_max = int(bbox.find('ymax').text)\n",
66 | "\n",
67 | " annotations.append((label, x_min, y_min, x_max, y_max))\n",
68 | "\n",
69 | " # Plot the image with bounding boxes\n",
70 | " for label, x_min, y_min, x_max, y_max in annotations:\n",
71 | " color = (0, 255, 0) # Green color for bounding boxes\n",
72 | " thickness = 2\n",
73 | " cv2.rectangle(image, (x_min, y_min), (x_max, y_max), color, thickness)\n",
74 | " cv2.putText(image, label, (x_min, y_min - 5), cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)\n",
75 | "\n",
76 | " plt.imshow(image)\n",
77 | " plt.show()\n",
78 | "\n",
79 | "def read_and_plot_yolo_annotations(image_path, annotations_path):\n",
80 | " # Read the image using OpenCV\n",
81 | " image = cv2.imread(image_path)\n",
82 | " if image is None:\n",
83 | " print(\"Error: Unable to read the image.\")\n",
84 | " return\n",
85 | " \n",
86 | " # Read the YOLO annotations from the file\n",
87 | " with open(annotations_path, 'r') as f:\n",
88 | " lines = f.readlines()\n",
89 | "\n",
90 | " annotations = []\n",
91 | " for line in lines:\n",
92 | " line = line.strip().split()\n",
93 | " label = line[0]\n",
94 | " x_center = float(line[1])\n",
95 | " y_center = float(line[2])\n",
96 | " width = float(line[3])\n",
97 | " height = float(line[4])\n",
98 | "\n",
99 | " # Calculate the coordinates of the bounding box\n",
100 | " x_min = int((x_center - width / 2) * image.shape[1])\n",
101 | " y_min = int((y_center - height / 2) * image.shape[0])\n",
102 | " x_max = int((x_center + width / 2) * image.shape[1])\n",
103 | " y_max = int((y_center + height / 2) * image.shape[0])\n",
104 | "\n",
105 | " annotations.append((label, x_min, y_min, x_max, y_max))\n",
106 | "\n",
107 | " # Plot the image with bounding boxes\n",
108 | " for label, x_min, y_min, x_max, y_max in annotations:\n",
109 | " color = (0, 255, 0) # Green color for bounding boxes\n",
110 | " thickness = 2\n",
111 | " cv2.rectangle(image, (x_min, y_min), (x_max, y_max), color, thickness)\n",
112 | " cv2.putText(image, label, (x_min, y_min - 5), cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)\n",
113 | "\n",
114 | " plt.imshow(image)\n",
115 | " plt.show()\n",
116 | "\n",
117 | "images = os.listdir('../output/images')\n",
118 | "image_path = os.path.join('../output/images', random.choice(images))\n",
119 | "\n",
120 | "plt.figure()\n",
121 | "if pascal_yolo == 'yolo':\n",
122 | " annotations_path = image_path.replace('images','annotations').replace('jpg','txt')\n",
123 | " assert os.path.isfile(annotations_path), \"File not found. Check if pascal_voc is set correctly.\"\n",
124 | " read_and_plot_yolo_annotations(image_path, annotations_path)\n",
125 | "elif pascal_yolo == 'pascal':\n",
126 | " annotations_path = image_path.replace('images','annotations').replace('jpg','xml')\n",
127 | " assert os.path.isfile(annotations_path), \"File not found. Check if pascal_voc is set correctly.\"\n",
128 | " read_pascal_voc_and_plot(image_path, annotations_path)\n",
129 | "else:\n",
130 | " raise ValueError(\"Wrong value for pascal_yolo\")"
131 | ]
132 | },
133 | {
134 | "cell_type": "code",
135 | "execution_count": null,
136 | "id": "be311255-abad-410a-b5f7-9bda40f631f3",
137 | "metadata": {},
138 | "outputs": [],
139 | "source": []
140 | }
141 | ],
142 | "metadata": {
143 | "kernelspec": {
144 | "display_name": "Python [conda env:plakakia] *",
145 | "language": "python",
146 | "name": "conda-env-plakakia-py"
147 | },
148 | "language_info": {
149 | "codemirror_mode": {
150 | "name": "ipython",
151 | "version": 3
152 | },
153 | "file_extension": ".py",
154 | "mimetype": "text/x-python",
155 | "name": "python",
156 | "nbconvert_exporter": "python",
157 | "pygments_lexer": "ipython3",
158 | "version": "3.11.0"
159 | }
160 | },
161 | "nbformat": 4,
162 | "nbformat_minor": 5
163 | }
164 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------