Skip to content

Instantly share code, notes, and snippets.

Avatar

Gu Wang wangg12

View GitHub Profile
@markedphillips
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"
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 Jun 27, 2021
Ralamb optimizer (RAdam + LARS trick)
View ralamb.py
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 Apr 23, 2019
This example is a prototype demonstrating normal mapping in VisPy
View normal_mapping_example.py
#!/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 Jan 20, 2022
Intel for display, Nvidia for computing
View intel-nvidia.md

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 Feb 11, 2020
Un-scaled version of CoordConv2D
View coordconv2d.py
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 Aug 8, 2021
Extracted CordConvs tensorflow implementation from (An intriguing failing of convolutional neural networks and the CoordConv solution) https://arxiv.org/pdf/1807.03247.pdf
View CoordConvLayer.py
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 Oct 17, 2021
Python script to convert *.ply to *.obj (3D formats)
View ply2obj.py
'''
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 Oct 6, 2017
A snippet to show how roialign works
View test_roialign.py
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 Sep 14, 2017
[PyTorch] pre-trained VGG16 for perceptual loss. e.g. Style Transfer
View vgg.py
"""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 Dec 31, 2021
downloading images from flickr using python-flickr
View download_flickr_image.py
# 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)