Skip to main content

Kohya's GUI

Laboratory OS Installation Details

Environment

Git Repohttps://github.com/bmaltais/kohya_ss.git
Working Directory/workspace/kohya_ss
Python3.11
Env Managerconda

Environment Variables

APP_DIRECTORY
/workspace/kohya_ss
KOHYA_PORT
<assigned at runtime>
APP_VERSIONWhich version of the app to use, using a git branch name or commit hash.
e5e8be0

Install & Run

install-and-run.sh
#!/bin/bash
set -e

export PATH="/opt/conda/bin:/root/.local/bin:$PATH"

# Clone the GitHub repository into the directory when needed
mkdir -p "/workspace/kohya_ss"
if [ -d "/workspace/kohya_ss/.git" ]; then
  echo "Git repository already initialized in /workspace/kohya_ss"
elif [ -z "$(ls -A "/workspace/kohya_ss" 2>/dev/null)" ]; then
  git clone --progress "https://github.com/bmaltais/kohya_ss.git" "/workspace/kohya_ss"
else
  echo "Working directory /workspace/kohya_ss already exists and is not a git repository."
  echo "Leaving existing files untouched and skipping clone of https://github.com/bmaltais/kohya_ss.git."
fi
  
# Change to the app directory
cd "/workspace/kohya_ss"

# Setup Conda environment
echo "Creating conda environment kohya_ss with Python 3.11..."
source /opt/conda/etc/profile.d/conda.sh

# Create the conda environment when needed
if ! conda env list | awk '{print $1}' | grep -Fxq "kohya_ss"; then
  conda create -n kohya_ss python=3.11 -y
else
  echo "Conda environment kohya_ss already exists"
fi

# Activate the conda environment
conda activate kohya_ss

# Upgrade pip and update basic packages
pip install --upgrade pip setuptools wheel

# Install PyTorch
pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu128

# Environment setup complete
echo "Environment setup complete!"

bash ./setup.sh

bash gui.sh --listen 0.0.0.0 --server_port "$KOHYA_PORT" --root_path /kohya_ss $OPENLAB_EXTRA_ARGS