Skip to content

Instantly share code, notes, and snippets.

@Apfelin
Apfelin / STTBot.py
Last active October 25, 2024 08:57
Discord speech-to-text bot, made with discord.py by Rapptz and voice additions by imayhaveborkedit. Uses wit.ai for speech recognition
import discord
import asyncio
import speech_recognition as sr
from threading import Thread
# bot token and wit.ai api key
TOKEN = ""
WIT_AI_KEY = ""
# we need a sink for the listen function, so we just define our own
@BIGBALLON
BIGBALLON / extract_ILSVRC.sh
Created May 13, 2018 20:09
script for ImageNet data extract.
#!/bin/bash
#
# script to extract ImageNet dataset
# ILSVRC2012_img_train.tar (about 138 GB)
# ILSVRC2012_img_val.tar (about 6.3 GB)
# make sure ILSVRC2012_img_train.tar & ILSVRC2012_img_val.tar in your current directory
#
# https://github.com/facebook/fb.resnet.torch/blob/master/INSTALL.md
#
# train/
@movefast
movefast / WeightedLossSampler.py
Last active December 12, 2018 10:29
A random sampler weighted on prev batch losses using fastai library
from torch.utils.data.sampler import Sampler
from torch.utils.data.sampler import RandomSampler
class WeightedLossSampler(Sampler, Callback):
def __init__(self, data_source, replacement=True, bs=64, init_fac=1, ls_init_fac=1e-2):
self.num_samples = len(data_source)
self.weights = to_gpu(torch.ones(self.num_samples)*init_fac)
self.replacement = replacement
self.i = 0
@bkj
bkj / pytorch_lifted_loss.py
Last active April 28, 2022 07:12
pytorch lifted loss
#!/usr/bin/env python
"""
pytorch_lifted_loss.py
"""
import torch
import torch.nn as nn
from torch.autograd import Variable
@PolarNick239
PolarNick239 / blocking_queue.h
Last active September 11, 2022 12:30
C++ concurrent blocking queue with limited size (based on boost condition_variable)
#include <queue>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition_variable.hpp>
// Based on https://www.justsoftwaresolutions.co.uk/threading/implementing-a-thread-safe-queue-using-condition-variables.html
template<typename Data>
class BlockingQueue {
private:
std::queue<Data> queue;
mutable boost::mutex queue_mutex;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ndronen
ndronen / model.py
Last active April 28, 2018 19:50
Semantic segmentation with ENet in PyTorch
#!/usr/bin/env python
"""
A quick, partial implementation of ENet (https://arxiv.org/abs/1606.02147) using PyTorch.
The original Torch ENet implementation can process a 480x360 image in ~12 ms (on a P2 AWS
instance). TensorFlow takes ~35 ms. The PyTorch implementation takes ~25 ms, an improvement
over TensorFlow, but worse than the original Torch.
"""
from __future__ import absolute_import
@fasiha
fasiha / README.md
Last active October 23, 2024 02:50
Pitch (fundamental frequency) detection using (1) harmonic product spectrum, (2) Blackman-Tukey spectral estimator, and (3) Welch spectral estimator.

Experimenting with pitch detection and spectral estimators

See the question and discussion on StackOverflow: How to get the fundamental frequency using Harmonic Product Spectrum?.

We’re trying to estimate the fundamental frequency of a voiced A4 note (440 Hz). (See the question for link to audio clip.)

Harmonic product spectrum

Result: full data, 0 to 2 KHz

@vsubhashini
vsubhashini / readme.md
Last active January 24, 2023 21:43
Sequence to Sequence - Video to Text (S2VT)
@mooware
mooware / colorstreamhandler.py
Last active August 19, 2024 13:35
Colored log output for Python logging framework. Works on Windows, Linux, and probably Mac as well.
# colored stream handler for python logging framework (use the ColorStreamHandler class).
#
# based on:
# http://stackoverflow.com/questions/384076/how-can-i-color-python-logging-output/1336640#1336640
# how to use:
# i used a dict-based logging configuration, not sure what else would work.
#
# import logging, logging.config, colorstreamhandler
#