Skip to content

Instantly share code, notes, and snippets.

View rexlow's full-sized avatar
🏸
Need to workout more!

Rex Low rexlow

🏸
Need to workout more!
View GitHub Profile
@rexlow
rexlow / SampleGan.py
Created February 25, 2021 11:48
A quick and dirty implementation of GAN network in PyTorch that approximates a gaussian distribution
#!/usr/bin/python3
# Sample GAN implementation for learning purposes only
# The network will model 2 different dataset of different distribution and
# train Generator to approximate the Distributor's distribution better
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
@rexlow
rexlow / ImageTools.es6
Created September 20, 2019 03:48 — forked from dcollien/ImageTools.es6
Resize Images in the Browser
let hasBlobConstructor = typeof(Blob) !== 'undefined' && (function () {
try {
return Boolean(new Blob());
} catch (e) {
return false;
}
}());
let hasArrayBufferViewSupport = hasBlobConstructor && typeof(Uint8Array) !== 'undefined' && (function () {
try {
@rexlow
rexlow / movies.json
Created August 26, 2019 01:26
Mock movies data
[
{
"vote_count": 417,
"id": 429203,
"video": false,
"vote_average": 6.4,
"title": "The Old Man & the Gun",
"popularity": 304.393,
"poster_path": "/a4BfxRK8dBgbQqbRxPs8kmLd8LG.jpg",
"original_language": "en",
@rexlow
rexlow / calculate_distribution.py
Created April 22, 2019 05:03
Calculate data distribution
def calculate_distribution(loader):
step = 0
mean = torch.empty(3)
std = torch.empty(3)
for data, label in loader:
b, c, h, w = data.shape
total_pixels = b * h * w
sum_ = torch.sum(data, dim=[0, 2, 3])
sum_of_square = torch.sum(data ** 2, dim=[0, 2, 3])
name: "Face-ResNet"
layer {
name: "data"
type: "ImageData"
top: "data"
top: "label"
include {
phase: TRAIN
}
transform_param {
@rexlow
rexlow / irv2.py
Last active February 14, 2019 02:38
Inception Resnet V2
"""
Inception ResNet V2
Official Tensorflow Implementation
@ https://github.com/tensorflow/models/blob/master/research/slim/nets/inception_resnet_v2.py
Paper
@ http://arxiv.org/abs/1602.07261
Naming convention in the official TF-slim implementation
@rexlow
rexlow / server.py
Last active January 14, 2019 08:08
Tornado threaded async non-blocking server example
#!/usr/bin/python3
import time
import json
import urllib
from tornado.ioloop import IOLoop
from tornado.gen import coroutine
from tornado.httpserver import HTTPServer
from tornado.concurrent import run_on_executor
from tornado.web import Application, RequestHandler
name: "HED"
layer {
name: "data"
type: "ImageLabelmapData"
top: "data"
top: "label"
include {
phase: TRAIN
}
transform_param {
@rexlow
rexlow / NumpyPerformanceTest.py
Created January 3, 2019 08:55
NumpyPerformanceTest
""" File name : NumpyPerformanceTest.py
Description : This script is to profile the performance of different numpy methods
Usage : python3 NumpyPerformanceTest.py
Author : Rex Low
"""
import cv2
name: "SE-ResNet-50"
# mean_value: 104, 117, 123
layer {
name: "data"
type: "Input"
top: "data"
input_param: {
shape: {
dim: 1
dim: 3