# ImageDatasetViz
[](https://travis-ci.org/vfdev-5/ImageDatasetViz)
[](https://coveralls.io/github/vfdev-5/ImageDatasetViz?branch=master)
Observe dataset of images and targets in few shots

## Descriptions
Idea is to create tools to store images, targets from a dataset as a few large images to observe the dataset
in few shots.
## Installation
#### with pip
```bash
pip install image-dataset-viz
```
#### from sources
```bash
python setup.py install
```
or
```bash
pip install git+https://github.com/vfdev-5/ImageDatasetViz.git
```
## Usage
### Render a single datapoint
First, we can just take a look on a single data point rendering. Let's assume that we
have `img` as, for example, `PIL.Image` and `target` as acceptable target type (`str` or list of points or
`PIL.Image` mask, etc), thus we can generate a single image with target.
```python
from image_dataset_viz import render_datapoint
# if target is a simple label
res = render_datapoint(img, "test label", text_color=(0, 255, 0), text_size=10)
plt.imshow(res)
# if target is a mask image (PIL.Image)
res = render_datapoint(img, target, blend_alpha=0.5)
plt.imshow(res)
# if target is a bounding box, e.g. np.array([[10, 10], [55, 10], [55, 77], [10, 77]])
res = render_datapoint(img, target, geom_color=(255, 0, 0))
plt.imshow(res)
```
#### Example output on Leaf Segmentation dataset from CVPPP2017
  
### Export complete dataset
For example, we have a dataset of image files and annotations files (polygons with labels):
```python
img_files = [
'/path/to/image_1.ext',
'/path/to/image_2.ext',
...
'/path/to/image_1000.ext',
]
target_files = [
'/path/to/target_1.ext2',
'/path/to/target_2.ext2',
...
'/path/to/target_1000.ext2',
]
```
We can produce a single image composed of 20x50 small samples with targets to better visualize the whole dataset.
Let's assume that we do need a particular processing to open the images in RGB 8bits format:
```python
from PIL import Image
def read_img_fn(img_filepath):
return Image.open(img_filepath).convert('RGB')
```
and let's say the annotations are just lines with points and a label, e.g. `12 23 34 45 56 67 car`
```python
from pathlib import Path
import numpy as np
def read_target_fn(target_filepath):
with Path(target_filepath).open('r') as handle:
points_labels = []
while True:
line = handle.readline()
if len(line) == 0:
break
splt = line[:-1].split(' ') # Split into points and labels
label = splt[-1]
points = np.array(splt[:-1]).reshape(-1, 2)
points_labels.append((points, label))
return points_labels
```
Now we can export the dataset
```python
de = DatasetExporter(read_img_fn=read_img_fn, read_target_fn=read_target_fn,
img_id_fn=lambda fp: Path(fp).stem, n_cols=20)
de.export(img_files, target_files, output_folder="dataset_viz")
```
and thus we should obtain a single png image with composed of 20x50 small samples.
## Examples
- [CIFAR10](examples/example_CIFAR10.ipynb)
- [VEDAI](examples/example_VEDAI.ipynb)
Metadata
Release files for image-dataset-viz 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| image_dataset_viz-0.2.2.tar.gz | 388.8 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| image_dataset_viz-0.2.2-py3.5.egg | Legacy Egg format | - | - | Details |
| image_dataset_viz-0.2.2-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 1.2 MB
Release files / image_dataset_viz-0.2.2.tar.gz
| Download URL | image_dataset_viz-0.2.2.tar.gz |
|---|---|
| Size | 388.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
459745f301956c28741226aa8916d76f3fee546e74cae938b12a0d53bfeece26
|
|
BLAKE2b-256 checksum How to use checksums |
ae7f08ebf3e0b4015e2fbd4cbb891f7128aab38d34d15322475031f192c4f4b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.6
|
Release files / image_dataset_viz-0.2.2-py3.5.egg
| Download URL | image_dataset_viz-0.2.2-py3.5.egg |
|---|---|
| Size | 396.9 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
04731971bea33b584db1566f703f6d9a3bb808e63cde5eec84c355e4e136cd1e
|
|
BLAKE2b-256 checksum How to use checksums |
1e31fa9a85638e770f1ced78e25fb8eabe7876881a0a627ca24d61a1615a6f68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.6
|
Release files / image_dataset_viz-0.2.2-py2.py3-none-any.whl
| Download URL | image_dataset_viz-0.2.2-py2.py3-none-any.whl |
|---|---|
| Size | 388.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
dcd879c48f7c916456898a81e604dec981967f4bba7e1dad5c35de07bdea826c
|
|
BLAKE2b-256 checksum How to use checksums |
05fc5b63dd6101991ff2a9f8e2df5cc27f5696c9e36d7c4bd22d0ed6c65fa05a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.6
|