Skip to content

Instantly share code, notes, and snippets.

View gauravkaila's full-sized avatar

Gaurav Kaila gauravkaila

View GitHub Profile
def _write_saved_model(saved_model_path,
trained_checkpoint_prefix,
inputs,
outputs):
"""Writes SavedModel to disk.
Args:
saved_model_path: Path to write SavedModel.
trained_checkpoint_prefix: path to trained_checkpoint_prefix.
inputs: The input image tensor to use for detection.
outputs: A tensor dictionary containing the outputs of a DetectionModel.
_write_saved_model(saved_model_path, trained_checkpoint_prefix,
placeholder_tensor, outputs)
import tensorflow as tf
# Assuming object detection API is available for use
from object_detection.utils.config_util import create_pipeline_proto_from_configs
from object_detection.utils.config_util import get_configs_from_pipeline_file
import object_detection.exporter
# Configuration for model to be exported
config_pathname = ${Model_configuration}
@gauravkaila
gauravkaila / exporter.py
Created December 5, 2017 18:46
Code to comment out in the exporter.py script
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# def _write_frozen_graph(frozen_graph_path, frozen_graph_def):
# """Writes frozen graph to disk.
#
# Args:
# frozen_graph_path: Path to write inference graph.
# frozen_graph_def: tf.GraphDef holding frozen graph.
# """
# with gfile.GFile(frozen_graph_path, 'wb') as f:
# f.write(frozen_graph_def.SerializeToString())
# logging.info('%d ops in the final graph.', len(frozen_graph_def.node))
def make_tensor_proto(values, dtype=None, shape=None, verify_shape=False):
"""Create a TensorProto.
Args:
values: Values to put in the TensorProto.
dtype: Optional tensor_pb2 DataType value.
shape: List of integers representing the dimensions of tensor.
verify_shape: Boolean that enables verification of a shape of values.
Returns:
A TensorProto. Depending on the type, it may contain data in the
"tensor_content" attribute, which is not directly useful to Python programs.
@gauravkaila
gauravkaila / install_docker_ubuntu_16.04.sh
Last active May 20, 2023 05:47
Install Docker and nvidia-docker on Ubuntu-16.04
#!/bin/bash
# add the GPG key for the official Docker repository to the system
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# add the Docker repository to APT sources
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
# update the package database with the Docker packages from the newly added repo
sudo apt-get update
# 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'
# 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'
parameter data_type Azure name
subscription_id string Azure subscription id
resource_group string Azure resource group
workspace_name string Azure machine learning workspace