Skip to content

Instantly share code, notes, and snippets.

Avatar

Eric A. Scuccimarra escuccim

View GitHub Profile
@andrewjong
andrewjong / pytorch_image_folder_with_file_paths.py
Last active Oct 18, 2020
PyTorch Image File Paths With Dataset Dataloader
View pytorch_image_folder_with_file_paths.py
import torch
from torchvision import datasets
class ImageFolderWithPaths(datasets.ImageFolder):
"""Custom dataset that includes image file paths. Extends
torchvision.datasets.ImageFolder
"""
# override the __getitem__ method. this is the method that dataloader calls
def __getitem__(self, index):
@omoindrot
omoindrot / tensorflow_finetune.py
Last active Oct 27, 2020
Example TensorFlow script for fine-tuning a VGG model (uses tf.contrib.data)
View tensorflow_finetune.py
"""
Example TensorFlow script for finetuning a VGG model on your own data.
Uses tf.contrib.data module which is in release v1.2
Based on PyTorch example from Justin Johnson
(https://gist.github.com/jcjohnson/6e41e8512c17eae5da50aebef3378a4c)
Required packages: tensorflow (v1.2)
Download the weights trained on ImageNet for VGG:
```
wget http://download.tensorflow.org/models/vgg_16_2016_08_28.tar.gz
@alceufc
alceufc / softmax.py
Created Jan 24, 2016
Compute Softmax function using numpy.
View softmax.py
import numpy as np
def softmax(x):
"""
Compute softmax values for each sets of scores in x.
Rows are scores for each class.
Columns are predictions (samples).
"""
scoreMatExp = np.exp(np.asarray(x))
@vladignatyev
vladignatyev / progress.py
Last active Nov 25, 2020
Python command line progress bar in less than 10 lines of code.
View progress.py
# The MIT License (MIT)
# Copyright (c) 2016 Vladimir Ignatev
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the Software
# is furnished to do so, subject to the following conditions:
#
@juice49
juice49 / UniqueFilename
Created Jul 2, 2014
Laravel unique filename
View UniqueFilename
/**
* Creates a unique filename by appending a number
*
* i.e. if image.jpg already exists, returns
* image2.jpg
*/
function uniqueFilename($path, $name, $ext) {
$output = $name;
$basename = basename($name, '.' . $ext);
@ramhiser
ramhiser / jaccard.py
Last active Jul 27, 2020
Jaccard cluster similarity in Python
View jaccard.py
import itertools
def jaccard(labels1, labels2):
"""
Computes the Jaccard similarity between two sets of clustering labels.
The value returned is between 0 and 1, inclusively. A value of 1 indicates
perfect agreement between two clustering algorithms, whereas a value of 0
indicates no agreement. For details on the Jaccard index, see:
http://en.wikipedia.org/wiki/Jaccard_index
@smithdanielle
smithdanielle / check.packages.r
Created Apr 1, 2014
Check if multiple R packages are installed. Install them if they are not,then load them into the R session.
View check.packages.r
# check.packages function: install and load multiple R packages.
# Check to see if packages are installed. Install them if they are not, then load them into the R session.
check.packages <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
# Usage example
You can’t perform that action at this time.