Skip to content

Instantly share code, notes, and snippets.

@chamecall
chamecall / TopBiasedRandomCrop.py
Created March 25, 2025 13:19
custom image/bbox albumentation augmentation
import numpy as np
import cv2
from albumentations.core.transforms_interface import DualTransform
class TopBiasedRandomCrop(DualTransform):
"""
Randomly crops an image so that the cropped region's width is at least min_width and its height is at least min_height
of the original. The vertical (y) offset is biased by sampling from a Beta distribution with parameters beta_alpha and beta_beta.
This transform also adjusts bounding boxes in [x_min, y_min, x_max, y_max] format.
@chamecall
chamecall / git-tag-delete-local-and-remote.sh
Last active December 16, 2024 20:17 — forked from mobilemind/git-tag-delete-local-and-remote.sh
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d <tagname>
# delete remote tag '12345' (eg, GitHub version too)
git push origin :<tagname>
# create local tag
git tag <tagname>
# push tag to remote
git push origin <tagname>
@chamecall
chamecall / numpy_topk.py
Created August 13, 2024 11:21 — forked from EdisonLeeeee/numpy_topk.py
Numpy implementation of torch.topk
import numpy as np
from collections import namedtuple
topk_namedtuple = namedtuple('topk_namedtuple', ['values', 'indices'])
def topk(array: np.ndarray, k: int, largest: bool = True) -> topk_namedtuple:
"""Returns the k largest/smallest elements and corresponding indices
from an array-like input.
@chamecall
chamecall / qat_fx.py
Created October 11, 2023 20:12 — forked from TadaoYamaoka/qat_fx.py
Quantization Aware Training with FX Graph Mode
import os
import torch
import torch.nn as nn
import torch.optim as optim
import torchvision
from torchvision import transforms
from torch.ao.quantization import get_default_qat_qconfig_mapping
from torch.ao.quantization.quantize_fx import prepare_qat_fx, convert_fx
@chamecall
chamecall / pycocotools_tutorial.ipynb
Created January 25, 2023 08:14 — forked from interactivetech/pycocotools_tutorial.ipynb
Detailed Walkthrough of pycocotools and Python COCO API
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.