Skip to content

Instantly share code, notes, and snippets.


Gu Wang wangg12

View GitHub Profile
markedphillips / docker-compose.yml
Last active Nov 14, 2019
In a folder "overleaf" with this file, "docker-compose up -d" and your overleaf will magically be updated. This addresses the overleaf base image which has a dated latex package and a broken update mechanism.
View docker-compose.yml
version: "2.2"
restart: always
image: dennis1f/sharelatex-texlive2018 # sharelatex/sharelatex:latest
container_name: sharelatex
condition: service_healthy
redknightlois /
Last active Jun 27, 2021
Ralamb optimizer (RAdam + LARS trick)
class Ralamb(Optimizer):
def __init__(self, params, lr=1e-3, betas=(0.9, 0.999), eps=1e-8, weight_decay=0):
defaults = dict(lr=lr, betas=betas, eps=eps, weight_decay=weight_decay)
self.buffer = [[None, None, None] for ind in range(10)]
super(Ralamb, self).__init__(params, defaults)
def __setstate__(self, state):
super(Ralamb, self).__setstate__(state)
GuillaumeFavelier /
Last active Apr 23, 2019
This example is a prototype demonstrating normal mapping in VisPy
#!/usr/bin/env python
# -*- coding: utf-8 -*-
This example is a prototype demonstrating normal mapping
by comparison between a reference mesh and its flatten
import numpy as np
from vispy import app, gloo
wangruohui /
Last active Jan 20, 2022
Intel for display, Nvidia for computing

Intel for display, NVIDIA for computing

This guide will show you how to use Intel graphics for rendering display and NVIDIA graphics for CUDA computing on Ubuntu 18.04 / 20.04 desktop.

I made this work on an ordinary gaming PC with two graphics devices, an Intel UHD Graphics 630 plus an NVIDIA GeForce GTX 1080 Ti. Both of them can be shown via lspci | grep VGA.

00:02.0 VGA compatible controller: Intel Corporation Device 3e92
01:00.0 VGA compatible controller: NVIDIA Corporation GP102 [GeForce GTX 1080 Ti] (rev a1)
Dref360 /
Last active Feb 11, 2020
Un-scaled version of CoordConv2D
import keras.backend as K
import tensorflow as tf
from tensorflow.keras.layers import Layer
"""Not tested, I'll play around with GANs soon with it."""
from tensorflow.keras.layers import Conv2D
import numpy as np
class CoordConv2D(Layer):
gcusso /
Last active Aug 8, 2021
Extracted CordConvs tensorflow implementation from (An intriguing failing of convolutional neural networks and the CoordConv solution)
from tensorflow.python.layers import base
import tensorflow as tf
class AddCoords(base.Layer):
"""Add coords to a tensor"""
def __init__(self, x_dim=64, y_dim=64, with_r=False):
super(AddCoords, self).__init__()
self.x_dim = x_dim
self.y_dim = y_dim
randomize /
Last active Oct 17, 2021
Python script to convert *.ply to *.obj (3D formats)
Simple script to convert ply to obj models
from argparse import ArgumentParser
from plyfile import PlyData
def main():
parser = ArgumentParser()
ruotianluo /
Created Oct 6, 2017
A snippet to show how roialign works
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import numpy as np
crcrpar /
Created Sep 14, 2017
[PyTorch] pre-trained VGG16 for perceptual loss. e.g. Style Transfer
"""Modified VGG16 to compute perceptual loss.
This class is mostly copied from pytorch/examples.
See, fast_neural_style in
import torch
from torchvision import models
class VGG_OUTPUT(object):
yunjey /
Last active Dec 31, 2021
downloading images from flickr using python-flickr
# First, you should install flickrapi
# pip install flickrapi
import flickrapi
import urllib
from PIL import Image
# Flickr api access key
flickr=flickrapi.FlickrAPI('c6a2c45591d4973ff525042472446ca2', '202ffe6f387ce29b', cache=True)