Skip to content

Instantly share code, notes, and snippets.

View diggerdu's full-sized avatar
🍃
May you find your worth in the waking world

Xingjian Du diggerdu

🍃
May you find your worth in the waking world
View GitHub Profile
@diggerdu
diggerdu / pseudo_cqt_pytorch.py
Created August 9, 2019 07:33 — forked from keunwoochoi/pseudo_cqt_pytorch.py
To compute pseudo CQT (Constant-Q-transform using STFT) on Pytorch.
cqt_filter_fft = librosa.constantq.__cqt_filter_fft
class PseudoCqt():
"""A class to compute pseudo-CQT with Pytorch.
Written by Keunwoo Choi
API (+implementations) follows librosa (https://librosa.github.io/librosa/generated/librosa.core.pseudo_cqt.html)
Usage:
src, _ = librosa.load(filename)
src_tensor = torch.tensor(src)
@diggerdu
diggerdu / client.py
Last active August 7, 2018 08:58 — forked from yoavram/client.py
Example of uploading binary files programmatically in python, including both client and server code.Client implemented with the requests library and the server is implemented with the flask library.
import requests
#http://docs.python-requests.org/en/latest/user/quickstart/#post-a-multipart-encoded-file
url = "http://localhost:5000/"
fin = open('simple_table.pdf', 'rb')
files = {'file': fin}
try:
r = requests.post(url, files=files)
print r.text
@diggerdu
diggerdu / pytorch_visualize.py
Created August 31, 2017 06:55 — forked from hyqneuron/pytorch_visualize.py
PyTorch graph visualization
import torch
import torch.nn as nn
from torch.nn import Parameter
from torch.autograd import Variable, Function
from collections import defaultdict
import graphviz
"""
This is a rather distorted implementation of graph visualization in PyTorch.
# Working example for my blog post at:
# https://danijar.github.io/structuring-your-tensorflow-models
import functools
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
def doublewrap(function):
"""
A decorator decorator, allowing to use the decorator to be used without
@diggerdu
diggerdu / arxiv2kindle.ipynb
Created September 11, 2016 10:34 — forked from bshillingford/arxiv2kindle.ipynb
arxiv2kindle: recompiles an arxiv paper for kindle-sized screens, and sends it to your wifi-enabled kindle
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.