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
# # Recipe for creating a poster based on a video | |
# | |
# 1. download a video (for example, youtube-dl) | |
# 2. extract images from the video, say every second one frame (ffmpeg) | |
# 3. choose the images you want and delete the images you don't want | |
# 4. (this notebook) align the images horizontally and vertically based on the numbering | |
# got this part from https://note.nkmk.me/en/python-pillow-concat-images/ | |
from PIL import Image |
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
""" | |
This is based on keras-yolo3 (https://github.com/experiencor/keras-yolo3) | |
and licensed under MIT | |
""" | |
import os | |
import numpy as np | |
from tensorflow.keras.layers import Conv2D, Input, BatchNormalization, LeakyReLU, ZeroPadding2D, UpSampling2D | |
from tensorflow.keras.layers import concatenate, add | |
from tensorflow.keras.models import Model | |
import struct |
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
""" | |
A minimal implementation of Monte Carlo tree search (MCTS) in Python 3 | |
Luke Harold Miles, July 2019, Public Domain Dedication | |
See also https://en.wikipedia.org/wiki/Monte_Carlo_tree_search | |
https://gist.github.com/qpwo/c538c6f73727e254fdc7fab81024f6e1 | |
""" | |
from abc import ABC, abstractmethod | |
from collections import defaultdict | |
import math |
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
""" | |
Adapter from | |
[stackoverflow](https://stackoverflow.com/questions/39453948/create-a-html-page-with-a-list-of-packages-using-pdoc-module). | |
Please note that this script is currently limited to one level of submodules. Also it's a bit ugly. Help fix it, if you like. | |
This looks atrocious for markdown (my impresssion) | |
""" | |
from os import path, makedirs | |
import argparse |
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
""" | |
Adapter from | |
[stackoverflow](https://stackoverflow.com/questions/39453948/create-a-html-page-with-a-list-of-packages-using-pdoc-module). | |
It's a bit ugly. Help fix it, if you like. | |
""" | |
from os import path, makedirs | |
import pdoc | |
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
#include <wn.h> | |
#include <stdlib.h> | |
#include <iostream> | |
// g++ wordnet_example.cpp /usr/lib/libwordnet.a -o wordnet_example | |
int main(int argc, char **argv) { | |
if (wninit()) { | |
printf("Fatal! Could not open the WordNet corpus!\n"); | |
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
from numba import njit, jit, prange | |
import numpy as np | |
from numba.pycc import CC | |
from scipy.sparse import lil_matrix | |
cc = CC('adjacency_utils') | |
@cc.export('calc_dist', 'f8(f8[:], f8[:])') | |
@jit("f8(f8[:], f8[:])") | |
def calc_dist(u, v): |
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 matplotlib.pyplot as plt | |
from sklearn.pipeline import make_pipeline | |
from sklearn.preprocessing import StandardScaler | |
from sklearn.decomposition import FastICA | |
from sklearn.pipeline import make_pipeline | |
from sklearn.svm import SVC | |
from sklearn.base import TransformerMixin | |
class Reduce(TransformerMixin): | |
def fit(self, X, y=None): |
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 wordcloud import (WordCloud, get_single_color_func) | |
import matplotlib.pyplot as plt | |
from colour import Color | |
class GroupedColorFunc(object): | |
"""Create a color function object which assigns DIFFERENT SHADES of | |
specified colors to certain words based on the color to words mapping. | |
Uses wordcloud.get_single_color_func |
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 numpy as np | |
import pandas as pd | |
import seaborn as sns | |
import scipy | |
def lift_chart(y_true, y_pred, bins=10, ax=None, normalize=False, labels=None): | |
'''Given matched vectors of true versus predicted | |
targets, plot them against each other. | |
NewerOlder