Skip to content

Instantly share code, notes, and snippets.

View visualDust's full-sized avatar
🛌
遇到困难睡大觉

Gavin Gong visualDust

🛌
遇到困难睡大觉
View GitHub Profile
@visualDust
visualDust / convert llama2 weights to huggingface.md
Created April 3, 2024 08:30
convert downloaded llama2 weights to huggingface format so that you can load it with huggingface/transformers from_pretrained

Download and convert llama-7b model to huggingface format

This is a refined version of huggingface/LLaMA2 Usage tips.

Go to somewhere you want to put the original llama2 7b model weights, maybe in the download folder. Create a folder called LLaMA:

cd ~/downloads (or maybe somewhere else)
mkdir LLaMA
cd LLaMA
import time
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.datasets as datasets
import neetbox
from torchvision import transforms
from torch.utils.data import DataLoader
from neetbox import logger
@visualDust
visualDust / one_hot_with_ignore_label.py
Last active November 19, 2023 12:24
One hot encoding that supports ignore label
def one_hot_encode(
mask: torch.Tensor,
num_classes: int,
ignored_label: Union[str, int] = "negative",
):
"""Convert the mask to a one-hot encoded representation by @visualDust
Args:
mask (torch.Tensor): indexed label image. Should types int
num_classes (int): number of classes
@visualDust
visualDust / 📊 Weekly development breakdown
Last active May 10, 2024 01:06
Weekly sleeping breakdown
Other 10 hrs 40 mins █████████▊░░░░░░░░░░░ 47.0%
Fish To... 3 hrs 26 mins ███▏░░░░░░░░░░░░░░░░░ 15.1%
Markdown 2 hrs 20 mins ██▏░░░░░░░░░░░░░░░░░░ 10.3%
Browsing 1 hr 36 mins █▍░░░░░░░░░░░░░░░░░░░ 7.1%
Searching 1 hr 23 mins █▎░░░░░░░░░░░░░░░░░░░ 6.1%
@visualDust
visualDust / TF2中张量的基本数学运算.ipynb
Last active October 29, 2020 22:53
TF2中张量的基本数学运算
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@visualDust
visualDust / TF2高阶操作.ipynb
Last active October 29, 2020 22:52
TF2高阶操作
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@visualDust
visualDust / TF2基本操作.ipynb
Last active October 29, 2020 16:58
TF2基本操作
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.