Skip to content

Instantly share code, notes, and snippets.

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

Bendang bendangnuksung

👷‍♂️
At work
View GitHub Profile
import torch
torch.cuda.set_device(0)
# In[2]:
import torch
from detectron2 import model_zoo
from detectron2.engine import DefaultPredictor
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
apiVersion: v1
# service type
kind: Service
metadata:
# Service name
labels:
run: myresnet-service
name: myresnet-service
spec:
ports:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
# App name
name: myresnet-deployment
spec:
# Creating two pods
replicas: 2
template:
metadata:
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
#!/bin/bash
tensorflow_model_server --port=8500 --rest_api_port=8501 --model_name=resnet --model_base_path=/models/resnet

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)))
@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
@bendangnuksung
bendangnuksung / 2080ti.md
Last active January 21, 2021 01:16
# Installing 2080ti driver and cuda