This file contains hidden or 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 atexit | |
import pickle | |
class Cache: | |
def __init__(self, path: str): | |
self.path = path | |
try: | |
with open(path, 'rb') as file: |
This file contains hidden or 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 threading import Thread | |
from queue import Queue | |
class threading(Thread): | |
''' | |
```Python | |
@threading | |
def foo(): | |
return 42 |
This file contains hidden or 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
''' | |
################################# README ####################################### | |
This script deploys all functions within a module (i.e. src). | |
Note that the typing of functions is a necessity for deployment. | |
For instance, we have a module defined as src. | |
src | |
├── __init__.py | |
└── foo.py |
This file contains hidden or 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 onnx_graphsurgeon as gs # https://github.com/NVIDIA/TensorRT/tree/main/tools/onnx-graphsurgeon | |
@gs.Graph.register() | |
def rebuild_hard_swish(self, *nodes): | |
_add, _clip, _mul, _div = nodes | |
# delete div node | |
_mul.outputs = _div.outputs[:] | |
_div.outputs.clear() |
This file contains hidden or 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 functools import lru_cache, partial | |
import numpy as np | |
def hds_sample(d=4): | |
out = [1] | |
d -= 2 | |
for i in range(d, -1, -1): | |
theta = inv_cdf(i)(np.random.rand()) |
This file contains hidden or 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
apt-get install docker.io | |
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | apt-key add - | |
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) | |
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | tee /etc/apt/sources.list.d/nvidia-docker.list | |
apt-get update | |
apt-get install -y nvidia-docker2 | |
pkill -SIGHUP dockerd | |
apt-get install nvidia-418 |
This file contains hidden or 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
# This is a pytorch implementation of the [Locating Objects Without Bounding Boxes](https://arxiv.org/pdf/1806.07564.pdf) | |
class WeightedHausdorffDistance(torch.nn.Module): | |
def __init__(self, alpha=-5): | |
"""note: this distance metric takes effect when the input heatmap values are within [0,1]""" | |
super().__init__() | |
self.soft_min_fn = lambda x:x.pow(alpha).mean(0).mean(0).pow(1/alpha) # alpha --> -infi ==> min_func | |
def forward(self, heat_map, points): |
This file contains hidden or 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 cv2 | |
import numpy as np | |
from PIL import Image | |
import os.path as osp, os | |
## from https://github.com/nwojke/deep_sort | |
import tracker | |
import detection | |
import nn_metric | |
## |