dgs.utils.utils

General utility functions.

Module Functions

extract_crops_and_save(img_fps, boxes, new_fps)

Given a list of original image paths and a list of target image-crops paths, use the given bounding boxes to extract the image content as image crops and save them as new images.

extract_crops_from_images(imgs, bboxes[, kps])

Given a list of images, use the bounding boxes to extract the respective image crops.

ids_to_one_hot(ids, nof_classes)

Given a tensor containing the class ids as LongTensor, return the one hot representation as LongTensor.

notify_on_completion_or_error([info, min_time])

A decorator that sends a Discord notification when the decorated function completes successfully or fails.

replace_file_type(fp, new_type[, old_types])

Replace the file extension of a file path with a new type.

send_discord_notification(message)

Sends a notification message to a Discord channel via a webhook.

torch_to_numpy(tensor)

Clone and convert torch tensor to numpy.

Module Classes

HidePrint()

Safely disable printing for a block of code.

MemoryTracker([interval, top_n])

A Wrapper for tracking RAM usage.