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
# pip install pymupdf | |
import fitz | |
src = fitz.open("QM_SS24_Skript.pdf") | |
doc = fitz.open() | |
LEFT_MARGIN = 100 | |
RIGHT_MARGIN = 100 |
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
# Written by Splines, https://github.com/splines | |
# Change WITH_PUTBACKS to True or False to change if we allow putbacks or not | |
# In order to run this, you need to install Graphviz first, | |
# see the installation guide here: | |
# https://graphviz.readthedocs.io/en/stable/#installation | |
from typing import List | |
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
def change_brightness(color, amount=1): | |
""" | |
Changes the brightness of the given color by multiplying luminosity | |
by the given amount. | |
Input can be a matplotlib color string, hex string, or RGB tuple. | |
The color gets brighter when amount > 1 and darker when amount < 1. | |
The resulting luminosity is restricted to [0,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
# Installation | |
# Run `pip install pyaudio` first | |
# If that throws an error, you need to install a "wheel" first (pre-packaged binary) | |
# Follow the instructions here: https://stackoverflow.com/a/71073645/9655481 | |
# e.g. I use Python 3.9.6 and installed the file "PyAudio‑0.2.11‑cp39‑cp39‑win_amd64.whl" | |
# from here: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio | |
import time | |
import matplotlib.pyplot as plt |
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
# 🌐 MNIST Dataset | |
# https://deepai.org/dataset/mnist | |
import numpy as np | |
from matplotlib import pyplot as plt | |
with open('./mnist/train-images.idx3-ubyte', 'rb') as images_file,\ | |
open('./mnist/train-labels.idx1-ubyte', 'rb') as labels_file: | |
# --- Images Header |
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
# --- Images Header | |
# 4x 32-bit big-endian integer | |
images_header = np.fromfile(images_file, dtype='>i4', count=4) | |
images_magic_number = images_header[0] | |
images_count = images_header[1] | |
row_count = images_header[2] | |
col_count = images_header[3] | |
pixel_count = row_count*col_count |
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 | |
from matplotlib import pyplot as plt | |
with open('./mnist/train-images.idx3-ubyte', 'rb') as images_file,\ | |
open('./mnist/train-labels.idx1-ubyte', 'rb') as labels_file: |