Skip to content

Instantly share code, notes, and snippets.

View woo1's full-sized avatar
😝
Good

wooil woo1

😝
Good
View GitHub Profile
#!/usr/bin/env python
# pip uninstall opencv-python
# pip install -U opencv-contrib-python
# run with webcam : python charuco_webcam.py 0
import cv2
import numpy as np
import matplotlib.pyplot as plt
import glob
def _xywh2cs(x, y, w, h):
center = np.zeros((2), dtype=np.float32)
center[0] = x + (w - 1) * 0.5
center[1] = y + (h - 1) * 0.5
IMAGE_SIZE =[288, 384]
aspect_ratio = IMAGE_SIZE[0] * 1.0 / IMAGE_SIZE[1]
pixel_std = 200
if w > aspect_ratio * h:
@woo1
woo1 / post_process_infant_pose_est.py
Created February 2, 2023 08:24
2d pose estimation pose process example
import numpy as np
def get_max_preds(batch_heatmaps):
'''
get predictions from score maps
heatmaps: numpy.ndarray([batch_size, num_joints, height, width])
'''
assert isinstance(batch_heatmaps, np.ndarray), \
'batch_heatmaps should be numpy.ndarray'
assert batch_heatmaps.ndim == 4, 'batch_images should be 4-ndim'
@woo1
woo1 / gan.py
Created May 29, 2022 07:18
GAN Basic model
import torch
import torch.nn as nn
# MNIST - 0~1 분류, Discriminator
D = nn.Sequential(
nn.Linear(784, 128),
nn.ReLU(),
nn.Linear(128, 1),
nn.Sigmoid()
)
@woo1
woo1 / PARE_to_Anim_NeRF_action.py
Created February 4, 2022 06:01
convert PARE output to Anim-NeRF action data
import pickle
import numpy as np
import os.path as osp
import glob
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--pare_rslt_dir', type=str, default='',
help='')
@woo1
woo1 / read_pickle.py
Last active December 27, 2021 07:50
python2에서 dump된 pickle 파일을 python3에서 읽기
# reference : https://jangjy.tistory.com/336
import pickle
with open('data.pkl', 'rb') as f:
# data = pickle.load(f)
u = pickle._Unpickler(f)
u.encoding = 'latin1'
p = u.load()
print(p)
@woo1
woo1 / latent_xyzc.py
Created December 20, 2021 05:19
spconv 버전 업데이트에 따른 수정
import torch.nn as nn
import spconv
import torch.nn.functional as F
import torch
from lib.config import cfg
from . import embedder
from spconv.pytorch.modules import SparseModule, SparseSequential
from spconv.pytorch.conv import SubMConv3d, SparseConv3d
from spconv.pytorch.core import SparseConvTensor
@woo1
woo1 / pare_smpl2smplx.py
Created November 16, 2021 04:23
PARE smpl output pickle data to smplx using frankmocap module
import torch
import numpy as np
import sys
import os
sys.path.append(os.getcwd())
from bodymocap.body_mocap_api import BodyMocap
import pickle
import joblib
import os.path as osp
import trimesh
@woo1
woo1 / README.md
Last active October 6, 2021 11:59 — forked from mkocabas/README.md

How to visualize the body part segmentation from smpl-x output?

This script lets you to visualize the body part segmentation labels of SMPL-X body models. Follow the instructions to be able to run this script.

Instructions

  1. Download the body models you would like to visualize.
  2. Install the requirements
  3. Run python visualize_body_part_segmentation.py <body_model> <body_model_path> <parameter_file_path>

An example command python visualize_body_part_segmentation.py smplx data/body_models/smplx output_data_path.pkl

@woo1
woo1 / global_attention.py
Created September 23, 2021 05:21
global_attention.py in GAST
from __future__ import absolute_import, division
import torch
from torch import nn
class GlobalGraph(nn.Module):
""""
Global graph attention layer
"""