Skip to content

Instantly share code, notes, and snippets.

View gatheluck's full-sized avatar

Yoshihiro Fukuhara gatheluck

View GitHub Profile
@gatheluck
gatheluck / AutoDownloadCVF.py
Last active July 18, 2018 23:53
Automatic papers downloading from CVF
# -*- coding: utf-8 -*-
import os
import requests
conf = 'CVPR2016' # CVPR2015/CVPR2014/CVPR2013/ICCV2013
#header = 'http://www.cv-foundation.org/openaccess/'
header = 'http://openaccess.thecvf.com/'
def name_check(name):
name = name.replace('?','')
@gatheluck
gatheluck / pdf2jpg.py
Created July 18, 2018 23:51
Automatic file converting from pdf to jpg
# coding: utf-8
import os
import os.path
import fnmatch
import subprocess
import argparse
# Parse the arguments
parser = argparse.ArgumentParser(description='Tile the first num-pages horizontally into a JPEG image.')
@gatheluck
gatheluck / loss_plot.py
Created June 5, 2019 01:32
Plotting multiple loss by visdom with legend.
from visdom import Visdom
import argparse
import numpy as np
DEFAULT_PORT = 8097
DEFAULT_HOSTNAME = "http://localhost"
parser = argparse.ArgumentParser(description='Demo arguments')
parser.add_argument('-port', metavar='port', type=int, default=DEFAULT_PORT, help='port the visdom server is running on.')
parser.add_argument('-server', metavar='server', type=str, default=DEFAULT_HOSTNAME, help='Server address of the target to run the demo on.')
# This code is for self study.
# Remider of the difference between copy.copy and copy.deepcopy
# immutable objects
print('immutable object')
a = 'abc'
b = a
print("a:{}, id(a):{}".format(a, id(a)))
print("b:{}, id(b):{}".format(b, id(b)))
@gatheluck
gatheluck / tqdm_sample.py
Created July 1, 2019 09:16
simple progress meter by tqdm.
from tqdm import tqdm
import time
from collections import OrderedDict
from random import random
with tqdm(range(10000), ncols=10) as pbar:
for i in pbar:
pbar.set_postfix(OrderedDict(
output='{:06d}'.format(i),
loss='{:.4f}'.format(random())
@gatheluck
gatheluck / nmr_vs_softras.py
Last active August 29, 2019 11:20
Compare the results of rendering
import os
import tqdm
import argparse
import torch
import torch.nn as nn
import torchvision
from skimage.io import imread, imsave
@gatheluck
gatheluck / rbs_transformation.py
Last active October 9, 2019 00:19
RBS transformation used in "Robust Local Features for Improving the Generalization of Adversarial Training".
import random
import numpy as np
import copy
import torch
import torchvision
from torchvision import transforms
from PIL import Image
import os
import sys
import torch
import torch.nn.functional as F
import pymesh
class VisCameras():
init_front_vec = torch.tensor([1.0, 0.0, 0.0]).view(1,-1).float()
import os
import sys
import torch
import torch.nn.functional as F
import pymesh
class VisCameras():
init_front_vec = torch.tensor([1.0, 0.0, 0.0]).view(1,-1).float()
@gatheluck
gatheluck / camera_optimization.py
Last active October 21, 2019 13:06
comparison of camera parameter optimization example of NMR and SoftRas. When use both model at same time, it will lead nan loss value.
import os
import argparse
import glob
import torch
import torch.nn as nn
import numpy as np
from skimage.io import imread, imsave
import tqdm
import imageio