Skip to content

Instantly share code, notes, and snippets.

Avatar

Gu Wang wangg12

View GitHub Profile
View cameras_real
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import math
import numpy as np
from typing import Tuple
import torch
import torch.nn.functional as F
from pytorch3d.transforms import Rotate, Transform3d, Translate
@wangg12
wangg12 / pytorch-glumpy.py
Created Oct 26, 2019 — forked from victor-shepardson/pytorch-glumpy.py
using pycuda and glumpy to draw pytorch GPU tensors to the screen without copying to host memory
View pytorch-glumpy.py
from contextlib import contextmanager
import numpy as np
import torch
from torch import Tensor, ByteTensor
import torch.nn.functional as F
from torch.autograd import Variable
import pycuda.driver
from pycuda.gl import graphics_map_flags
from glumpy import app, gloo, gl
@wangg12
wangg12 / tmux_local_install.sh
Created Oct 7, 2019 — forked from ryin/tmux_local_install.sh
bash script for installing tmux without root access
View tmux_local_install.sh
#!/bin/bash
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
TMUX_VERSION=1.8
View pytorch-numba.py
from timeit import default_timer as time
import numpy as np
from numba import cuda
import os
os.environ['NUMBAPRO_LIBDEVICE']='/usr/lib/nvidia-cuda-toolkit/libdevice/'
os.environ['NUMBAPRO_NVVM']='/usr/lib/x86_64-linux-gnu/libnvvm.so.3.1.0'
import numpy
import torch
import ctypes
@wangg12
wangg12 / delete_git_submodule.md
Created Sep 1, 2019 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.
View delete_git_submodule.md

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@wangg12
wangg12 / Install NVIDIA Driver and CUDA.md
Created Aug 3, 2019 — forked from wangruohui/Install NVIDIA Driver and CUDA.md
Install NVIDIA Driver and CUDA on Ubuntu / CentOS / Fedora Linux OS
View Install NVIDIA Driver and CUDA.md
@wangg12
wangg12 / gitBash_windows.md
Created Apr 21, 2019 — forked from evanwill/gitBash_windows.md
how to add more utilities to git bash for windows, wget, make
View gitBash_windows.md

How to add more to Git Bash on Windows

Git for Windows comes bundled with the "Git Bash" terminal which is incredibly handy for unix-like commands on a windows machine. It is missing a few standard linux utilities, but it is easy to add ones that have a windows binary available.

The basic idea is that C:\Program Files\Git\mingw64\ is your / directory according to Git Bash (note: depending on how you installed it, the directory might be different. from the start menu, right click on the Git Bash icon and open file location. It might be something like C:\Users\name\AppData\Local\Programs\Git, the mingw64 in this directory is your root. Find it by using pwd -W). If you go to that directory, you will find the typical linux root folder structure (bin, etc, lib and so on).

If you are missing a utility, such as wget, track down a binary for windows and copy the files to the corresponding directories. Sometimes the windows binary have funny prefixes, so

@wangg12
wangg12 / blender_cam.py
Created Apr 1, 2019 — forked from autosquid/blender_cam.py
blender-camera-from-3x4-matrix
View blender_cam.py
# from: http://blender.stackexchange.com/questions/40650/blender-camera-from-3x4-matrix?rq=1
# And: http://blender.stackexchange.com/questions/38009/3x4-camera-matrix-from-blender-camera
# Input: P 3x4 numpy matrix
# Output: K, R, T such that P = K*[R | T], det(R) positive and K has positive diagonal
#
# Reference implementations:
# - Oxford's visual geometry group matlab toolbox
# - Scilab Image Processing toolbox
@wangg12
wangg12 / sharelatex-install-ubuntu-16.04.md
Created Mar 29, 2019 — forked from gelim/sharelatex-install-ubuntu-16.04.md
sharelatex (non-docker) installation on a ubuntu 16.04 server
View sharelatex-install-ubuntu-16.04.md

Installing ShareLaTex on Ubuntu 16.04

Use this as-is without any warranty, and don't bug ShareLatex project members if there are problems with my instructions. They officialy support docker installation only.

This gist summarize the actions I did to setup a pure ShareLaTex community edition on a bare linux ubuntu 16.04 server (no docker). I intentionnaly tried to stick to distribution practice for running daemons (via runit, and not via a custom my_init + setuser wrapper).

I basically took ShareLaTeX receipt to build their docker and adapted it.

@wangg12
wangg12 / trim_detectron_model.py
Created Dec 18, 2018
trim last layers of detectron model for maskrcnn-benchmark
View trim_detectron_model.py
import os
import torch
import argparse
from maskrcnn_benchmark.config import cfg
from maskrcnn_benchmark.utils.c2_model_loading import load_c2_format
def removekey(d, listofkeys):
r = dict(d)
for key in listofkeys: