Skip to content

Instantly share code, notes, and snippets.

View mkocabas's full-sized avatar

Muhammed Kocabas mkocabas

View GitHub Profile
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"

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>
####### 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)
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'
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
import os
import json
import shutil
import subprocess
import numpy as np
import os.path as osp
def run_openpose(
video_file,
output_folder,
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
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.
'''
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'
import torchvision
import os.path as osp
import numpy as np
import cv2
import torch
import time
def get_video_opencv(fname):
vid_tensor = []