Skip to content

Commit e8d8f53

Browse files
committed
Mosaic augmentation script added
1 parent 8d4d3b7 commit e8d8f53

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1238
-0
lines changed

Mosaic_Augmentation/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Mosaic Augmentation Implementation in Python
2+
3+
This script implements the mosaic augmentation technique in Python to create mosaics of images. Mosaic augmentation is a data augmentation method commonly used in computer vision tasks to augment image datasets.
4+
5+
## Setup Instructions
6+
7+
To use this script, follow these steps:
8+
9+
1. Install the required dependencies:
10+
11+
```bash
12+
pip install numpy opencv-python Pillow
13+
```
14+
15+
2. Download the script from the GitHub repository: [link-to-repository]
16+
17+
3. Place the script in the same directory as the dataset folder containing 'Annotations' and 'Images' subfolders.
18+
19+
4. Import the necessary modules at the beginning of your script:
20+
21+
```python
22+
import random
23+
import cv2
24+
import os
25+
import glob
26+
import numpy as np
27+
from PIL import Image
28+
```
29+
30+
5. Modify the `ANNO_DIR` and `IMG_DIR` variables in the script to point to the respective folders containing annotations and images.
31+
32+
6. Run the script:
33+
34+
```bash
35+
python script_name.py
36+
```
37+
38+
## Detailed Explanation
39+
40+
This script reads a dataset of annotated images, randomly selects four images, and creates a mosaic image by combining them. The mosaic is divided into four quadrants, and each input image is placed in one quadrant with a random scale. Annotations for the new mosaic are also updated accordingly.
41+
42+
43+
### Developed by [Arvind Srivastav](https://github.com/alwenpy)
44+
45+
## Disclaimers
46+
47+
This script is provided as-is and without any warranties. The author is not responsible for any misuse or damages resulting from the use of this script. Use it responsibly and at your own risk.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
35
2+
1 45 235 79 318
3+
1 60 209 120 356
4+
1 119 214 168 336
5+
1 94 220 136 326
6+
1 213 201 287 381
7+
1 268 201 339 378
8+
1 312 192 389 380
9+
1 374 226 391 267
10+
1 417 225 438 279
11+
1 428 222 446 266
12+
1 443 224 456 258
13+
1 449 227 467 271
14+
1 396 217 406 241
15+
1 402 210 413 238
16+
1 409 217 419 241
17+
1 531 222 550 287
18+
1 527 217 538 245
19+
1 511 213 522 240
20+
1 515 211 525 237
21+
1 491 216 502 243
22+
1 484 209 494 235
23+
1 473 211 483 235
24+
1 477 211 487 236
25+
1 468 212 476 235
26+
1 461 210 471 236
27+
1 456 212 466 240
28+
1 448 209 459 237
29+
1 439 210 450 237
30+
1 431 211 442 241
31+
1 420 213 432 242
32+
3 0 208 46 407
33+
3 65 216 88 241
34+
3 167 233 180 250
35+
3 150 222 160 238
36+
3 381 222 395 246
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
147
2+
1 50 132 117 296
3+
1 93 163 147 294
4+
1 172 141 226 273
5+
1 196 156 232 245
6+
1 259 156 296 248
7+
1 477 158 507 242
8+
1 477 35 504 104
9+
1 456 103 486 178
10+
1 445 102 475 177
11+
1 418 105 446 175
12+
1 454 39 479 103
13+
1 459 66 480 119
14+
1 446 65 468 119
15+
1 433 63 456 120
16+
1 415 62 439 124
17+
1 401 66 424 124
18+
1 386 69 407 124
19+
1 368 66 392 125
20+
1 357 63 383 127
21+
1 342 64 368 130
22+
1 308 63 335 131
23+
1 284 78 316 156
24+
1 410 33 438 104
25+
1 325 63 351 130
26+
1 271 45 296 108
27+
1 259 72 286 137
28+
1 247 63 274 131
29+
1 228 60 256 130
30+
1 213 46 235 102
31+
1 199 50 222 106
32+
1 183 53 206 109
33+
1 156 45 179 101
34+
1 128 64 149 118
35+
1 119 62 140 117
36+
1 103 57 128 117
37+
1 89 56 111 109
38+
1 74 49 99 111
39+
1 72 88 98 151
40+
1 56 94 81 154
41+
1 43 90 70 155
42+
1 30 99 52 153
43+
1 45 58 66 110
44+
1 23 63 49 130
45+
1 32 55 57 115
46+
1 17 47 41 105
47+
1 0 129 17 203
48+
1 0 128 25 201
49+
3 35 185 63 237
50+
3 87 186 111 229
51+
3 129 176 146 197
52+
3 157 179 186 238
53+
3 281 154 296 202
54+
3 301 176 321 239
55+
3 325 177 352 236
56+
3 355 175 381 229
57+
3 382 175 414 234
58+
3 423 203 453 248
59+
3 415 175 440 211
60+
3 439 175 464 212
61+
3 469 177 498 230
62+
3 482 126 504 161
63+
3 482 106 500 126
64+
3 488 96 502 114
65+
3 432 51 446 65
66+
3 431 88 448 117
67+
3 410 105 426 124
68+
3 397 123 419 162
69+
3 374 123 396 162
70+
3 349 119 370 160
71+
3 325 122 349 164
72+
3 301 122 323 165
73+
3 279 125 300 162
74+
3 257 122 278 159
75+
3 391 108 405 127
76+
3 389 96 405 111
77+
3 367 96 386 118
78+
3 340 98 363 118
79+
3 386 53 401 69
80+
3 385 41 398 56
81+
3 362 36 379 60
82+
3 352 50 365 66
83+
3 322 98 335 118
84+
3 324 47 340 64
85+
3 324 34 340 49
86+
3 309 48 323 65
87+
3 293 45 309 66
88+
3 294 65 311 87
89+
3 278 101 292 119
90+
3 279 74 290 90
91+
3 260 46 274 65
92+
3 262 113 283 126
93+
3 246 52 258 69
94+
3 241 109 258 148
95+
3 218 126 236 160
96+
3 190 122 209 153
97+
3 247 100 259 110
98+
3 235 101 249 112
99+
3 223 107 238 125
100+
3 221 99 233 109
101+
3 207 103 218 117
102+
3 199 112 213 125
103+
3 195 98 207 110
104+
3 216 87 227 98
105+
3 218 80 228 87
106+
3 202 85 213 98
107+
3 204 73 216 85
108+
3 174 111 192 131
109+
3 155 111 175 138
110+
3 136 110 155 136
111+
3 180 99 193 113
112+
3 168 102 179 113
113+
3 184 82 194 96
114+
3 176 74 186 88
115+
3 165 86 178 98
116+
3 162 75 172 87
117+
3 146 94 163 110
118+
3 135 100 146 113
119+
3 148 63 165 80
120+
3 138 50 153 64
121+
3 126 125 146 155
122+
3 110 125 126 153
123+
3 93 127 109 151
124+
3 92 108 108 129
125+
3 109 108 124 126
126+
3 123 108 137 124
127+
3 121 96 133 111
128+
3 123 87 133 102
129+
3 107 84 123 107
130+
3 107 45 119 57
131+
3 96 48 106 57
132+
3 91 88 102 100
133+
3 65 65 81 78
134+
3 55 72 69 89
135+
3 51 129 68 173
136+
3 34 130 47 177
137+
3 61 52 71 63
138+
3 54 54 62 66
139+
3 19 128 34 176
140+
3 16 103 34 128
141+
3 0 116 9 126
142+
3 0 87 14 113
143+
3 42 48 48 56
144+
3 12 76 23 88
145+
3 8 55 19 70
146+
3 1 56 15 83
147+
3 0 50 6 65
148+
3 83 74 95 90
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
24
2+
1 0 122 59 312
3+
1 59 129 117 272
4+
1 44 115 92 234
5+
1 83 136 160 327
6+
1 146 126 184 222
7+
1 195 141 251 279
8+
1 220 135 285 294
9+
1 258 136 327 306
10+
1 303 152 360 293
11+
1 323 148 375 278
12+
1 366 138 432 301
13+
1 444 151 507 306
14+
1 486 142 551 316
15+
1 433 97 469 188
16+
3 126 138 146 168
17+
3 264 146 285 175
18+
3 303 125 320 161
19+
3 325 136 343 155
20+
3 406 155 422 172
21+
3 528 155 544 176
22+
3 463 134 477 149
23+
5 356 148 388 162
24+
5 410 137 437 153
25+
5 490 146 507 156
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
34
2+
1 24 53 84 200
3+
1 53 45 86 128
4+
1 72 49 119 163
5+
1 100 45 174 225
6+
1 129 44 183 175
7+
1 167 48 207 145
8+
1 159 44 188 115
9+
1 206 41 253 157
10+
1 204 50 229 112
11+
1 257 41 285 113
12+
1 275 47 306 126
13+
1 287 48 326 143
14+
1 306 48 355 171
15+
1 338 42 374 133
16+
1 214 41 276 196
17+
1 367 51 409 154
18+
1 396 44 417 98
19+
1 407 46 446 143
20+
1 439 48 473 133
21+
1 475 48 505 125
22+
1 490 46 508 93
23+
3 0 184 24 278
24+
3 0 76 16 177
25+
3 0 53 21 143
26+
3 29 45 44 81
27+
3 109 46 126 136
28+
3 305 44 319 103
29+
3 339 42 352 65
30+
3 360 45 366 108
31+
3 391 43 403 102
32+
3 430 41 438 113
33+
3 448 44 453 99
34+
3 478 44 492 72
35+
3 503 55 509 116
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
16
2+
1 0 28 86 247
3+
1 70 47 143 228
4+
1 174 45 255 246
5+
1 148 54 225 242
6+
1 96 62 149 192
7+
1 348 99 368 151
8+
1 380 64 429 183
9+
1 397 66 447 187
10+
1 420 59 476 199
11+
1 443 59 503 209
12+
1 490 65 554 221
13+
1 513 60 582 231
14+
3 153 75 184 138
15+
3 242 111 254 146
16+
3 254 115 264 143
17+
3 262 115 281 141
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
49
2+
1 0 125 24 231
3+
1 0 127 35 226
4+
1 19 122 59 223
5+
1 39 122 84 235
6+
1 78 138 107 212
7+
1 96 139 121 201
8+
1 111 119 151 217
9+
1 131 127 175 236
10+
1 155 133 188 214
11+
1 174 133 202 203
12+
1 187 129 231 240
13+
1 229 125 271 231
14+
1 243 123 284 225
15+
1 271 129 305 214
16+
1 289 130 321 209
17+
1 312 129 342 206
18+
1 319 129 352 209
19+
1 341 122 380 218
20+
1 369 126 407 219
21+
1 384 119 430 231
22+
1 426 120 473 238
23+
1 440 123 480 224
24+
1 451 125 487 216
25+
1 457 123 496 218
26+
1 474 122 500 219
27+
3 136 121 144 134
28+
3 173 127 182 136
29+
3 196 125 204 138
30+
3 235 127 245 141
31+
3 269 128 277 141
32+
3 278 130 287 142
33+
3 327 123 335 131
34+
3 347 125 357 136
35+
3 364 123 371 135
36+
3 412 123 422 137
37+
3 429 128 438 140
38+
3 438 129 446 139
39+
3 425 125 433 135
40+
5 19 123 34 136
41+
5 67 128 88 140
42+
5 87 125 101 139
43+
5 103 129 125 140
44+
5 158 134 168 143
45+
5 218 127 235 140
46+
5 292 128 301 140
47+
5 308 127 324 138
48+
5 340 128 349 140
49+
5 372 123 384 138
50+
5 479 128 490 138

0 commit comments

Comments
 (0)