Skip to content

Instantly share code, notes, and snippets.

@erogol
erogol / tts_example.ipynb
Last active February 12, 2024 23:46
TTS_example.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@erogol
erogol / dataset_mongo.py
Last active April 19, 2023 08:24
PyTorch MongoDB dataset interface
import io
import os
import numpy as np
from PIL import Image
from pymongo import MongoClient
from torch.utils.data import Dataset, DataLoader
from torchvision import transforms
def pil_loader(f):
@erogol
erogol / NLL_OHEM.py
Last active January 29, 2023 21:02
Online hard example mining PyTorch
import torch as th
class NLL_OHEM(th.nn.NLLLoss):
""" Online hard example mining.
Needs input from nn.LogSotmax() """
def __init__(self, ratio):
super(NLL_OHEM, self).__init__(None, True)
self.ratio = ratio
git show-branch \
| sed "s/].*//" \
| grep "\*" \
| grep -v "$(git rev-parse --abbrev-ref HEAD)" \
| head -n1 \
| sed "s/^.*\[//"
@erogol
erogol / linked_list.cpp
Last active April 10, 2022 10:17
linked list implementation to experiment with it in C++
/*
Linked_list implementation for cracking the code
questions
*/
#include <iostream>
#include <stdlib.h> /* srand, rand */
#include <map>
using namespace std;
template <typename dataType>
@erogol
erogol / ddc_sentece_test_330k.ipynb
Last active May 14, 2021 09:40
DDC_sentece_test_330K.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@erogol
erogol / sub_vector_exp.cpp
Created January 26, 2014 10:58
extract a sub-vector from given c++ vector, example code
#include <vector>
#include <iostream>
using namespace std;
int main(){
// This initialization is available at C++11 support compiler
// For lower version C++ support check the reference document
vector<int> arr (9);
arr = {1,2,3,4,5,6,7,8,9};
@erogol
erogol / CaffeBatchPrediction.cpp
Created July 13, 2015 12:54
Caffe c++ batch based prediction
#include "caffeclassifier.h"
CaffeClassifier::CaffeClassifier(const string& model_file,
const string& trained_file,
const string& mean_file,
const string& label_file,
const bool use_GPU,
const int batch_size) {
if (use_GPU)
Caffe::set_mode(Caffe::GPU);
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@erogol
erogol / WTA_kernel_binary
Created August 30, 2013 16:06
Google's Winner Takes All hashing implemmentation
function[binary_codes,G_vecs] = WTA_kernel_binary(X,G_vecs,G, K)
% G is number of permutation vectors
% K is the insterest span
if size(G_vecs,1) == 0
G_vec = zeros(G,size(X,2));
for i = 1:G
G_vecs(i,:) = randperm(size(X,2),size(X,2));
end
end