Skip to content

Instantly share code, notes, and snippets.

View iKrishneel's full-sized avatar
🏠
Working from home

Krishneel iKrishneel

🏠
Working from home
View GitHub Profile
#!/usr/bin/env python
import os
import math
import cmath
import numpy as np
import cv2 as cv
import matplotlib.pyplot as plt
img = cv.imread('bi.jpg')
@iKrishneel
iKrishneel / poisson_image_editing.py
Created June 8, 2018 06:50
Poisson Image Blending on OpenCV
#!/usr/bin/env python
import os
import sys
import numpy as np
import cv2 as cv
def main(argv):
if len(argv) < 3:
@iKrishneel
iKrishneel / estimate_position.py
Last active February 27, 2018 15:03
Pseudo-script outlining operations required to obtain the x,y position a robot
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# (C) 02-27-2018 by Krishneel
import os
import sys
import math
import random
import time
@iKrishneel
iKrishneel / sensor_msgs_to_pilimage
Created January 10, 2018 10:43
convert_sensor_msg_to_pil
import numpy as np
from PIL import Image as PILImage
channel = int(np.ceil(len(img_msg.data)/(img_msg.height * img_msg.width)))
im = np.ndarray(shape=(img_msg.height, img_msg.width, channel),
dtype=np.uint8, buffer=img_msg.data)
pim = PILImage.fromarray(im)
@iKrishneel
iKrishneel / CMakeLists.txt
Last active February 22, 2018 06:26
singly linked list tutorial
cmake_minimum_required(VERSION 2.8)
project(linked_list)
add_executable(main linked_list.cpp)
target_link_libraries(main)
@iKrishneel
iKrishneel / nn.py
Created December 11, 2017 17:27 — forked from ottokart/nn.py
3-layer neural network example with dropout in 2nd layer
# Tiny example of 3-layer nerual network with dropout in 2nd hidden layer
# Output layer is linear with L2 cost (regression model)
# Hidden layer activation is tanh
import numpy as np
n_epochs = 100
n_samples = 100
n_in = 10
n_hidden = 5

How to create a custom Caffe layer in Python?

This tutorial will guide through the steps to create a simple custom layer for Caffe using python. By the end of it, there are some examples of custom layers.

###- Why would I want to do that? Usually you would create a custom layer to implement a funcionality that isn't available in Caffe, tuning it for your requirements.

###- What will I need? Probably just Python and Caffe instaled.

###- Is there any downside?

name: "CaffeNet"
layer {
name: "data"
type: "Input"
top: "data"
input_param { shape: { dim: 10 dim: 3 dim: 227 dim: 227 } }
}
layer {
name: "conv1"
type: "Convolution"
@iKrishneel
iKrishneel / install-caffe-tx1.sh
Last active May 1, 2017 10:26
Bash script to install CAFFE on NVIDIA TX1
#!/usr/bin/env bash
# Copyright (C) 2016 by Krishneel Chaudhary @ JSK Lab, The University
# of Tokyo, Japan
function install-glog {
/bin/echo -e "\e[1;32m[LOG] Installing GLOG \e[0m"
ipwd=$PWD
cd /tmp/
#!/usr/bin/env bash
sudo apt-get update
sudo apt-get install libopencv-dev build-essential checkinstall cmake pkg-config yasm libtiff4-dev libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils doxygen git
sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get update
sudo apt-get install ffmpeg
sudo apt-get install git