Skip to content

Instantly share code, notes, and snippets.

View nateraw's full-sized avatar
💯

Nathan Raw nateraw

💯
View GitHub Profile
@nateraw
nateraw / profiling.py
Created October 9, 2019 00:21
Get total runtime and between times for checkpoints in arbitrary chunks of code
from timeit import default_timer as timer
class SimpleProfiler:
"""Class to test times over multiple named checkpoints.
Usage:
# Starts timer
p = SimpleProfiler()
@nateraw
nateraw / prepare_cats_and_dogs.py
Created June 2, 2021 19:15
Boilerplate for preparing cats and dogs dataset. Removes corrupted images.
import pickle
from pathlib import Path
import tensorflow as tf
root = Path('./PetImages')
num_skipped = 0
examples = []
for folder_name in ("Cat", "Dog"):
for fpath in (root / folder_name).glob('*'):
@nateraw
nateraw / export.py
Created June 2, 2021 21:20
Read in cats and dogs, convert images to bytes, save as pickle to upload to HuggingFace's Datasets Hub.
import pickle
from pathlib import Path
import tensorflow as tf
root = Path('./PetImages')
num_skipped = 0
examples = []
for folder_name in ("Cat", "Dog"):
for fpath in (root / folder_name).glob('*'):
@nateraw
nateraw / Code.gs
Created July 20, 2021 18:42
Add Translation to Google Sheets using HuggingFace's API
function TRANSLATE(text, repo_id="Helsinki-NLP/opus-mt-en-es") {
endpoint = "https://api-inference.huggingface.co/pipeline/translation/" + repo_id;
const payload = JSON.stringify({
"inputs": text
});
// Add your token from https://huggingface.co/settings/token
const options = {
"headers": {"Authorization": "Bearer <YOUR HUGGINGFACE API KEY>"},
"wait_for_model": true,
@nateraw
nateraw / imagefolder-official-example.ipynb
Last active August 24, 2021 02:53
imagefolder-official-example.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nateraw
nateraw / pytorch-push-to-hub.ipynb
Created September 3, 2021 20:40
pytorch-push-to-hub.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nateraw
nateraw / upload_all_timm_models.ipynb
Last active November 3, 2021 03:20
upload_all_timm_models.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nateraw
nateraw / timm-push-and-save-example.ipynb
Last active December 3, 2021 07:28
timm-push-and-save-example.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nateraw
nateraw / gradio-blocks-demo.ipynb
Last active February 22, 2022 19:16
gradio-blocks-demo.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nateraw
nateraw / keras-model-card-demo.ipynb
Last active March 3, 2022 21:57
keras-model-card-demo.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.