Skip to content

Instantly share code, notes, and snippets.

View desh2608's full-sized avatar

Desh Raj desh2608

View GitHub Profile
@desh2608
desh2608 / IEEEbib-abbrev.bst
Created September 4, 2023 15:21
Modified IEEEbib.bst to abbreviate first names
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IEEE.bst %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Bibliography Syle file for articles according to IEEE instructions
% balemi@aut.ee.ethz.ch <22-JUN-93>
% modified from unsrt.bib. Contributions by Richard H. Roy
ENTRY
{ address
author
booktitle
chapter
@desh2608
desh2608 / kaldi_get_ctm.sh
Created June 19, 2023 17:58
How to create a CTM file using forced alignments in Kaldi
#!/usr/bin/env bash
. ./cmd.sh
. ./path.sh
# Train systems,
nj=30 # number of parallel jobs,
stage=0
dsets="dev test"
. utils/parse_options.sh
@desh2608
desh2608 / install_k2.sh
Last active March 10, 2022 18:20 — forked from pzelasko/install_k2.sh
Steps needed to install K2 from scratch
#!/usr/bin/env bash
# Do not run the commented lines
# First git clone k2 and cd to inside it.
# Common steps
conda create -n k2 python=3.8
conda activate k2
@desh2608
desh2608 / parse_args.py
Created May 28, 2018 14:52
Example of parsing command line arguments in Python
import argparse
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('integers', metavar='N', type=int, nargs='+',
help='an integer for the accumulator')
parser.add_argument('--sum', dest='accumulate', action='store_const',
const=sum, default=max,
help='sum the integers (default: find the max)')
args = parser.parse_args()
@desh2608
desh2608 / utils_test.py
Created May 28, 2018 14:51
Example of a unit test script for testing utilities using Python unittest module
import unittest
class ImageUtilsTest(unittest.TestCase):
"""Testing image utilities: visualization and compression
"""
def setUp(self):
"""This method sets up objects for all the test cases.
"""
<code for loading data>
@desh2608
desh2608 / type_validation.py
Created May 28, 2018 14:49
Example of validating an object in Python
def validate_object(x):
"""This function validates an object x that is supposed to represent an object inside an image, and throws an exception on failure. Specifically it is checking that:
x['polygon'] is a list of >= 3 integer (x,y) pairs representing the corners of the polygon in clockwise or anticlockwise order.
"""
if type(x) != dict:
raise ValueError('dict type input required.')
if 'polygon' not in x:
raise ValueError('polygon object required.')
@desh2608
desh2608 / load_holographic.py
Created January 9, 2018 17:43
How to load from the numpy file
import numpy as np
import pandas as pd
with open('./holographic.npz') as d:
indices = d['arr_0']
X_train = d['arr_1']
X_val = d['arr_2']
y_train = d['arr_3']
y_val = d['arr_4']