This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Modified from github repo: shakedzy/tic_tac_toe | |
""" | |
import numpy as np | |
import torch | |
import torch.nn as nn | |
import os | |
import time | |
import random | |
from collections import deque |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import cv2 | |
# import PSNR | |
import numpy as np | |
import pysnooper | |
cv2.setUseOptimized(True) | |
# Parameters initialization |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import heatmap | |
import cv2 | |
def use_heatmap(image, box_centers): | |
hm = heatmap.Heatmap() | |
img = hm.heatmap(box_centers, dotsize=200, size=(image.shape[1], image.shape[0]), opacity=128, area=((0, 0), (image.shape[1], image.shape[0]))) | |
return img | |
img = "/path/to/image.jpg" | |
centers = [(10, 20), (30, 40) ] # centers of heatmaps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import onnx | |
import argparse | |
import onnx_tensorrt.backend as backend | |
import numpy as np | |
import time | |
def main(): | |
parser = argparse.ArgumentParser(description="Onnx runtime engine.") | |
parser.add_argument( | |
"--onnx", default="/home/arkenstone/test_face_model/res50/mxnet_exported_mnet.onnx", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorrt as trt | |
import numpy as np | |
import pycuda.autoinit | |
import pycuda.driver as cuda | |
import time | |
model_path = "model.onnx" | |
input_size = 32 | |
TRT_LOGGER = trt.Logger(trt.Logger.WARNING) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import numpy as np | |
import os | |
import tensorrtserver.api as tapi | |
import tensorrtserver.api.model_config_pb2 as model_config | |
import cv2 | |
import queue as q | |
def model_dtype_to_np(model_dtype): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess as sp | |
import cv2 | |
import numpy as np | |
cmd = ["gst-launch-1.0", | |
"rtspsrc", "location=rtsp://admin:[email protected]/Streaming/Channels/1", "latency=100", "!", | |
"queue", "!", | |
"rtph264depay", "!", | |
"h264parse", "!", | |
"nvv4l2decoder", "drop-frame-interval=2", "!", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From ubuntu:18.04 as base | |
# install github and vim | |
RUN apt-get install -y vim wget gnupg | |
ENV DEBIAN_FRONTEND "noninteractive" # to skip any interactive configurations during installation | |
RUN apt-get install -yq keyboard-configuration | |
# install gstreamer | |
RUN apt install -y \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess as sp | |
import cv2 | |
import numpy as np | |
from PIL import Image | |
import tensorflow as tf | |
ffmpeg_cmd_1 = ["./ffmpeg", "-y", | |
"-hwaccel", "nvdec", | |
"-c:v", "h264_cuvid", | |
"-vsync", "0", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
from tensorflow.core.framework import types_pb2, graph_pb2, attr_value_pb2 | |
from tensorflow.tools.graph_transforms import TransformGraph | |
from google.protobuf import text_format | |
import numpy as np | |
# object detection api input and output nodes | |
input_name = "image_tensor" | |
output_names = ["detection_boxes", "detection_classes", "detection_scores", "num_detections"] | |
# Const should be float32 in object detection api during nms (see here: https://www.tensorflow.org/api_docs/cc/class/tensorflow/ops/non-max-suppression-v4.html) |
NewerOlder