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 | |
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml') # Load the cascade for the face. | |
eye_cascade = cv2.CascadeClassifier('haarcascade_eye.xml') # Load the cascade for eye | |
smile_cascade = cv2.CascadeClassifier('haarcascade_smile.xml') # Load the cascade for smile | |
def detect(gray, frame): | |
faces = face_cascade.detectMultiScale(gray, 1.3, 5) | |
for x,y,w,h in faces: |
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 torch | |
from torch2trt import torch2trt | |
import torchvision.models as models | |
import tensorrt as trt | |
import torchvision.transforms as transforms | |
import torchvision.datasets as datasets | |
def get_trt_engine(model, inputs, max_batch_size=1, fp16_mode=True, int8_mode=False, int8_calib_dataset=None): | |
model_trt = torch2trt(model, |
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 trtorch | |
import torch | |
import torchvision.models as models | |
rn50 = models.resnet50(pretrained=True).cuda().eval() | |
inp = torch.randn((1, 3, 224, 224), device='cuda') | |
rn50_jit_traced = torch.jit.trace(rn50, inp) | |
rn50_jit_scripted = torch.jit.script(rn50) |
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 torch | |
from torch2trt import torch2trt | |
import torchvision.models as models | |
import tensorrt as trt | |
import torchvision.transforms as transforms | |
import torchvision.datasets as datasets | |
def get_trt_engine(model, inputs, max_batch_size=1, fp16_mode=True, int8_mode=False, int8_calib_dataset=None): | |
model_trt = torch2trt(model, |
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
#include <iostream> | |
void print(int& i){ | |
std::cout << i << "\n"; | |
} | |
int main(){ | |
int i = 10; | |
// Binding function print | |
auto foo = std::bind(&print, i); |
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
#include <thread> | |
#include <stdio.h> | |
int count = 0; | |
void counter(){ | |
for (int i=0; i < 100000; ++i){ | |
count++; | |
} | |
} |
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
#include <thread> | |
#include <stdio.h> | |
#include <mutex> | |
int count = 0; | |
std::mutex writer; | |
void counter(){ | |
for (int i=0; i < 100000; ++i){ | |
writer.lock(); |
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
#include <thread> | |
#include <stdio.h> | |
#include <atomic> | |
std::atomic<unsigned int> count (0); | |
void counter(){ | |
for (int i=0; i < 100000; ++i){ | |
count++; | |
} |
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
// Compiling and running this program: | |
// nvcc -std=c++11 device-prop-test.cu && ./a.out | |
#include <chrono> | |
#include <iostream> | |
using namespace std; | |
#define CUDA_CHECK(call) \ | |
do { \ | |
cudaError_t status = call; \ | |
if(status != cudaSuccess) { \ |
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
#include <limits.h> | |
#include <unistd.h> | |
#include <csignal> | |
#include <cstdlib> | |
#include <fstream> | |
#include <iostream> | |
#include <iostream> | |
#include <sstream> | |
#include <stdexcept> |