Skip to content

Instantly share code, notes, and snippets.

@PhanDuc
PhanDuc / simple_test.py
Created September 14, 2021 11:57
simple test batch triton
import ast
import argparse
import cv2 as cv
# import json
import numpy as np
import os
# import tensorflow as tf
import time
import uuid
@PhanDuc
PhanDuc / consumer.txt
Last active September 8, 2021 08:47
Consumer format from kafka
ConsumerRecord(topic='ai-integrator-video', partition=0, offset=127, timestamp=1631076816929, timestamp_type=0, key=b'17812', value=b'{"request_id": 17812, "request_type": "video_url", "log_id": 15093, "category_id": 1, "object_id": 1, "field_name": "VideoUrl", "field_value": "https://fbang-web-assets.s3.ap-southeast-1.amazonaws.com/common/ELDEN+RING+-+Official+Gameplay+Reveal.mp4"}', checksum=None, serialized_key_size=5, serialized_value_size=251, headers=())
ConsumerRecord(topic='ai-integrator-video', partition=0, offset=128, timestamp=1631076816955, timestamp_type=0, key=b'17821', value=b'{"request_id": 17821, "request_type": "video_url", "log_id": 15096, "category_id": 1, "object_id": 1, "field_name": "VideoUrl", "field_value": "https://fbang-web-assets.s3.ap-southeast-1.amazonaws.com/common/ELDEN+RING+-+Official+Gameplay+Reveal.mp4"}', checksum=None, serialized_key_size=5, serialized_value_size=251, headers=())
ConsumerRecord(topic='ai-integrator-video', partition=0, offset=129, timestamp=1631076817013
@PhanDuc
PhanDuc / triton.log
Created September 1, 2021 12:12
triton ensemble log
}
step {
model_name: "yolov5_onnx_horror_postprocess"
model_version: 1
input_map {
key: "FLAG_INFERENCE"
value: "FLAG_OUTPUT"
}
input_map {
key: "HORROR_INFERENCE_0"
@PhanDuc
PhanDuc / output.sh
Created August 9, 2021 10:42
horror_triton_console_output
I0809 10:27:23.454255 1 logging.cc:52] Tactic: 861694390046228376 time 0.401024
I0809 10:27:23.457287 1 logging.cc:52] Conv_105 + Relu_106 (scudnn) Set Tactic Name: volta_scudnn_128x64_sliced1x2_ldg4_relu_exp_small_nhwc_tn_v1
I0809 10:27:23.468172 1 logging.cc:52] Tactic: 5258189349241541167 time 0.214656
I0809 10:27:23.468615 1 logging.cc:52] Conv_105 + Relu_106 (scudnn) Set Tactic Name: volta_scudnn_128x128_relu_exp_small_nhwc_tn_v1
I0809 10:27:23.479728 1 logging.cc:52] Tactic: 5821621277990374316 time 0.399456
I0809 10:27:23.480157 1 logging.cc:52] Conv_105 + Relu_106 (scudnn) Set Tactic Name: volta_scudnn_128x32_sliced1x4_ldg4_relu_exp_small_nhwc_tn_v1
I0809 10:27:23.490417 1 logging.cc:52] Tactic: 5863767799113001648 time 0.117984
I0809 10:27:23.490856 1 logging.cc:52] Conv_105 + Relu_106 (scudnn) Set Tactic Name: volta_scudnn_128x128_ldg4_relu_exp_medium_nhwc_tn_v1
I0809 10:27:23.501746 1 logging.cc:52] Tactic: -9147980667639709536 time 0.399328
I0809 10:27:23.502250 1 logging.cc:52] Conv_105 + Relu_10
@PhanDuc
PhanDuc / asyncio_get.py
Created March 25, 2021 17:15
Asyncio get request using aiohttp
import aiohttp
import asyncio
import time
import requests
from PIL import Image
import io
start_time = time.time()
urls = [
"https://kscloset.vn/wp-content/uploads/2021/03/K154TES-FK1AADOOK116TES-FK5A0CAM1--270x370.jpg",
from fastapi import FastAPI, File, UploadFile, HTTPException
from PIL import Image
from pydantic import BaseModel
from tensorflow.keras.models import load_model
from typing import List
import io
import numpy as np
import sys
import uvicorn
"""
Script to eveluation model
Usage:
python evaluate.py --dataset /path/to/folder/images --checkpoint /point/to/model
Example:
python evaluate.py --dataset /dataset/val --checkpoint /box20190222T1237/mask_rcnn_box_0019.h5
"""
import json
Nowadays, using the stare-of-art algorithm, it is possible to create a system that helps people in-
crease the performance of work, avoid spending too much time on mundane tasks so they can
concentrate on work that requires human skills. Deep learning methods can complete tasks that
previously took human a lot of time to do.
Fresh food in supermarkets such as fruit, vegetables are sold quickly that why employ-
ees should re-fill the empty boxes with fresh fruit, vegetables as soon as possible. In the current
workflows, employees need to check manually and it is very time-consuming.
The goal of the thesis is to demonstrate that computer vision and deep learning can solve the
#Save numpy data to tfrecord
import numpy as np
import tensorflow as tf
#Generate Test data
# a float array and int array each with shape (2,2,2)
f_array = np.array([[[1., 2.],
@PhanDuc
PhanDuc / readExcel.py
Created August 1, 2018 11:40 — forked from armaandhir/readExcel.py
Reading data from excel using openpyxl
#
# I hate the documentation of openpyxl and it took me a while to undertand their stuff. So I decided to write down this code.
# Has some wrapper functions that reads all rows from the excel sheet and also a function to read a particular row.
# Add some code to the functions if you wish to do something on fly like adding values to list and sorting them later.
#
# Date: 28/09/2015
from openpyxl import load_workbook
# Reads all rows