convert_data
Functions and classes for converting data.
bboxes_from_simulated_chirps(data, nfft)
Make bounding boxes of simulated chirps using the chirp parameters.
Parameters
data
:Dataset
The dataset to make bounding boxes for.nfft
: int The number of samples in the FFT.
Returns
pandas.DataFrame
A dataframe with the bounding boxes.
Source code in chirpdetector/convert_data.py
convert(data, conf, output, label_mode)
Convert a gridtools dataset to a YOLO dataset.
Parameters
data
:Dataset
The dataset to convert.conf
:Config
The configuration.output
:pathlib.Path
The output directory.label_mode
:str
The label mode. Can be one of 'none', 'synthetic' or 'detected'.
Returns
None
Notes
This function iterates through a raw recording in chunks and computes the sum spectrogram of each chunk. The chunk size needs to be chosen such that the images can be nicely fed to a detector. The function also computes the bounding boxes of chirps in that chunk and saves them to a dataframe and a txt file into a labels directory.
Source code in chirpdetector/convert_data.py
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 |
|
convert_bboxes_from_simulated_chirps(imgpath, spectrogram_times, spectrogram_frequencies, current_chunk, bboxes)
Generate labels of a simulated dataset.
Parameters
imgpath
:pathlib.Path
The path to the image.spectrogram_times
:np.ndarray
The time axis of the spectrogram.spectrogram_frequencies
:np.ndarray
The frequency axis of the spectrogram.current_chunk
:int
The chunk number.bboxes
:pd.DataFrame
The bounding boxes.
Returns
pandas.DataFrame
A dataframe with the bounding boxes.
Source code in chirpdetector/convert_data.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
|
convert_cli(path, output, label_mode)
Parse all datasets in a directory and convert them to a YOLO dataset.
Parameters
path
:pathlib.Path
The root directory of the datasets.
Returns
None
Source code in chirpdetector/convert_data.py
detected_labels(output, chunk, imgname, spec, spectrogram_times)
Use the detect_chirps to make a YOLO dataset.
Parameters
output
:pathlib.Path
The output directory.chunk
:Dataset
The dataset to make bounding boxes for.imgname
:str
The name of the image.spec
:np.ndarray
The spectrogram.spectrogram_times
:np.ndarray
The time axis of the spectrogram.
Returns
None
Source code in chirpdetector/convert_data.py
make_file_tree(path)
Build a file tree for the training dataset.
Parameters
path : pathlib.Path The root directory of the dataset.
Source code in chirpdetector/convert_data.py
numpy_to_pil(img)
Convert a 2D numpy array to a PIL image.
Parameters
img : np.ndarray The input image.
Returns
PIL.Image The converted image.
Source code in chirpdetector/convert_data.py
save_labels_for_simulated_chirps(bbox_df, dataset_root)
Save the labels for a simulated dataset.
Parameters
bbox_df
:pd.DataFrame
The bounding boxes.dataset_root
:pathlib.Path
The root directory of the dataset.
Returns
None