Skip to content

Instantly share code, notes, and snippets.

View offbye's full-sized avatar

Xitao Zhang offbye

View GitHub Profile
# Create stub
host, port = FLAGS.server.split(':')
channel = implementations.insecure_channel(host, int(port))
stub = prediction_service_pb2.beta_create_PredictionService_stub(channel)
# Create prediction request object
request = predict_pb2.PredictRequest()
# Specify model name (must be the same as when the TensorFlow serving serving was started)
request.model_spec.name = 'obj_det'
@asimshankar
asimshankar / export.py
Created June 20, 2017 00:17
Keras Models --> TensorFlow SavedModel format
# Mostly copied from https://keras.io/applications/#usage-examples-for-image-classification-models
# Changing it to use InceptionV3 instead of ResNet50
from keras.applications.inception_v3 import InceptionV3, preprocess_input, decode_predictions
from keras.preprocessing import image
import numpy as np
model = InceptionV3()
img_path = 'elephant.jpg'
@soasme
soasme / parser.py
Last active January 23, 2017 08:13
# -*- coding: utf-8 -*-
GRAMMAR = r"""
IGNORE: "[ \t\n]";
UNARY_OP: "[+-!]";
IDENTIFIER: "[a-zA-Z_][a-zA-Z0-9_]*";
STRING_LITERAL: "\\"[^\\\\"]*\\"";
DECIMAL_LITERAL: "0|[1-9][0-9]*";
OCTAL_LITERAL: "0[oO][0-7]+";
HEX_LITERAL: "0[xX][0-9a-fA-F]+";
BIN_LITERAL: "0[bB][0-1]+";
@yrevar
yrevar / imagenet1000_clsidx_to_labels.txt
Last active April 30, 2024 12:39
text: imagenet 1000 class idx to human readable labels (Fox, E., & Guestrin, C. (n.d.). Coursera Machine Learning Specialization.)
{0: 'tench, Tinca tinca',
1: 'goldfish, Carassius auratus',
2: 'great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias',
3: 'tiger shark, Galeocerdo cuvieri',
4: 'hammerhead, hammerhead shark',
5: 'electric ray, crampfish, numbfish, torpedo',
6: 'stingray',
7: 'cock',
8: 'hen',
9: 'ostrich, Struthio camelus',
@alashow
alashow / OkHttp3Stack.java
Last active May 29, 2020 08:59 — forked from bryanstern/OkHttpStack.java
An OkHttp backed HttpStack for Volley (okhttp3 version)
/**
* The MIT License (MIT)
*
* Copyright (c) 2015 Circle Internet Financial
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@manis404
manis404 / gist:5427116
Created April 20, 2013 19:38
Rpi Hardware h264 encode/decode
echo "deb http://vontaene.de/raspbian-updates/ . main" >> /etc/apt/sources.list
apt-get update
apt-get install libgstreamer1.0-0 libgstreamer1.0-0-dbg libgstreamer1.0-dev liborc-0.4-0 liborc-0.4-0-dbg liborc-0.4-dev liborc-0.4-doc gir1.2-gst-plugins-base-1.0 gir1.2-gstreamer-1.0 gstreamer1.0-alsa gstreamer1.0-doc gstreamer1.0-omx gstreamer1.0-plugins-bad gstreamer1.0-plugins-bad-dbg gstreamer1.0-plugins-bad-doc gstreamer1.0-plugins-base gstreamer1.0-plugins-base-apps gstreamer1.0-plugins-base-dbg gstreamer1.0-plugins-base-doc gstreamer1.0-plugins-good gstreamer1.0-plugins-good-dbg gstreamer1.0-plugins-good-doc gstreamer1.0-plugins-ugly gstreamer1.0-plugins-ugly-dbg gstreamer1.0-plugins-ugly-doc gstreamer1.0-pulseaudio gstreamer1.0-tools gstreamer1.0-x libgstreamer-plugins-bad1.0-0 libgstreamer-plugins-bad1.0-dev libgstreamer-plugins-base1.0-0 libgstreamer-plugins-base1.0-dev