Skip to content

Instantly share code, notes, and snippets.

@farisalasmary
farisalasmary / msi-gtx1060-ubuntu-18.04-deeplearning.md
Created March 5, 2023 09:46 — forked from hereismari/msi-gtx1060-ubuntu-18.04-deeplearning.md
Setting up a MSI laptop with GPU (gtx1060), Installing Ubuntu 18.04, CUDA, CDNN, Pytorch and TensorFlow
import pytorch_lightning as pl
import numpy as np
import torch
from torch.nn import MSELoss
from torch.optim import Adam
from torch.utils.data import DataLoader, Dataset
import torch.nn as nn
class SimpleDataset(Dataset):
@farisalasmary
farisalasmary / bytes_to_wav.py
Created January 1, 2023 10:35 — forked from hadware/bytes_to_wav.py
Convert wav in bytes for to numpy ndarray, then back to bytes
from scipy.io.wavfile import read, write
import io
## This may look a bit intricate/useless, considering the fact that scipy's read() and write() function already return a
## numpy ndarray, but the BytesIO "hack" may be useful in case you get the wav not through a file, but trough some websocket or
## HTTP Post request. This should obviously work with any other sound format, as long as you have the proper decoding function
with open("input_wav.wav", "rb") as wavfile:
input_wav = wavfile.read()
@farisalasmary
farisalasmary / tqdm_threadpool.py
Created October 31, 2021 14:07 — forked from timothymugayi/tqdm_threadpool.py
How to run tqdm in multiple threads
import time
from random import randrange
from multiprocessing.pool import ThreadPool
from tqdm import tqdm
def func_call(position, total):
text = 'progressbar #{position}'.format(position=position)
@farisalasmary
farisalasmary / train.py
Created March 28, 2020 07:35
DeepSpeech2.pytorch Train.py
import argparse
import json
import os
import random
import time
import numpy as np
import torch.distributed as dist
import torch.utils.data.distributed
from apex import amp