Skip to content

Instantly share code, notes, and snippets.

View wangg12's full-sized avatar

Gu Wang wangg12

View GitHub Profile
@markedphillips
markedphillips / docker-compose.yml
Last active November 14, 2019 01:34
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.
version: "2.2"
services:
sharelatex:
restart: always
image: dennis1f/sharelatex-texlive2018 # sharelatex/sharelatex:latest
container_name: sharelatex
depends_on:
mongo:
condition: service_healthy
redis:
@redknightlois
redknightlois / ralamb.py
Last active August 9, 2023 20:50
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
GuillaumeFavelier / normal_mapping_example.py
Last active April 23, 2019 03:02
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
version.
"""
import numpy as np
from vispy import app, gloo
@wangruohui
wangruohui / intel-nvidia.md
Last active April 25, 2024 10:38
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
Dref360 / coordconv2d.py
Last active February 11, 2020 14:40
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
gcusso / CoordConvLayer.py
Last active August 8, 2021 04:14
Extracted CordConvs tensorflow implementation from (An intriguing failing of convolutional neural networks and the CoordConv solution) https://arxiv.org/pdf/1807.03247.pdf
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
randomize / ply2obj.py
Last active March 27, 2024 15:33
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
ruotianluo / test_roialign.py
Created October 6, 2017 02:22
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
crcrpar / vgg.py
Created September 14, 2017 02:23
[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 https://github.com/pytorch/examples.
"""
import torch
from torchvision import models
class VGG_OUTPUT(object):
@yunjey
yunjey / download_flickr_image.py
Last active December 26, 2023 15:22
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)