Skip to content

Instantly share code, notes, and snippets.

Avatar

Muhammed Kocabas mkocabas

View GitHub Profile
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 Oct 9, 2019
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 = []
View download_coco.sh
#!/usr/bin/env bash
mkdir coco
cd coco/
wget http://images.cocodataset.org/zips/train2017.zip
wget http://images.cocodataset.org/zips/val2017.zip
unzip train2017.zip
unzip val2017.zip
View h36m_extract_frames_from_videos.py
import os
import subprocess
from multiprocessing import Process
NUM_PROCESS = 1 # define number of processes to speed up
VIDEOS_DIR = 'Videos' # path to Human3.6M videos
def find_files():
SUBJECTS = [1, 5, 6, 7, 8, 9, 11]