Skip to content

Instantly share code, notes, and snippets.

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

pmod prerakmody

🏠
Working from home
View GitHub Profile
raw_output = net.layers['conv6']
# Step1 :
raw_prediction = tf.reshape(raw_output, [-1, args.num_classes])
label_proc = prepare_label(label_batch, tf.stack(raw_output.get_shape()[1:3]), num_classes=args.num_classes, one_hot=False) # [batch_size, h, w]
raw_gt = tf.reshape(label_proc, [-1,])
indices = tf.squeeze(tf.where(tf.less_equal(raw_gt, args.num_classes - 1)), 1)
# Ste2 :
gt = tf.cast(tf.gather(raw_gt, indices), tf.int32)
def mrcnn_mask_loss_graph(target_masks, target_class_ids, pred_masks):
"""Mask binary cross-entropy loss for the masks head.
target_masks: [batch, num_rois, height, width].
A float32 tensor of values 0 or 1. Uses zero padding to fill array.
target_class_ids: [batch, num_rois]. Integer class IDs. Zero padded.
pred_masks: [batch, proposals, height, width, num_classes] float32 tensor
with values from 0 to 1.
"""
# Step1.1 : Reshape for simplicity. Merge first two dimensions into one.
target_class_ids = K.reshape(target_class_ids, (-1,))
@prerakmody
prerakmody / velodyne_lidar_pcap_reader.py
Last active November 6, 2022 02:28
Convert .pcap files captured from Velodyne into xyz ascii format
# from scapy3k.all import *
import sys
print (' - Encoding : ', sys.getdefaultencoding())
# print (' - Version : ', sys.version)
import math
import pprint
import datetime
import pandas as pd
from scapy.all import * #https://scapy.readthedocs.io/en/latest/installation.html
@prerakmody
prerakmody / h5py.py
Last active June 2, 2018 06:15
Hacks with the HDF5 format using h5py
import h5py
import numpy as np
filename = 'filename.h5'
data = h5py.File(filename)
nodes = list(data.items())
data_path= '/a/b' #mention the node you are interested in
#Convert to .csv
filename_save = 'filename.csv'
import os
import re
import sys
import copy
import struct
import pprint
import traceback
def pcd_read(filename, verbose=0, verbose_steps=0):
# Refer this to unpack - https://docs.python.org/3/library/struct.html#format-characters
@prerakmody
prerakmody / tqdm.py
Last active September 25, 2020 09:06
TQDM snippets
import time
import tqdm
import colorama # for multiple tqdm bars on Windows
import numpy as np
dataloader = np.random.random((10))
with tqdm.tqdm(total=len(dataloader), leave=True, disable=False, position=0) as pbar:
for val in dataloader:
pbar.update(1)

AWS command line utility for S3

Install

  • sudo pip3 install awscli

Configure

  • cd ~/
  • mkdir ~/.aws
  • vim ~/.aws/config

[default]

@prerakmody
prerakmody / add_https.md
Created June 20, 2018 11:17
Adding https to your server

Generate certificate

  1. Visit certbot
  2. Follow the steps for your particular OS

Installation

  1. Spin up an AWS/Azure/GCP machine (Ubuntu - 16.04)
    • ensure you know how to use the web-interface of these IaaS to open ports for an instance
    • open ports 80, 443, 8000, 8888
  2. Follow this link
  3. Create a dir (.jupyterhub) which shall contain jupyterhub specific files
    • mkdir .jupyterhub
    • cd .jupyterhub
    • jupyterhub --generate-config
    • openssl rand -hex 8 > jupyterhub_cookie_secret
@prerakmody
prerakmody / README.md
Last active June 14, 2023 10:07
Functions to read rosbag files

Installation

  1. Windows (ros-noetic with pytorch)
    conda create -y -n XOSight-Pattern2 "python=3.8" "mamba>=0.22.1" -c conda-forge
    conda activate XOSight-Pattern2
    mamba install ros-noetic-desktop -c robostack -c robostack-experimental -c conda-forge --override-channels
    mamba install vs2019_win-64
    conda deactivate
    conda activate XOSight-Pattern2
    

mamba install rosdep