Skip to content

Instantly share code, notes, and snippets.

View zcaceres's full-sized avatar
👨‍💻
programming

Zach Caceres zcaceres

👨‍💻
programming
View GitHub Profile
@zcaceres
zcaceres / node-python-fastai.md
Last active May 16, 2023 07:20
Starter code to use NodeJS with a Python layer for the model.

Deploying a Deep Learning Image Classification Model with NodeJS, Python, and Fastai

TL|DR: Use this to easily deploy a FastAI Python model using NodeJS.

You've processed your data and trained your model and now it's time to move it to the cloud.

If you've used a Python-based framework like fastai to build your model, there are several excellent solutions for deployment like Django or Starlette. But many web devs prefer to work in NodeJS, especially if your model is only part of a broader application.

My friend Navjot pointed out that NodeJS and Python could run together if we could send remote procedure calls from NodeJS to Python.

@zcaceres
zcaceres / untar-data.sh
Created October 31, 2018 00:38
Composer Deep Learning #8
#! /bin/bash
tar -zxvf yourfile.tar.gz
@zcaceres
zcaceres / send-file-to-gcp.sh
Created October 31, 2018 00:37
Composer Deep Learning #7
#! /bin/bash
gcloud compute scp path-to-your-tar.tar.gz your-gcp-instance-here:~
@zcaceres
zcaceres / zip-compositions.sh
Created October 31, 2018 00:35
Composer Deep Learning #6
# Recursively zips our 'data' directory into a tarball named 'composition.tar.gz', excluding the wav and mid files we made in previous steps.
tar -czvf compositions.tar.gz --exclude=*.wav --exclude=*.mid --exclude=*DS_Store ./data
@zcaceres
zcaceres / wav-to-spectrogram.py
Created October 30, 2018 01:28
Composer Deep Learning #5
#!/usr/bin/env python3
from pathlib import Path
from sys import argv
from scipy import signal
from scipy.io import wavfile
import numpy as np
import matplotlib.pyplot as plt
def create_spectrograms(folder_path):
@zcaceres
zcaceres / convert_midi-to-wav.sh
Created October 30, 2018 01:25
Composer Deep Learning #4
#!/usr/bin/env bash
synth -i $1
@zcaceres
zcaceres / midi_to_wav.py
Created October 30, 2018 01:24
Composer Deep Learning #3
#!/usr/bin/env python3
from pathlib import Path
from sys import argv
import subprocess
import shlex
# Takes in a directory and converts all midi files to .wav
def convert_all_midi_to_wav(folder_path):
@zcaceres
zcaceres / rename_to_filecount.py
Last active November 1, 2018 23:13
Composer Deep Learning #2
#!/usr/bin/env python3
from pathlib import Path
from sys import argv
# Converts all files in specified directory to format [foldername]_[filenumber]
def rename_files(folder_path, folder_name):
files = [file for file in folder_path.iterdir() if file.is_file() and ("mid" in file.name)]
for (x, file) in enumerate(files):
print('Renaming', file)
@zcaceres
zcaceres / folder_lowercase.py
Created October 30, 2018 01:19
Composer Deep Learning Script #1
#!/usr/bin/env python3
from pathlib import Path
from sys import argv
# Downcases a the names of all directories inside the current directory.
path = Path('.')
dirs = [file for file in path.iterdir() if file.is_dir()]
for (x, dir) in enumerate(dirs):