Skip to content

Instantly share code, notes, and snippets.

View okiriza's full-sized avatar

Okiriza Wibisono okiriza

View GitHub Profile
@okiriza
okiriza / autoencoder_visualization.py
Last active February 24, 2022 11:50
Script for visualizing autoencoder and PCA encoding on MNIST data
import colorlover as cl
from plotly import graph_objs as go
from plotly import offline
from sklearn.decomposition import PCA
import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
from torchvision import datasets, transforms
@okiriza
okiriza / example_autoencoder.py
Last active December 1, 2020 06:58
Example convolutional autoencoder implementation using PyTorch
import random
import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import torchvision
from torchvision import datasets, transforms
@okiriza
okiriza / keras-resnet-extract-bottleneck-features.py
Last active May 1, 2017 19:48
Python function for extracting image features using bottleneck layer of Keras' ResNet50
from keras.applications.resnet50 import ResNet50, preprocess_input
from keras.preprocessing import image
import numpy as np
resnet = ResNet50(include_top=False)
def extract_features(img_paths, batch_size=64):
""" This function extracts image features for each image in img_paths using ResNet50 bottleneck layer.
Returned features is a numpy array with shape (len(img_paths), 2048).
from __future__ import print_function
import os
import time
import boto3
from boto3 import dynamodb
import cv2
import numpy as np
import scipy.misc
from datetime import datetime, timedelta
import urllib2
from urllib2 import URLError
import boto3
START_BYTE = b'\xff\xd8'
END_BYTE = b'\xff\xd9'
ITER_LIMIT = 10000