sudo apt update && sudo apt upgrade
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections import defaultdict | |
| import random | |
| from huggingface_hub import hf_hub_download | |
| from datasets import Dataset | |
| import numpy as np | |
| import pandas as pd | |
| from transformers import AutoTokenizer | |
| from rich.console import Console | |
| from rich.table import Table | |
| from trl import DPOTrainer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from transformers import AutoModelForCausalLM, AutoTokenizer, StaticCache | |
| import torch | |
| from typing import Optional | |
| device = "cuda" | |
| # Copied from the gpt-fast repo | |
| def multinomial_sample_one_no_sync(probs_sort): # Does multinomial sampling without a cuda synchronization | |
| q = torch.empty_like(probs_sort).exponential_(1) | |
| return torch.argmax(probs_sort / q, dim=-1, keepdim=True).to(dtype=torch.int) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| ### steps #### | |
| # verify the system has a cuda-capable gpu | |
| # download and install the nvidia cuda toolkit and cudnn | |
| # setup environmental variables | |
| # verify the installation | |
| ### | |
| ### to verify your gpu is cuda enable check |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Credit 🙏: I just used the example from langchain docs and it works quite well: https://python.langchain.com/en/latest/use_cases/question_answering.html | |
| # Note 2: The Arxiv -> PDF logic is a bit messy, I'm sure it can be done better | |
| # Note 3: Please install the following: | |
| # To run: | |
| # Save this in a `app.py` | |
| # pip install arxiv PyPDF2 langchain chromadb | |
| # The chat feature was shipped in H2O nightly this week, we will need to install from nightly link: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Spectrogram is a 2D numpy array | |
| print(type(mel_sgram), mel_sgram.shape) | |
| # <class 'numpy.ndarray'> (128, 134) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # use the decibel scale to get the final Mel Spectrogram | |
| mel_sgram = librosa.amplitude_to_db(mel_scale_sgram, ref=np.min) | |
| librosa.display.specshow(mel_sgram, sr=sample_rate, x_axis='time', y_axis='mel') | |
| plt.colorbar(format='%+2.0f dB') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import moviepy.editor as mp | |
| import math | |
| from PIL import Image | |
| import numpy | |
| def zoom_in_effect(clip, zoom_ratio=0.04): | |
| def effect(get_frame, t): | |
| img = Image.fromarray(get_frame(t)) | |
| base_size = img.size |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| if [ -z "$2" ];then | |
| echo 'USAGE: | |
| denoise input.mov output.mov | |
| OR | |
| denoise input.mov output.mov [ambient-noise-start-time] [ambient-noise-duration] [sox-noisered-amount] [sox-norm-param] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -------------------------------------------------- | |
| function (build_external_project target file_name) | |
| set(CMAKELIST_CONTENT " | |
| cmake_minimum_required(VERSION ${CMAKE_MINIMUM_REQUIRED_VERSION}) | |
| project(build_external_project) | |
| file(MD5 \"${file_name}\" FILE_HASH) |