Skip to content

Instantly share code, notes, and snippets.

View SheikSadi's full-sized avatar
🎯
Focusing

Sheik Sadi Rohmotullah SheikSadi

🎯
Focusing
View GitHub Profile
# Copyright (c) OpenMMLab. All rights reserved.
import os
import warnings
from argparse import ArgumentParser
import cv2
from mmpose.apis import (get_track_id, inference_top_down_pose_model,
init_pose_model, process_mmdet_results,
vis_pose_tracking_result)
@SheikSadi
SheikSadi / center_cumsum.py
Created November 16, 2022 09:04
numpy cumsum from a specified center
import numpy as np
def center_cumsum(a:np.ndarray, pivot:tuple) -> np.ndarray:
"""
Compute the cumsum but pivoting a specified index
"""
assert isinstance(a, np.ndarray)
assert a.ndim == 2
a_cum = np.zeros_like(a, dtype=a.dtype)
@SheikSadi
SheikSadi / smart_cropping.py
Last active November 16, 2022 16:19
Descent from Hilltop algorithm for cropping images based on saliency maps
import numpy as np
from skimage.feature import peak_local_max
from scipy.cluster.vq import kmeans
def get_centroids(array2d, maximum_gap=0.2, peak_theshold = 0.5):
maximum_distortion = array2d.shape[0] * maximum_gap
for _k in [1, 2, 3, 4]:
peaks = peak_local_max(array2d, threshold_rel=peak_theshold).astype(np.float32)
k_peaks, distortion = kmeans(peaks.astype(float), _k)