Skip to content

Instantly share code, notes, and snippets.

View prabindh's full-sized avatar
💭
I may be slow to respond.

Prabindh Sundareson prabindh

💭
I may be slow to respond.
View GitHub Profile
# https://stackoverflow.com/questions/56069411
# The TF code
score_inputs = tf.placeholder(np.float32, shape=(None, 100))
targets = tf.placeholder(np.float32, shape=(None), name="targets")
l2 = tf.contrib.layers.l2_regularizer(0.01)
first_layer = tf.layers.dense(score_inputs, 100, activation=tf.nn.relu, kernel_regularizer=l2)
outputs = tf.layers.dense(first_layer, 1, activation = None, kernel_regularizer=l2)
@prabindh
prabindh / dirlist_creator.py
Created May 4, 2019 02:56
Create directory listing tree in python and output in JSON
import os
import json
def path_to_dict(path):
d = {'name': os.path.basename(path)}
if os.path.isdir(path):
d['type'] = "directory"
d['children'] = [path_to_dict(os.path.join(path,x)) for x in os.listdir\
(path)]
else:
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 13 16:59:53 2016
From - https://stats.stackexchange.com/questions/218407/encoding-angle-data-for-neural-network
@author: Ari
"""
from numpy import savetxt, loadtxt, round, zeros, sin, cos, arctan2, clip, pi, tanh, exp, arange, dot, outer, array, shape, zeros_like, reshape, mean, median, max, min
from numpy.random import rand, shuffle
import matplotlib.pyplot as plt
// Call like below
// boxedMat will contain resized image
// boxedMat = __LetterBoxResize(floatMat, net->w, net->h);
//
// Taken mostly from https://jdhao.github.io/2017/11/06/resize-image-to-square-with-padding/
cv::Mat ArapahoV2::__LetterBoxResize(cv::Mat img, int w, int h)
{
cv::Mat intermediateImg, outputImg;
int delta_w, delta_h, top, left, bottom, right;
@prabindh
prabindh / CMakeLists.txt
Created October 7, 2018 14:30
CMake wrapper script for darknet-cpp
###
### CMake wrapper script for building darknet-cpp as ExternalProject
###
### Platforms supported: Only Linux, perhaps Mac. Windows not supported.
### Refer to the darknet/Makefile for the GPU/OPENCV flag options
### Options have to be set in the darknet/Makefile before invoking this script.
### All requirements (CUDA, CUDNN) need to be installed before invoking this script.
###
### Read https://github.com/prabindh/darknet for further details on build
###
@prabindh
prabindh / arapaho-Detect-func.cpp
Created August 27, 2018 12:15
Resize changes
bool ArapahoV2::Detect(
const cv::Mat & inputMat,
float thresh,
float hier_thresh,
int & objectCount)
{
int count = 0;
objectCount = 0;
threshold = thresh;
// ** NOTE: You would need to perform a "cudaSetDevice(gpuId)" with this same gpuId before any CUDA operations are performed on this gpuId
bool ArapahoV2::Setup(
ArapahoV2Params & p,
int & expectedWidth,
int & expectedHeight
int gpuId
)
{
/// All old stuff
@prabindh
prabindh / convolutional_layer.c
Created August 22, 2017 01:53
Fix for CUDA 8 build error
#if CUDNN_MAJOR >= 6
cudnnSetConvolution2dDescriptor(l->convDesc, l->pad, l->pad, l->stride, l->stride, 1, 1, CUDNN_CROSS_CORRELATION, CUDNN_DATA_FLOAT);
#else
cudnnSetConvolution2dDescriptor(l->convDesc, l->pad, l->pad, l->stride, l->stride, 1, 1, CUDNN_CROSS_CORRELATION);
#endif
@prabindh
prabindh / gist:524ddd79ae6c9815a97c8d43239bb9f5
Last active December 13, 2016 15:05
JsDialogHandler crash on Prompt dialog and callback continue
public class JsDialogHandler : IJsDialogHandler
{
string result = "default";
public bool OnJSDialog(IWebBrowser browserControl, IBrowser browser, string originUrl,
CefJsDialogType dialogType, string messageText, string defaultPromptText,
IJsDialogCallback callback, ref bool suppressMessage)
{
suppressMessage = true;
if (dialogType == CefJsDialogType.Prompt)
{
@prabindh
prabindh / configure-output
Last active August 29, 2015 13:57
This is the output of ./configure --help at this time, for the Graphics SDK package. Request comments.
`configure' configures TI Graphics SDK 4.09.00.01 to adapt to many kinds of systems.
Usage: ./configure [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Defaults for the options are specified in brackets.
Configuration: