Skip to content

Instantly share code, notes, and snippets.

View bendangnuksung's full-sized avatar
👷‍♂️
At work

Bendang bendangnuksung

👷‍♂️
At work
View GitHub Profile
@bendangnuksung
bendangnuksung / split_shuffle.py
Created September 21, 2017 08:54
Function to Split (Train and Test) and Shuffle a CSV file
import random
#eg: shuffle_split(80, "xyz.csv") 80= 80% train, 20% Test. xyz.csv= source_file
def shuffle_split(train_size, filename):
data=open(filename, "r")
train1=open("train.csv", "w")
test1= open("test.csv", "w")
read_data= data.readlines()
@bendangnuksung
bendangnuksung / 2080ti.md
Last active January 21, 2021 01:16
# Installing 2080ti driver and cuda
@bendangnuksung
bendangnuksung / docker_tf_model_setup.md
Last active January 7, 2022 08:59
nvidia docker, tensorflow model server GPU setup for ubuntu (for cuda 9)

Setup Nvidia docker, TF model server GPU setup

Install Docker

Reference here

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install -y docker-ce

Preprocessing before model serving

  1. Get the input and output tensor name from the model
  2. Create a tensorflow model builder
    # Create SavedModelBuilder class
    # defines where the model will be exported
    export_path_base = MODEL_PATH
    export_path = os.path.join(
        tf.compat.as_bytes(export_path_base),
        tf.compat.as_bytes(str(VERSION_NUMBER)))
#!/bin/bash
tensorflow_model_server --port=8500 --rest_api_port=8501 --model_name=resnet --model_base_path=/models/resnet
import base64
import requests
from datetime import datetime
import argparse
from tensorflow_serving.apis import predict_pb2
from tensorflow_serving.apis import prediction_service_pb2_grpc
import grpc
import tensorflow as tf
tf_v = 2
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
# App name
name: myresnet-deployment
spec:
# Creating two pods
replicas: 2
template:
metadata:
apiVersion: v1
# service type
kind: Service
metadata:
# Service name
labels:
run: myresnet-service
name: myresnet-service
spec:
ports:
from detectron2.utils.logger import setup_logger
from glob import glob
setup_logger()
import copy
from detectron2.evaluation import COCOEvaluator, inference_on_dataset
from detectron2.data import build_detection_test_loader
from detectron2 import model_zoo
from detectron2.config import get_cfg
from detectron2.config import CfgNode as CN