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
| # train_grpo.py | |
| import re | |
| import torch | |
| from datasets import load_dataset, Dataset | |
| from transformers import AutoTokenizer, AutoModelForCausalLM | |
| from peft import LoraConfig | |
| from trl import GRPOConfig, GRPOTrainer | |
| # Load and prep dataset |
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 typing import Dict, Union | |
| from huggingface_hub import get_safetensors_metadata | |
| import argparse | |
| import sys | |
| # Example: | |
| # python get_gpu_memory.py Qwen/Qwen2.5-7B-Instruct | |
| # Dictionary mapping dtype strings to their byte sizes | |
| bytes_per_dtype: Dict[str, float] = { |
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
| #Step 1 | |
| import cv2 # working with, mainly resizing, images | |
| import numpy as np # dealing with arrays | |
| import os # dealing with directories | |
| from random import shuffle # mixing up or currently ordered data that might lead our network astray in training. | |
| from tqdm import tqdm # a nice pretty percentage bar for tasks. Thanks to viewer Daniel BA1/4hler for this suggestion | |
| import tensorflow as tf #Import Tensorflow | |
| import glob #This will extract all files from the folder | |
| import keras | |
| from keras.preprocessing.image import ImageDataGenerator |