Skip to content

Instantly share code, notes, and snippets.

View JonathanLoscalzo's full-sized avatar

Jonathan Loscalzo JonathanLoscalzo

View GitHub Profile
@JonathanLoscalzo
JonathanLoscalzo / tiny_yolo-wheat_detection.ipynb
Created May 15, 2020 13:54
[Wheat detection] - Tiny Yolo implementation
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@JonathanLoscalzo
JonathanLoscalzo / custom_data_loader.py
Created June 4, 2020 17:13 — forked from ikhlestov/custom_data_loader.py
pytorch: custom data loader
import torch
import torchvision as tv
class ImagesDataset(torch.utils.data.Dataset):
def __init__(self, df, transform=None,
loader=tv.datasets.folder.default_loader):
self.df = df
self.transform = transform
self.loader = loader
@JonathanLoscalzo
JonathanLoscalzo / architecture_pattern.py
Created June 4, 2020 17:14 — forked from ikhlestov/architecture_pattern.py
pytorch: architecture pattern
class ImagesDataset(torch.utils.data.Dataset):
pass
class Net(nn.Module):
pass
model = Net()
optimizer = torch.optim.SGD(model.parameters(), lr=0.01)
scheduler = lr_scheduler.StepLR(optimizer, step_size=30, gamma=0.1)
criterion = torch.nn.MSELoss()
@JonathanLoscalzo
JonathanLoscalzo / imagenet1000_clsidx_to_labels.json
Last active June 5, 2020 20:35 — forked from yrevar/imagenet1000_clsidx_to_labels.txt
text: imagenet 1000 class idx to human readable labels (Fox, E., & Guestrin, C. (n.d.). Coursera Machine Learning Specialization.)
{
0: "tench, Tinca tinca",
1: "goldfish, Carassius auratus",
2: "great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias",
3: "tiger shark, Galeocerdo cuvieri",
4: "hammerhead, hammerhead shark",
5: "electric ray, crampfish, numbfish, torpedo",
6: "stingray",
7: "cock",
8: "hen",
@JonathanLoscalzo
JonathanLoscalzo / flametest.py
Created June 5, 2020 22:41
flametest.py for DL pytorch test
import torch
import torchvision
def get_model():
return torchvision.models.resnet18(pretrained=True)
def get_pred(model):
return model(torch.rand([1,3,224,224]))
model = get_model()
for i in range(1,10000):
get_pred(model)
@JonathanLoscalzo
JonathanLoscalzo / copia-de-running-spark-on-colab.ipynb
Created June 12, 2020 12:57
Copia de RUNNING SPARK ON COLAB
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@JonathanLoscalzo
JonathanLoscalzo / stratified_sample.py
Created June 15, 2020 04:13 — forked from srikarplus/stratified_sample.py
Stratified Sampling in Pytorch
def make_weights_for_balanced_classes(images, nclasses):
count = [0] * nclasses
for item in images:
count[item[1]] += 1
weight_per_class = [0.] * nclasses
N = float(sum(count))
for i in range(nclasses):
weight_per_class[i] = N/float(count[i])
weight = [0] * len(images)
for idx, val in enumerate(images):
@JonathanLoscalzo
JonathanLoscalzo / register-jupyter-env
Created June 23, 2020 22:29 — forked from thvitt/register-jupyter-env
Register a jupyter kernel for the current pyenv.
#!/bin/sh
if [ "$PYENV_VERSION" -ne "" ]
then
name=`pyenv version-name`
python=`pyenv which python`
else
name=`basename "$VIRTUAL_ENV"`
python="$VIRTUALENV/bin/python"
fi
@JonathanLoscalzo
JonathanLoscalzo / 03-pytorch_text_classification.ipynb
Created July 3, 2020 18:33
03-pytorch_text_classification.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@JonathanLoscalzo
JonathanLoscalzo / StartLabelDetection.js
Created July 17, 2020 15:47
[medium] startLabelDetection for Rekognition into a Lambda
const AWS = require('aws-sdk')
const rek = new AWS.Rekognition();
var configuration = {
AWSAccessKeyId: process.env.AWSAccessKeyId,
AWSSecretKey: process.env.AWSSecretKey
}
AWS.config.update({
accessKeyId: configuration.AWSAccessKeyId,