You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Image and Bounding Box Slicer-Resizer (image_bbox_slicer)
3
3
4
4
This easy-to-use library is a data transformer sometimes useful in Object Detection tasks. It splits images and their bounding box annotations into tiles, both into specific sizes and into any arbitrary number of equal parts. It can also resize them, both by specific sizes and by a resizing/scaling factor. Of course it goes without saying that just image slicing could in Segmentation tasks (where input and labels both are images). Read the docs [here](https://image-bbox-slicer.readthedocs.io/en/latest/).
Currently, this library only supports bounding box annotations in [PASCAL VOC](http://host.robots.ox.ac.uk/pascal/VOC/) format. And as of now, there is **no command line execution support**. Please raise an issue if needed.
@@ -14,203 +14,14 @@ Currently, this library only supports bounding box annotations in [PASCAL VOC](h
14
14
$ pip install image_bbox_slicer
15
15
```
16
16
17
-
This tool was tested on both Windows and Linx. Works with Python 3.4 and higher versions and requires:
17
+
This tool was tested on both Windows and Linx. Works well with Python 3.8.
18
18
```python
19
19
Pillow
20
20
numpy
21
21
pascal-voc-writer
22
22
matplotlib
23
23
```
24
24
25
-
## Usage - A Quick Demo
26
-
_Note: This usage demo can be found in `demo.ipynb` in the repo._
25
+
## Slicing Demo: [Docs](https://image-bbox-slicer.readthedocs.io/en/latest/slicing-demo.html) and [Notebook](https://github.com/acl21/image_bbox_slicer/blob/master/Slicing_Demo.ipynb)
27
26
28
-
```python
29
-
import image_bbox_slicer as ibs
30
-
```
31
-
32
-
### Create And Configure `Slicer` Object
33
-
34
-
#### Setting Paths To Source And Destination Directories.
35
-
You must configure paths to source and destination directories like the following.
The above images show the difference in slicing with and without partial labels. In the image on the left, all the box annotations masked in <spanstyle="color:green">**green**</span> are called Partial Labels.
54
-
55
-
Configure your slicer to either ignore or consider them by setting `Slicer` object's `keep_partial_labels` instance variable to `True` or `False` respectively. By default it is set to `False`.
An empty tile is a tile with no "labels" in it. The definition of "labels" here is tightly coupled with the user's preference of partial labels. If you choose to keep the partial labels (i.e. `keep_partial_labels = True`), a tile with a partial label is not treated as empty. If you choose to not keep the partial labels (i.e. `keep_partial_labels = False`), a tile with one or more partial labels is considered empty.
66
-
67
-
Configure your slicer to either ignore or consider empty tiles by setting `Slicer` object's `ignore_empty_tiles` instance variable to `True` or `False` respectively. By default it is set to `True`.
68
-
69
-
70
-
```python
71
-
slicer.ignore_empty_tiles =False
72
-
```
73
-
74
-
#### Before-After Mapping
75
-
76
-
You can choose to store the mapping between file names of the images before and after slicing by setting the `Slicer` object's `save_before_after_map` instance variable to `True`. By default it is set to `False`.
77
-
78
-
Typically, `mapper.csv` looks like the following:
79
-
```
80
-
| old_name | new_names |
81
-
|------------|---------------------------------|
82
-
| 2102 | 000001, 000002, 000003, 000004 |
83
-
| 3931 | 000005, 000005, 000007, 000008 |
84
-
| test_image | 000009, 000010, 000011, 000012 |
85
-
| ... | ... |
86
-
```
87
-
88
-
89
-
```python
90
-
slicer.save_before_after_map =True
91
-
```
92
-
93
-
### Slicing
94
-
95
-
#### Images and Bounding Box Annotations Simultaneously
Copy file name to clipboardexpand all lines: docs/index.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,9 @@
1
-
# Image and Box Annotation Slicer
1
+
# Image and Box Annotation Slicer-Resizer
2
2
3
3
This easy-to-use library is a data transformer sometimes useful in Object Detection tasks. It splits images and its bounding box annotations into tiles, both into specific sizes and into any arbitrary number of equal parts. It can also resize them, both by specific sizes and by a resizing/scaling factor.
Currently, this library only supports bounding box annotations in [PASCAL VOC](http://host.robots.ox.ac.uk/pascal/VOC/) format. And as of now, there is **no command line execution support**.
_Note: This usage demo can be found in `demo.ipynb` in the project's [repo](https://github.com/akshaychandra21/image_bbox_slicer)._
2
+
_Note: This usage demo can be found in `Slicing_Demo.ipynb` in the project's [repo](https://github.com/acl21/image_bbox_slicer)._
3
3
4
-
Setting Paths To Source And Destination Directories
5
-
You must configure paths to source and destination directories like the following.
4
+
### Setting Paths To Source And Destination Directories
5
+
You must configure paths to source and destination directories like the following. By default it takes the current working directory as the source folder for both images and annotations and also creates new folders:
@@ -29,7 +34,7 @@ Configure your slicer to either ignore or consider them by setting `Slicer` obje
29
34
slicer.keep_partial_labels =True
30
35
```
31
36
32
-
## Empty Tiles
37
+
###Empty Tiles
33
38

34
39
35
40
An empty tile is a tile with no "labels" in it. The definition of "labels" here is tightly coupled with the user's preference of partial labels. If you choose to keep the partial labels (i.e. `keep_partial_labels = True`), a tile with a partial label is not treated as empty. If you choose to not keep the partial labels (i.e. `keep_partial_labels = False`), a tile with one or more partial labels is considered empty.
@@ -40,7 +45,7 @@ Configure your slicer to either ignore or consider empty tiles by setting `Slice
40
45
slicer.ignore_empty_tiles =False
41
46
```
42
47
43
-
## Before-After Mapping
48
+
###Before-After Mapping
44
49
45
50
You can choose to store the mapping between file names of the images before and after slicing by setting the `Slicer` object's `save_before_after_map` instance variable to `True`. By default it is set to `False`.
46
51
@@ -59,9 +64,7 @@ Typically, `mapper.csv` looks like the following:
59
64
slicer.save_before_after_map =True
60
65
```
61
66
62
-
## Slicing
63
-
64
-
Slicing both images and box annotations at the same time.
67
+
### Slicing both images and box annotations at the same time.
65
68
66
69
** By Number Of Tiles **
67
70
@@ -86,41 +89,3 @@ slicer.visualize_random()
86
89

87
90
88
91
*Note: `visualize_sliced_random()` randomly picks a recently sliced image from the directory for plotting.*
89
-
90
-
## Resizing
91
-

92
-
93
-
Images and Bounding Box Annotations Simultaneously
94
-
95
-
** By Specific Size **
96
-
97
-
98
-
```python
99
-
slicer.resize_by_size(new_size=(500,200))
100
-
slicer.visualize_resized_random()
101
-
```
102
-
103
-
104
-

105
-
106
-
107
-

108
-
109
-
110
-
** By A Resize Factor **
111
-
112
-
113
-
```python
114
-
slicer.resize_by_factor(resize_factor=0.05)
115
-
slicer.visualize_resized_random()
116
-
```
117
-
118
-

119
-
120
-
121
-

122
-
123
-
_Note:_
124
-
*`visualize_resized_random()` randomly picks a recently resized image from the destination directory for plotting.*
0 commit comments