Skip to content

Instantly share code, notes, and snippets.

View mkocabas's full-sized avatar

Muhammed Kocabas mkocabas

View GitHub Profile
View nanorc
set smooth
## Nanorc files
include "/usr/share/nano/nanorc.nanorc"
## C/C++
include "/usr/share/nano/c.nanorc"
## HTML
include "/usr/share/nano/html.nanorc"
View README.md

How to visualize the body part segmentation?

This script lets you to visualize the body part segmentation labels of SMPL, SMPL-H, and 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>
View uncertainty_hmr.py
####### LOSS FUNCTION #######
class MultivariateGaussianNegativeLogLikelihood(nn.Module):
def __init__(self):
super(MultivariateGaussianNegativeLogLikelihood, self).__init__()
def forward(self, pred_mean, pred_var, gt):
mu = pred_mean
logsigma = pred_var
mse = -0.5 * torch.sum(torch.square((gt - mu) / torch.exp(logsigma)), dim=1)
View test_texture_render.py
import torch
import numpy as np
import neural_renderer as nr
import matplotlib.pyplot as plt
from smplx.body_models import SMPL
def main():
device = 'cuda'
View opengl_opencv.py
import cv2
import numpy as np
import math
cx = 88 #principal point x coord
cy = 109 #principal point y coord
w = 178 #image width
h = 218 #image height
near = 10 #near plane
far = 20 #far plane
View posetrack.py
import os
import json
import shutil
import subprocess
import numpy as np
import os.path as osp
def run_openpose(
video_file,
output_folder,
View gcn.py
import dgl
import torch
import torch.nn as nn
import time
def build_pose_graph():
g = dgl.DGLGraph()
g.add_nodes(16)
@mkocabas
mkocabas / batch_procrustes_pytorch.py
Created October 9, 2019 12:31
Pytorch batch procrustes implementation
View batch_procrustes_pytorch.py
import numpy as np
import torch
def compute_similarity_transform(S1, S2):
'''
Computes a similarity transform (sR, t) that takes
a set of 3D points S1 (3 x N) closest to a set of 3D points S2,
where R is an 3x3 rotation matrix, t 3x1 translation, s scale.
i.e. solves the orthogonal Procrutes problem.
'''
View extract_mpi_inf_3dhp_frames.py
import subprocess
import os
import os.path as osp
def extract_video(vid_filename, output_folder):
cmd = [
'ffmpeg',
'-i', vid_filename,
f'{output_folder}/%06d.jpg',
'-threads', '16'
View opencv_vs_torchvision_video.py
import torchvision
import os.path as osp
import numpy as np
import cv2
import torch
import time
def get_video_opencv(fname):
vid_tensor = []