#!/bin/bash

# Folder name is taken from the first script argument
FOLDER_NAME="$1"

# Check if the folder name is provided
if [ -z "$FOLDER_NAME" ]; then
  echo "Usage: $0 <folder_name>"
  exit 1
fi

# Check if the folder exists
if [ ! -d "$FOLDER_NAME" ]; then
    echo "Folder '$FOLDER_NAME' does not exist. Creating now..."
    mkdir -p "$FOLDER_NAME"
    mkdir -p "$FOLDER_NAME/chkpts"
    mkdir -p "$FOLDER_NAME/log"
    mkdir -p "$FOLDER_NAME/samples"
    echo "Folder '$FOLDER_NAME' created successfully."
else
    echo "Folder '$FOLDER_NAME' already exists."
fi


# This script is used to fine-tune SDXL on the LoRA dataset.
accelerate launch --num_cpu_threads_per_process=2 --num_processes=2 "scripts/sd3m_lora_dreambooth_v0.py" \
--instance_data_dir="/mnt/webdataset/v3" \
--pretrained_model_name_or_path="stabilityai/stable-diffusion-3-medium-diffusers" \
--output_dir="$FOLDER_NAME/chkpts" \
--logging_dir="$FOLDER_NAME/log" \
--resolution=1024 \
--train_batch_size=8 \
--instance_prompt="Photo in style of GODSTK" \
--gradient_accumulation_steps=4 \
--report_to="wandb" \
--num_train_epochs=50 \
--learning_rate=3e-5 \
--class_prompt='Background Photo of Road' \
--rank=256 \
--mixed_precision=bf16
