Skip to content

Instantly share code, notes, and snippets.

View Mirodil's full-sized avatar

Mirodil Mirodil

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
gilrosenthal / install script
Created July 4, 2018 20:14 Install on Google Colab
!pip install fastai
!apt-get -qq install -y libsm6 libxext6 && pip install -q -U opencv-python
import cv2
from os import path
from wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag
platform = '{}{}-{}'.format(get_abbr_impl(), get_impl_ver(), get_abi_tag())
accelerator = 'cu80' if path.exists('/opt/bin/nvidia-smi') else 'cpu'
!pip install -q{accelerator}/torch-0.3.0.post4-{platform}-linux_x86_64.whl torchvision
Mirodil /
Last active December 14, 2018 17:13
LearningRateFinder for keras
class LearningRateFinder(Callback):
This callback implements a learning rate finder(LRF)
The learning rate is constantly increased during training.
On training end, the training loss is plotted against the learning rate.
One may choose a learning rate for a model based on the given graph,
selecting a value slightly before the minimal training loss.
# Example
lrf = LearningRateFinder([0.0001, 0.0005, 0.001, 0.005, 0.01, 0.05]), y_train, epochs=1, batch_size=128, callbacks=[lrf])
Mirodil /
Last active May 10, 2018 14:39
FileListIterator for keras
import numpy as np
from keras import backend as K
from keras.preprocessing.image import Iterator, load_img, img_to_array
class FileListIterator(Iterator):
"""Iterator capable of reading images from an array of the filenames.
# Arguments
filenames: Path to the directory to read images from.
Each subdirectory in this directory will be
considered to contain images from one class,
jeremyjordan /
Last active December 4, 2023 13:41
Keras Callback for implementing Stochastic Gradient Descent with Restarts
from keras.callbacks import Callback
import keras.backend as K
import numpy as np
class SGDRScheduler(Callback):
'''Cosine annealing learning rate scheduler with periodic restarts.
# Usage
schedule = SGDRScheduler(min_lr=1e-5,
sbugallo /
Created January 23, 2018 08:24
ResNeXt 101 for MRCNN
from keras.layers import Conv2D
from keras.layers import Activation
from keras.layers import Add
from keras.layers import BatchNormalization
from keras.layers import ZeroPadding2D
from keras.layers import MaxPooling2D
def identity_block(input_tensor, kernel_size, filters, stage, block, use_bias=True):
This block is the one with no convolutional layer at its shortcut branch
chourobin /
Last active June 28, 2024 20:49
React Native Bridging Cheatsheet
fchollet /
Last active July 16, 2024 11:16
Updated to the Keras 2.0 API.
'''This script goes along the blog post
"Building powerful image classification models using very little data"
It uses data that can be downloaded at:
In our setup, we:
- created a data/ folder
- created train/ and validation/ subfolders inside data/
- created cats/ and dogs/ subfolders inside train/ and validation/
- put the cat pictures index 0-999 in data/train/cats
trevnorris /
Last active December 24, 2023 05:25
Quick steps of how to create a flame graph using perf

The will setup the latest Node and install the latest perf version on your Linux box.

When you want to generate the flame graph, run the following (folder locations taken from install script):

sudo sysctl kernel.kptr_restrict=0
# May also have to do the following:
# (additional reading )
sudo sysctl kernel.perf_event_paranoid=0