Skip to content

Instantly share code, notes, and snippets.

@smpanaro
smpanaro / README.md
Last active August 11, 2024 23:34
Apple Neural Engine Throughput Bench

Toy model to exercise the ANE.

$ pip install coremltools torch numpy calflops
$ python throughput.py

Converting PyTorch Frontend ==> MIL Ops:  99%|███████████████████████████████████████████████████████████████████████████████████████████████████████▊ | 92/93 [00:00<00:00, 7276.15 ops/s]
Running MIL frontend_pytorch pipeline: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████| 5/5 [00:00<00:00, 1071.89 passes/s]
Running MIL default pipeline: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 79/79 [00:15<00:00,  5.03 passes/s]
Running MIL backend_mlprogram pipeline: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████| 12/12 [00:00<00:00, 1207.37 passes/s]
@smpanaro
smpanaro / README.md
Created June 24, 2024 03:27
CoreML Model Introspection Script

This script lets you expose a CoreML model's intermediate tensors as outputs.

Why?

If your CoreML model is spitting out garbage and the inputs look correct it can be painful to find where things are failing in the middle of your model.

How?

Download the script, grab your .mlpackage and fire up https://netron.app to find an interesting tensor.

netron-example
@smpanaro
smpanaro / README.md
Created August 24, 2019 16:51
Spotify ChromeCast BitBar Plugin

Switch Spotify's audio output to a ChromeCast from your menu bar.

  1. Clone my fork of pychromecast.
    1. cd to the pychromecast directory and create a virtualenv: python3 -m venv env
    2. Checkout the spotify-transfer-example branch: git checkout spotify-transfer-example
    3. Install dependencies: pip install -r requirements.txt
    4. Save transfer_spotify_to_chromecast.sh to your pychromecast directory
    5. Update the paths and your spotify credentials in transfer_spotify_to_chromecast.sh
  2. Install BitBar
    1. Move SpotifyChromeCast.1d.sh to your BitBar plugins folder
@smpanaro
smpanaro / README.md
Last active August 8, 2019 04:04
A script to save/favorite the album for every track that is saved/favorited in Spotify.

Spotify's recent changes caused some albums (those where you saved/favorited songs but not the album) to be removed from your Library's album list.

Those songs are still in your Library's song list however. This script looks at all of your saved songs, finds the corresponding album, and saves it to your Library's album list if it is not already there.

Setup

  • You'll need to create a new client ID on Spotify's developer site, including setting up a redirect URI.
  • Fill in the credentials in populate_env.sh and run source populate_env.sh.
  • Install spotipy. pip install spotipy
  • Update username on line 7 of resave_albums.py to your spotify username.

Keybase proof

I hereby claim:

  • I am smpanaro on github.
  • I am smpanaro (https://keybase.io/smpanaro) on keybase.
  • I have a public key ASCrhd9sEFIQwzagME6DSCDmW6BJ-EnOMnulwlxu7mLJZgo

To claim this, I am signing this object:

@smpanaro
smpanaro / MoMA My Path Bookmarklet
Last active August 29, 2015 14:05
A bookmarklet to download photos taken with the MoMA's audio guide.
# Install
This script is meant to be used as a bookmarklet. For best results use Chrome or Firefox (the only browsers to [support](http://caniuse.com/#feat=download) the HTML5 download attribute).
1. Go [here](http://mrcoles.com/bookmarklet/) (or to any other bookmarklet generator) and paste the JavaScript below.
2. Check the Include jQuery box.
3. Click Convert to bookmarklet.
4. Drag into your bookmarks bar.
# Usage
Navigate to the http://www.moma.org/path/... URL emailed to you after your visit and click the bookmarklet.
A series of images should appear at the top of your page. Click them to download them.