Skip to content

Instantly share code, notes, and snippets.

@tianqig
tianqig / extractGifs.py
Created September 2, 2017 14:07 — forked from revolunet/extractGifs.py
extract frames from animated gif using python+PIL
import os
from PIL import Image
def extractFrames(inGif, outFolder):
frame = Image.open(inGif)
nframes = 0
while frame:
frame.save( '%s/%s-%s.gif' % (outFolder, os.path.basename(inGif), nframes ) , 'GIF')
nframes += 1
@tianqig
tianqig / gifextract.py
Created September 2, 2017 14:03 — forked from BigglesZX/gifextract.py
Extract frames from an animated GIF, correctly handling palettes and frame update modes
import os
from PIL import Image
'''
I searched high and low for solutions to the "extract animated GIF frames in Python"
problem, and after much trial and error came up with the following solution based
on several partial examples around the web (mostly Stack Overflow).
There are two pitfalls that aren't often mentioned when dealing with animated GIFs -
@tianqig
tianqig / disable-warnings.py
Created August 24, 2017 13:08
turn off all warnings by creating this startup file: ~/.ipython/profile_default/startup/disable-warnings.py , from https://stackoverflow.com/users/180783/astrofrog
import warnings
warnings.filterwarnings('ignore')
@tianqig
tianqig / GitHub curl.sh
Created August 23, 2017 12:28 — forked from Integralist/GitHub curl.sh
Download a single file from a private GitHub repo. You'll need an access token as described in this GitHub Help article: https://help.github.com/articles/creating-an-access-token-for-command-line-use
curl --header 'Authorization: token INSERTACCESSTOKENHERE' \
--header 'Accept: application/vnd.github.v3.raw' \
--remote-name \
--location https://api.github.com/repos/owner/repo/contents/path
# Example...
TOKEN="INSERTACCESSTOKENHERE"
OWNER="BBC-News"
REPO="responsive-news"
'''This script goes along the blog post
"Building powerful image classification models using very little data"
from blog.keras.io.
It uses data that can be downloaded at:
https://www.kaggle.com/c/dogs-vs-cats/data
In our setup, we:
- created a data/ folder
- created train/ and validation/ subfolders inside data/
- created cats/ and dogs/ subfolders inside train/ and validation/
- put the cat pictures index 0-999 in data/train/cats
import sys
import os
import cv2
import numpy as np
import tensorflow as tf
sys.path.append("..")
from object_detection.utils import label_map_util
@tianqig
tianqig / gcloud_commands
Created August 5, 2017 14:45 — forked from frntn/gcloud_commands
all gcloud commands
gcloud auth
gcloud auth activate-refresh-token
gcloud auth activate-service-account
gcloud auth git-helper
gcloud auth list
gcloud auth login
gcloud auth print-access-token
gcloud auth print-refresh-token
gcloud auth revoke
gcloud components
@tianqig
tianqig / google-cl.sh
Created August 5, 2017 08:26 — forked from loopj/google-cl.sh
Install google command line tools on mac
#!/bin/bash
sudo pip install -Iv http://gdata-python-client.googlecode.com/files/gdata-2.0.14.tar.gz googlecl
@tianqig
tianqig / happy_git_on_osx.md
Created July 30, 2017 08:11 — forked from trey/happy_git_on_osx.md
Creating a Happy Git Environment on OS X

Creating a Happy Git Environment on OS X

Step 1: Install Git

brew install git bash-completion

Configure things:

git config --global user.name "Your Name"

git config --global user.email "you@example.com"