Skip to content

Instantly share code, notes, and snippets.

Avatar

Yashas Samaga B L YashasSamaga

View GitHub Profile
View cuda_common.hpp
#ifndef CUDA_COMMON_HPP
#define CUDA_COMMON_HPP
#include <iostream>
#include <cuda_runtime.h>
#include <cublas_v2.h>
#define CHECK_CUDA(cond) check_cuda(cond, __LINE__)
@YashasSamaga
YashasSamaga / main.cpp
Last active Jul 21, 2020
YOLOv4 OpenCV Performance Evaluation
View main.cpp
// https://github.com/AlexeyAB/darknet/wiki/How-to-evaluate-accuracy-and-speed-of-YOLOv4
// g++ -I/usr/local/include/opencv4/ main.cpp -lopencv_core -lopencv_imgproc -lopencv_dnn -lopencv_imgcodecs -O3 -std=c++17 -lstdc++fs
#include <iostream>
#include <queue>
#include <iterator>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <chrono>
View backward.cu
#include <cuda_runtime.h>
#include <random>
#include <iostream>
struct relu_grad
{
__device__ float operator()(float x) { return x > 0; }
};
View fast_relu_grad.cu
#include <cuda_runtime.h>
#include <iostream>
#include <algorithm>
#include <random>
__global__ void relu(float* output, const float* input, unsigned int* sign32, int n)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
@YashasSamaga
YashasSamaga / main.cu
Last active Jun 14, 2020
Performance comparision of different mish implementations
View main.cu
#include "mish.hpp"
#include <cuda_runtime.h>
#include <random>
#include <iostream>
template <class Activation>
__global__ void activate_vec1(float* __restrict__ output, const float* __restrict__ input, int n)
{
@YashasSamaga
YashasSamaga / Makefile
Last active Aug 8, 2020
OpenCV DNN Benchmark Code
View Makefile
g++ -I/usr/local/include/opencv4/ benchmark.cpp -lopencv_core -lopencv_imgproc -lopencv_dnn -lopencv_imgcodecs -O3 -std=c++17
View buildOpenCV.sh
#!/bin/bash
# License: MIT. See license file in root directory
# Copyright(c) JetsonHacks (2017-2019)
OPENCV_VERSION=4.1.1
# Jetson Nano
ARCH_BIN=5.3
INSTALL_DIR=/usr/local
# Download the opencv_extras repository
# If you are installing the opencv testdata, ie
View D0_Requirements.md

Internal Dependencies

The minimum set of dependencies required to use the CUDA backend in OpenCV DNN is:

cudev
opencv_core
opencv_dnn
opencv_imgproc

You might also require the following to read/write/display images and videos:

@YashasSamaga
YashasSamaga / yolov4.py
Last active Aug 9, 2020
YOLOv4 Inference on OpenCV's CUDA DNN backend
View yolov4.py
import cv2
import time
CONFIDENCE_THRESHOLD = 0.2
NMS_THRESHOLD = 0.4
COLORS = [(0, 255, 255), (255, 255, 0), (0, 255, 0), (255, 0, 0)]
class_names = []
with open("classes.txt", "r") as f:
class_names = [cname.strip() for cname in f.readlines()]
@YashasSamaga
YashasSamaga / A0_NOTICE.md
Last active Jun 11, 2020
GSoC 2019 | OpenCV | Adding a CUDA backend to the DNN module
View A0_NOTICE.md

DISCLAIMER

This gist documents the Google Summer of Code project. It is not updated and hence does not indicate current status of the CUDA backend.

For updated details, please see this gist.

You can’t perform that action at this time.