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
#puzzle1 | |
import numba | |
import numpy as np | |
import warnings | |
from lib import CudaProblem, Coord | |
warnings.filterwarnings( | |
action="ignore", category=numba.NumbaPerformanceWarning, module="numba" | |
) |
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 av | |
container = av.open('assets/example_data/videos/pose1.mp4') | |
frame = av.VideoFrame(640, 480, "rgb24") | |
frame.to_ndarray() |
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 huggingface_hub import snapshot_download | |
# Download the entire repository | |
repo_path = snapshot_download(repo_id="huggingface/model-repo") |
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 yt_dlp import YoutubeDL | |
# URL of the YouTube video | |
video_url = "https://www.youtube.com/watch?v=example" | |
# yt-dlp options | |
ydl_opts = { | |
"format": "mp4", # Download a progressive MP4 stream with both video and audio | |
"outtmpl": "downloads/%(title)s.%(ext)s", # Output template | |
} |
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 clip | |
import torch | |
from PIL import Image | |
#image_pil = Image.open("path_to_image.jpg") | |
image_pil = Image.fromarray(image) | |
device = 'cuda' | |
image_input = preprocess(image_pil).unsqueeze(0).to(device) | |
with torch.no_grad(): | |
image_features = model.encode_image(image_input) |
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 numba.cuda | |
import torch | |
import numpy as np | |
t = torch.from_numpy(np.array([1,2,3])) | |
numba.cuda.as_cuda_array(t.to('cuda')) |
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
#define N 10000000 | |
#include "stdio.h" | |
// To compile: nvcc vector_add.cu -o vector_add -ccbin "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\bin\Hostx64\x64" | |
// void vector_add(float *out, float *a, float *b, int n) { | |
// for(int i = 0; i < n; i++){ | |
// out[i] = a[i] + b[i]; | |
// } | |
// } |
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 matplotlib.pyplot as plt | |
import numpy as np | |
import scipy.signal | |
# Create some data points for the curves | |
x = np.linspace(0, 10, 100) # 100 points between 0 and 10 | |
y1 = np.sin(x) # First curve (sine wave) | |
y2 = np.cos(x) # Second curve (cosine wave) | |
y3 = scipy.signal.correlate(y1, y2, mode = 'same') |
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
!pip install transformers==4.30 | |
!pip install accelerate | |
!pip install trl peft | |
!pip install bitsandbytes | |
!pip install xformers==0.0.22 | |
!pip install autoawq | |
from peft import LoraConfig | |
from peft import get_peft_model, PeftConfig, PeftModel, LoraConfig, prepare_model_for_kbit_training |
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
### Download files from https://huggingface.co/TinyLlama/TinyLlama-1.1B-Chat-v1.0/tree/main | |
import time | |
from transformers import AutoTokenizer | |
import transformers | |
import torch | |
# model = "PY007/TinyLlama-1.1B-step-50K-105b" | |
# model = "yuhanzgithub/tinyllama" | |
model = "./" | |
tokenizer = AutoTokenizer.from_pretrained(model) |
NewerOlder