This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Checks for the validity of numbers following the Luhn algorithm | |
Samuel Prevost 2021-04-01 | |
""" | |
import os | |
import sys | |
import numpy as np |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Callable, Union | |
from enum import Enum | |
from argparse import ArgumentTypeError as ArgumentError | |
import os | |
class ValType(Enum): | |
ANY = 0 | |
FILE = 1 | |
DIR = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pshape is now a fully fledged Python library ! | |
# Check it out at https://github.com/sam1902/pshape | |
# and install it anywhere with | |
# | |
# pip3 install pshape | |
import inspect, re | |
def pshape(arr): | |
frame = inspect.currentframe() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Samuel Prevost 2021-02-25 | |
# Released under GNU General Public License v3.0 | |
import os | |
import functools | |
from datetime import datetime | |
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2" | |
import tensorflow as tf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Distributed under GNU GPLv3 | |
"""Compute the receptive field of a CNN from any starting depth""" | |
import numpy as np | |
import torch | |
from torch import nn | |
from numba import njit | |
from numba.types import uint64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
import io | |
from ipywidgets import widgets | |
import IPython.display as display | |
def view(*arrs): | |
ims = [] | |
for arr in arrs: | |
output = io.BytesIO() | |
im = Image.fromarray(arr).resize((500,500), Image.NEAREST) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if [ "$#" -lt 1 ] || [ ! -f "$1" ]; then | |
echo "Usage: $0 1.jpg 2.jpg ..." | |
exit 1 | |
fi | |
sizes=$(identify -format "%h %w\n" "$@" | awk -F ' ' '(NR==1){minh=$1;minw=$2;maxh=$1;maxw=$2}; (NR>0){if(minh>$1) minh=$1; if(maxh<$1) maxh=$1;if(minw>$2) minw=$2; if(maxw<$2) maxw=$2;}; {height += $1} {width += $2} END {print height/NR; print width/NR; print maxh; print minh; print maxw; print minw;}') | |
h=$(echo "$sizes" | sed -n 1p) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wgetGdrive() { | |
if [ $# -lt 2 ]; then | |
echo "Usage $0 FILE_ID filename" | |
echo "FILE_ID looks like 1UkzAZMBG1U8kTqO3yhO2nTtoRNtEvyRq" | |
exit 1 | |
fi | |
# This is the proper way to create temp files | |
trap 'rm -f "$TMPFILE"' EXIT | |
COOKIES=$(mktemp) || exit 1 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
"""Tests PyTorch CUDA capabilities""" | |
import sys | |
import torch | |
def main(): | |
"""Main function""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import gym | |
import numpy as np | |
from itertools import count | |
import torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
import torch.optim as optim | |
from torch.distributions import Categorical |