Skip to content

Instantly share code, notes, and snippets.

View versae's full-sized avatar

Javier de la Rosa versae

View GitHub Profile
@Oceanswave
Oceanswave / main.py
Last active January 28, 2024 17:41
Streaming Transcriber w/ Whisper v3
#! python3.7
import argparse
import io
import os
import torch
from transformers import pipeline
import speech_recognition as sr
from datetime import datetime, timedelta
@lewtun
lewtun / sft_trainer.py
Last active April 27, 2024 21:28
Fine-tuning Mistral 7B with TRL & DeepSpeed ZeRO-3
# This is a modified version of TRL's `SFTTrainer` example (https://github.com/huggingface/trl/blob/main/examples/scripts/sft_trainer.py),
# adapted to run with DeepSpeed ZeRO-3 and Mistral-7B-V1.0. The settings below were run on 1 node of 8 x A100 (80GB) GPUs.
#
# Usage:
# - Install the latest transformers & accelerate versions: `pip install -U transformers accelerate`
# - Install deepspeed: `pip install deepspeed==0.9.5`
# - Install TRL from main: pip install git+https://github.com/huggingface/trl.git
# - Clone the repo: git clone github.com/huggingface/trl.git
# - Copy this Gist into trl/examples/scripts
# - Run from root of trl repo with: accelerate launch --config_file=examples/accelerate_configs/deepspeed_zero3.yaml --gradient_accumulation_steps 8 examples/scripts/sft_trainer.py
@calpt
calpt / README-OpenCLIP-to-Transformers.md
Last active May 14, 2024 12:21
Convert multilingual LAION CLIP checkpoints from OpenCLIP to Hugging Face Transformers

OpenCLIP -> HF Transformers Conversion

Setup

pip install open_clip_torch transformers

Convert

#pip install git+https://github.com/huggingface/transformers.git
import datetime
import sys
from transformers import pipeline
from transformers.pipelines.audio_utils import ffmpeg_microphone_live
pipe = pipeline("automatic-speech-recognition", model="openai/whisper-base", device=0)
sampling_rate = pipe.feature_extractor.sampling_rate
@emillykkejensen
emillykkejensen / MultiLabel_MultiClass_TextClassification_with_BERT_Transformer_and_Keras.py
Created August 21, 2020 10:23
Multi-Label, Multi-Class Text Classification with BERT, Transformer and Keras
#######################################
### -------- Load libraries ------- ###
# Load Huggingface transformers
from transformers import TFBertModel, BertConfig, BertTokenizerFast
# Then what you need from tensorflow.keras
from tensorflow.keras.layers import Input, Dropout, Dense
from tensorflow.keras.models import Model
from tensorflow.keras.optimizers import Adam
#! /usr/bin/env python3
import cv2
import numpy as np
from pathlib import Path
import argparse
###############################################################################
# CONSTANTS
DEBUG = False
@giannisp
giannisp / gist:ebaca117ac9e44231421f04e7796d5ca
Last active March 1, 2024 14:39
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install postgresql@9.6
brew unlink postgresql@9.6
brew link postgresql
from click import command, option, Option, UsageError
class MutuallyExclusiveOption(Option):
mutex_groups = {}
def __init__(self, *args, **kwargs):
opts_list = kwargs.pop('mutex_group', "")
self.mutex_group_key = ','.join(opts_list)
self.mutex_groups[self.mutex_group_key] = 0
help = kwargs.get('help', '')
@thoolihan
thoolihan / install_tensorflow_centos7.sh
Last active January 28, 2019 06:17
Install TensorFlow on CentOS7
sudo yum -y install epel-release
sudo yum -y install gcc gcc-c++ python-pip python-devel atlas atlas-devel gcc-gfortran openssl-devel libffi-devel
# use pip or pip3 as you prefer for python or python3
pip install --upgrade virtualenv
virtualenv --system-site-packages ~/venvs/tensorflow
source ~/venvs/tensorflow/bin/activate
pip install --upgrade numpy scipy wheel cryptography #optional
pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0rc0-cp35-cp35m-linux_x86_64.whl
# or below if you want gpu, support, but cuda and cudnn are required, see docs for more install instructions
pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.10.0rc0-cp35-cp35m-linux_x86_64.whl
@karpathy
karpathy / min-char-rnn.py
Last active May 30, 2024 23:33
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)