Skip to content

Instantly share code, notes, and snippets.

View davidefiocco's full-sized avatar

Davide Fiocco davidefiocco

View GitHub Profile
@davidefiocco
davidefiocco / colafinetuning.ipynb
Last active November 5, 2020 17:57
CoLAfinetuning.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@davidefiocco
davidefiocco / batch-bert.ipynb
Created October 22, 2020 15:09
Batch BERT.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@davidefiocco
davidefiocco / mirror.sh
Last active July 23, 2020 16:22
Launch webcam mirror on Linux
gst-launch-1.0 v4l2src device=/dev/video0 ! xvimagesink
@davidefiocco
davidefiocco / test_transforms.py
Created May 19, 2020 12:18
Test torchvision tranforms on a bunch of images
from torchvision import datasets, models, transforms
from PIL import Image
import torch
import matplotlib.pyplot as plt
from pathlib import Path
images = list(Path('../foo').glob('**/*.*'))
example = images.pop()
img = Image.open(example).convert('RGB')
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@davidefiocco
davidefiocco / ImdbBERTInterpretation.ipynb
Last active March 31, 2020 22:18
Trying captum interpretation on pretrained sentiment classifier
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import prodigy
from prodigy.components.loaders import Images
from prodigy.util import split_string
def add_label_to_stream(stream, label):
for eg in stream:
# The 'label' you get from the command line is a list
# so let's just assume it's always one and take the first
eg["label"] = label[0]
yield eg
@davidefiocco
davidefiocco / imagenet_poppins.py
Created February 16, 2019 23:30
Reorganize image files with imagenet style folder hierarchy
import numpy as np
import shutil
from sklearn.model_selection import train_test_split
cats = ['negative', 'positives']
for cat in cats:
print(cat)
if not os.path.exists(data_folder + "/train/" + cat):
os.makedirs(data_folder + "/train/" + cat)
@davidefiocco
davidefiocco / gist:eb7e85f64b6dada46aa92bc19d3fc99c
Created May 24, 2018 09:02
Silly insertion of new line breaks in Google spreadsheet
Suppose that we want to break
{Hello}, {World}
into
{Hello},
{World}
do
= SUBSTITUTE(B2, "}, {", CONCATENATE("'} ", char(10), "{"))