Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻
programming

Zach Caceres zcaceres

👨‍💻
programming
View GitHub Profile
@zcaceres
zcaceres / node-python-fastai.md
Last active Jun 4, 2021
Starter code to use NodeJS with a Python layer for the model.
View node-python-fastai.md

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 Oct 31, 2018
Composer Deep Learning #8
View untar-data.sh
#! /bin/bash
tar -zxvf yourfile.tar.gz
@zcaceres
zcaceres / send-file-to-gcp.sh
Created Oct 31, 2018
Composer Deep Learning #7
View send-file-to-gcp.sh
#! /bin/bash
gcloud compute scp path-to-your-tar.tar.gz your-gcp-instance-here:~
@zcaceres
zcaceres / zip-compositions.sh
Created Oct 31, 2018
Composer Deep Learning #6
View zip-compositions.sh
# 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 Oct 30, 2018
Composer Deep Learning #5
View wav-to-spectrogram.py
#!/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 Oct 30, 2018
Composer Deep Learning #4
View convert_midi-to-wav.sh
#!/usr/bin/env bash
synth -i $1
@zcaceres
zcaceres / midi_to_wav.py
Created Oct 30, 2018
Composer Deep Learning #3
View midi_to_wav.py
#!/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 Nov 1, 2018
Composer Deep Learning #2
View rename_to_filecount.py
#!/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 Oct 30, 2018
Composer Deep Learning Script #1
View folder_lowercase.py
#!/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):
View body-language.md