### Manual Installation and Launch of Flux Gym Source: https://context7.com/cocktailpeanut/fluxgym/llms.txt Steps to clone the repository, set up a virtual environment, install dependencies (including sd-scripts and PyTorch), and launch the Flux Gym application. Ensure to activate the correct virtual environment and install sd-scripts dependencies before Flux Gym's. ```bash # Clone fluxgym and the Kohya sd-scripts backend git clone https://github.com/cocktailpeanut/fluxgym cd fluxgym git clone -b sd3 https://github.com/kohya-ss/sd-scripts # Create and activate a virtual environment python -m venv env source env/bin/activate # Linux # env\Scripts\activate # Windows # Install sd-scripts dependencies first cd sd-scripts && pip install -r requirements.txt && cd .. # Install Flux Gym dependencies pip install -r requirements.txt # Install PyTorch Nightly for CUDA 12.1 (standard GPUs) pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 # For NVIDIA RTX 50-series (5090, etc.) use cu128 + latest bitsandbytes # pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu128 # pip install -U bitsandbytes # Launch the app python app.py # Open http://localhost:7860 in your browser ``` -------------------------------- ### Install Flux Gym Dependencies Source: https://github.com/cocktailpeanut/fluxgym/blob/main/README.md Return to the root Flux Gym directory and install its dependencies into the activated virtual environment. ```bash cd .. pip install -r requirements.txt ``` -------------------------------- ### Install Kohya Scripts Dependencies Source: https://github.com/cocktailpeanut/fluxgym/blob/main/README.md Navigate to the sd-scripts directory and install its dependencies into the activated virtual environment. ```bash cd sd-scripts pip install -r requirements.txt ``` -------------------------------- ### Start Flux Gym Application Source: https://github.com/cocktailpeanut/fluxgym/blob/main/README.md Run the Flux Gym application from the root directory with the virtual environment activated. This launches the web UI. ```bash python app.py ``` -------------------------------- ### Docker Installation and Launch of Flux Gym Source: https://context7.com/cocktailpeanut/fluxgym/llms.txt Instructions for setting up Flux Gym using Docker Compose. This method simplifies dependency management and deployment. Optionally, user and group IDs can be overridden. ```bash git clone https://github.com/cocktailpeanut/fluxgym cd fluxgym git clone -b sd3 https://github.com/kohya-ss/sd-scripts # Optional: override user/group IDs (default 1000) # export PUID=$(id -u) PGID=$(id -g) docker compose up -d --build # Open http://localhost:7860 ``` -------------------------------- ### Build and Run Flux Gym with Docker Compose Source: https://github.com/cocktailpeanut/fluxgym/blob/main/README.md Build the Docker image and start the Flux Gym application in detached mode using Docker Compose. Access the UI via http://localhost:7860. ```bash docker compose up -d --build ``` -------------------------------- ### Install PyTorch Nightly (cu121) Source: https://github.com/cocktailpeanut/fluxgym/blob/main/README.md Install the nightly build of PyTorch with CUDA 12.1 support. This is a common requirement for GPU acceleration. ```bash pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 ``` -------------------------------- ### Configuring Base Models in models.yaml Source: https://context7.com/cocktailpeanut/fluxgym/llms.txt Example YAML configuration for defining base models available in Flux Gym. Each entry specifies the Hugging Face repository, base model, license, and file name. Custom models can be added by following this structure. ```yaml # models.yaml — add custom base models here # Built-in: Flux1-dev (non-commercial license) flux-dev: repo: cocktailpeanut/xulf-dev base: black-forest-labs/FLUX.1-dev license: other license_name: flux-1-dev-non-commercial-license license_link: https://huggingface.co/black-forest-labs/FLUX.1-dev/blob/main/LICENSE.md file: flux1-dev.sft # Built-in: Flux1-schnell (Apache 2.0) flux-schnell: repo: black-forest-labs/FLUX.1-schnell base: black-forest-labs/FLUX.1-schnell license: apache-2.0 file: flux1-schnell.safetensors # Built-in: Flux1-dev2pro (improved training stability) bdsqlsz/flux1-dev2pro-single: repo: bdsqlsz/flux1-dev2pro-single base: black-forest-labs/FLUX.1-dev license: other license_name: flux-1-dev-non-commercial-license license_link: https://huggingface.co/black-forest-labs/FLUX.1-dev/blob/main/LICENSE.md file: flux1-dev2pro.safetensors # Example: adding a custom community model my-custom-flux: repo: myuser/my-flux-variant base: black-forest-labs/FLUX.1-dev license: apache-2.0 file: my-flux-variant.safetensors ``` -------------------------------- ### Clone Flux Gym and Kohya Scripts Repositories Source: https://github.com/cocktailpeanut/fluxgym/blob/main/README.md Clone the Flux Gym repository and the specific sd3 branch of Kohya Scripts. This is the initial step for manual installation. ```bash git clone https://github.com/cocktailpeanut/fluxgym cd fluxgym git clone -b sd3 https://github.com/kohya-ss/sd-scripts ``` -------------------------------- ### Install PyTorch Nightly (cu128) and Update Bitsandbytes Source: https://github.com/cocktailpeanut/fluxgym/blob/main/README.md Install the nightly build of PyTorch with CUDA 12.8 support and update bitsandbytes for compatibility with NVIDIA RTX 50-series GPUs. ```bash pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu128 pip install -U bitsandbytes ``` -------------------------------- ### Automatic Model Download Function Source: https://context7.com/cocktailpeanut/fluxgym/llms.txt Python code demonstrating the internal `download(base_model)` function used by Flux Gym. This function automatically downloads necessary model components from Hugging Face to the local `models/` directory, skipping existing files. It's triggered before training starts. ```python # Internal usage within app.py — triggered automatically on training start # Model files are placed in: # models/unet/ → flux1-dev.sft (or variant) # models/vae/ → ae.sft # models/clip/ → clip_l.safetensors, t5xxl_fp16.safetensors download("flux-dev") # Console output: # download flux-dev # downloading ae.sft... # download clip_l.safetensors # download t5xxl_fp16.safetensors # Resulting directory layout: # models/ # unet/flux1-dev.sft # vae/ae.sft # clip/clip_l.safetensors # clip/t5xxl_fp16.safetensors ``` -------------------------------- ### start_training Source: https://context7.com/cocktailpeanut/fluxgym/llms.txt Orchestrates the full training pipeline, including directory creation, model download, script writing, training execution, and auto-generation of a Hugging Face model card. ```APIDOC ## `start_training(base_model, lora_name, train_script, train_config, sample_prompts)` — Training Execution Orchestrates the full training pipeline: creates output directories, triggers model download, writes the shell script and dataset TOML to disk, executes training via `bash` (or the `.bat` equivalent on Windows) with streamed log output, then auto-generates a Hugging Face model card README upon completion. ```python # Called by the Gradio UI when the user clicks "Start training" # This is a generator — yields log lines to the terminal LogsView component for log_line in start_training( base_model="flux-dev", lora_name="My Persian Miniature Style", train_script=sh_script, # output of gen_sh() train_config=toml_config, # output of gen_toml() sample_prompts="prsmn painting of a cat --d 42\nprsmn painting of a landscape --d 42", ): print(log_line) # Side effects on disk after completion: # outputs/my-persian-miniature-style/ # train.sh ← generated training script # dataset.toml ← Kohya dataset config # sample_prompts.txt ← sample image prompts # my-persian-miniature-style-000004.safetensors ← checkpoint at epoch 4 # my-persian-miniature-style-000008.safetensors ← checkpoint at epoch 8 # my-persian-miniature-style.safetensors ← final LoRA weights # sample/ ← generated sample images (if configured) # README.md ← auto-generated HuggingFace model card ``` ``` -------------------------------- ### Prepare Training Dataset Source: https://context7.com/cocktailpeanut/fluxgym/llms.txt Copies uploaded images into the training dataset folder, resizes them to the configured resolution (maintaining aspect ratio via LANCZOS resampling), and writes paired .txt caption files. Skips writing caption files that already exist. ```python # Called just before start_training() — assembles the on-disk dataset destination_folder = "datasets/my-lora" size = 512 # target resolution (images are resized to this on their shorter side) # inputs[0] = list of image file paths # inputs[1..N] = corresponding caption strings images = ["/tmp/img0.png", "/tmp/img1.png"] captions = ["p3rs0n riding a bike", "p3rs0n as a bodybuilder"] result = create_dataset(destination_folder, size, images, *captions) # result = "datasets/my-lora" # Creates: # datasets/my-lora/img0.png (resized to 512px on short side) # datasets/my-lora/img0.txt → "p3rs0n riding a bike" # datasets/my-lora/img1.png # datasets/my-lora/img1.txt → "p3rs0n as a bodybuilder" ``` -------------------------------- ### create_dataset Source: https://context7.com/cocktailpeanut/fluxgym/llms.txt Prepares the training dataset by copying and resizing images, and creating corresponding `.txt` caption files. It preserves existing caption files, ensuring manual annotations are not overwritten. ```APIDOC ## `create_dataset(destination_folder, size, *inputs)` — Dataset Preparation Copies uploaded images into the training dataset folder, resizes them to the configured resolution (maintaining aspect ratio via LANCZOS resampling), and writes paired `.txt` caption files. Skips writing caption files that already exist (preserving manually uploaded `.txt` captions). ```python # Called just before start_training() — assembles the on-disk dataset destination_folder = "datasets/my-lora" size = 512 # target resolution (images are resized to this on their shorter side) # inputs[0] = list of image file paths # inputs[1..N] = corresponding caption strings images = ["/tmp/img0.png", "/tmp/img1.png"] captions = ["p3rs0n riding a bike", "p3rs0n as a bodybuilder"] result = create_dataset(destination_folder, size, images, *captions) # result = "datasets/my-lora" # Creates: # datasets/my-lora/img0.png (resized to 512px on short side) # datasets/my-lora/img0.txt → "p3rs0n riding a bike" # datasets/my-lora/img1.png # datasets/my-lora/img1.txt → "p3rs0n as a bodybuilder" ``` ``` -------------------------------- ### Sample Image Generation Flags Source: https://github.com/cocktailpeanut/fluxgym/blob/main/README.md Utilize various flags to control sample image generation during training. These include negative prompts (--n), dimensions (--w, --h), seed (--d), CFG scale (--l), and steps (--s). Prompt weighting syntax is also supported. ```text --n: Negative prompt up to the next option. --w: Specifies the width of the generated image. --h: Specifies the height of the generated image. --d: Specifies the seed of the generated image. --l: Specifies the CFG scale of the generated image. --s: Specifies the number of steps in the generation. ``` -------------------------------- ### gen_sh Source: https://context7.com/cocktailpeanut/fluxgym/llms.txt Assembles the complete `accelerate launch` shell command for Kohya's training script. It automatically adapts the optimizer and memory strategy based on the specified VRAM tier and appends advanced Kohya flags. ```APIDOC ## `gen_sh(...)` — Training Shell Script Generation Assembles the complete `accelerate launch` shell command for Kohya's `flux_train_network.py`, adapting the optimizer and memory strategy to the selected VRAM tier. For 12GB uses split-mode + single-block training; for 16GB uses Adafactor without split; for 20GB+ uses AdamW8bit. Advanced Kohya flags changed from their defaults are appended automatically. ```python sh_script = gen_sh( base_model="flux-dev", output_name="my-lora", resolution=512, seed=42, workers=2, learning_rate="8e-4", network_dim=4, # LoRA rank max_train_epochs=16, save_every_n_epochs=4, timestep_sampling="shift", guidance_scale=1.0, vram="16G", # "12G", "16G", or "20G" sample_prompts="p3rs0n riding a bike --d 42", sample_every_n_steps=100, # *advanced_components omitted (uses defaults) ) # Produces a script like: # accelerate launch \ # --mixed_precision bf16 \ # --num_cpu_threads_per_process 1 \ # sd-scripts/flux_train_network.py \ # --pretrained_model_name_or_path "/abs/path/models/unet/flux1-dev.sft" \ # --clip_l "/abs/path/models/clip/clip_l.safetensors" \ # --t5xxl "/abs/path/models/clip/t5xxl_fp16.safetensors" \ # --ae "/abs/path/models/vae/ae.sft" \ # --optimizer_type adafactor \ # --optimizer_args "relative_step=False" "scale_parameter=False" "warmup_init=False" \ # --lr_scheduler constant_with_warmup \ # --max_grad_norm 0.0 \ # --sample_prompts="/abs/path/outputs/my-lora/sample_prompts.txt" \ # --sample_every_n_steps="100" \ # --network_module networks.lora_flux \ # --network_dim 4 \ # --learning_rate 8e-4 \ # --max_train_epochs 16 \ # --save_every_n_epochs 4 \ # --timestep_sampling shift \ # --guidance_scale 1.0 \ # --loss_type l2 ``` ``` -------------------------------- ### Generate Training Shell Script Source: https://context7.com/cocktailpeanut/fluxgym/llms.txt Assembles the complete `accelerate launch` shell command for Kohya's `flux_train_network.py`. Adapts the optimizer and memory strategy to the selected VRAM tier (12GB, 16GB, or 20GB+). Advanced Kohya flags are appended automatically. ```python sh_script = gen_sh( base_model="flux-dev", output_name="my-lora", resolution=512, seed=42, workers=2, learning_rate="8e-4", network_dim=4, # LoRA rank max_train_epochs=16, save_every_n_epochs=4, timestep_sampling="shift", guidance_scale=1.0, vram="16G", # "12G", "16G", or "20G" sample_prompts="p3rs0n riding a bike --d 42", sample_every_n_steps=100, # *advanced_components omitted (uses defaults) ) # Produces a script like: # accelerate launch \ # --mixed_precision bf16 \ # --num_cpu_threads_per_process 1 \ # sd-scripts/flux_train_network.py \ # --pretrained_model_name_or_path "/abs/path/models/unet/flux1-dev.sft" \ # --clip_l "/abs/path/models/clip/clip_l.safetensors" \ # --t5xxl "/abs/path/models/clip/t5xxl_fp16.safetensors" \ # --ae "/abs/path/models/vae/ae.sft" \ # --optimizer_type adafactor \ # --optimizer_args "relative_step=False" "scale_parameter=False" "warmup_init=False" \ # --lr_scheduler constant_with_warmup \ # --max_grad_norm 0.0 \ # --sample_prompts="/abs/path/outputs/my-lora/sample_prompts.txt" \ # --sample_every_n_steps="100" \ # --network_module networks.lora_flux \ # --network_dim 4 \ # --learning_rate 8e-4 \ # --max_train_epochs 16 \ # --save_every_n_epochs 4 \ # --timestep_sampling shift \ # --guidance_scale 1.0 \ # --loss_type l2 ``` -------------------------------- ### Activate Python Virtual Environment (Linux) Source: https://github.com/cocktailpeanut/fluxgym/blob/main/README.md Create and activate a Python virtual environment on Linux. This isolates project dependencies. ```bash python -m venv env source env/bin/activate ``` -------------------------------- ### Activate Python Virtual Environment (Windows) Source: https://github.com/cocktailpeanut/fluxgym/blob/main/README.md Create and activate a Python virtual environment on Windows. This isolates project dependencies. ```bash python -m venv env env\Scripts\activate ``` -------------------------------- ### Uploading Pre-Made Caption Files Source: https://context7.com/cocktailpeanut/fluxgym/llms.txt Include `.txt` caption files with matching base names alongside image files for automatic detection. This skips AI captioning for those specific images. Ensure the caption file's base name exactly matches its corresponding image file. ```text # File naming convention — caption file must share the exact base name as its image: img0.png → img0.txt img1.jpg → img1.txt photo_42.webp → photo_42.txt # Example caption file contents (img0.txt): p3rs0n standing in front of the Eiffel Tower, wearing a blue coat, sunny day # Upload both image and txt files together via the Gradio file picker. # The caption text will pre-populate in the caption field for that image. # If no .txt file is found for an image, the trigger word is used as the default. ``` -------------------------------- ### Advanced Sample Image Prompts with Seed Source: https://github.com/cocktailpeanut/fluxgym/blob/main/README.md Use advanced flags like --d to specify the seed for consistent sample image generation, allowing visualization of LoRA evolution. This is useful for debugging and understanding training progress. ```text hrld person is riding a bike --d 42 hrld person is a body builder --d 42 hrld person is a rock star --d 42 ``` -------------------------------- ### Sample Image Prompt Flags for Kohya's sd-scripts Source: https://context7.com/cocktailpeanut/fluxgym/llms.txt Use inline flags within prompts to control sample image generation during training. Flags like `--d` fix the seed for consistent evolution tracking. Refer to Kohya's sd-scripts documentation for a full flag reference. ```text # Basic sample prompts (one per line in the "Sample Image Prompts" field) p3rs0n is riding a bike p3rs0n is a body builder p3rs0n is a rock star # With advanced flags — use --d to fix the seed so you can watch the LoRA evolve p3rs0n is riding a bike --d 42 p3rs0n is a body builder --d 42 p3rs0n is a rock star --d 42 # Full flag reference: # --n Negative prompt (e.g.: --n blurry, low quality) # --w Image width in pixels (e.g.: --w 768) # --h Image height in pixels (e.g.: --h 1024) # --d Seed (e.g.: --d 42) # --l CFG scale (e.g.: --l 3.5) # --s Number of steps (e.g.: --s 28) # Combined example p3rs0n portrait in oil painting style --d 42 --w 768 --h 1024 --s 28 --n ugly, blurry ``` -------------------------------- ### Execute LoRA Training Pipeline Source: https://context7.com/cocktailpeanut/fluxgym/llms.txt Orchestrates the full training pipeline, including directory creation, model download, script generation, and execution. Yields log lines for real-time feedback. Ensure necessary scripts and configurations are generated prior to calling. ```python # Called by the Gradio UI when the user clicks "Start training" # This is a generator — yields log lines to the terminal LogsView component for log_line in start_training( base_model="flux-dev", lora_name="My Persian Miniature Style", train_script=sh_script, # output of gen_sh() train_config=toml_config, # output of gen_toml() sample_prompts="prsmn painting of a cat --d 42\nprsmn painting of a landscape --d 42", ): print(log_line) # Side effects on disk after completion: # outputs/my-persian-miniature-style/ # train.sh ← generated training script # dataset.toml ← Kohya dataset config # sample_prompts.txt ← sample image prompts # my-persian-miniature-style-000004.safetensors ← checkpoint at epoch 4 # my-persian-miniature-style-000008.safetensors ← checkpoint at epoch 8 # my-persian-miniature-style.safetensors ← final LoRA weights # sample/ ← generated sample images (if configured) # README.md ← auto-generated HuggingFace model card ``` -------------------------------- ### run_captioning Source: https://context7.com/cocktailpeanut/fluxgym/llms.txt Generates detailed captions for training images using the multimodalart/Florence-2-large-no-flash-attn model. The concept sentence is prepended to each caption, and the model is loaded on-demand to manage VRAM. ```APIDOC ## `run_captioning(images, concept_sentence, *captions)` — AI Auto-Captioning Uses the `multimodalart/Florence-2-large-no-flash-attn` vision-language model to generate detailed captions for uploaded training images. The concept sentence (trigger word) is automatically prepended to each generated caption. The model is loaded on-demand to GPU and unloaded after completion to free VRAM for training. ```python # Triggered when the user clicks "Add AI captions with Florence-2" in the UI # images: list of file paths to uploaded images # concept_sentence: trigger word, e.g. "p3rs0n" # captions: current caption values (can be empty strings) images = ["/tmp/img0.png", "/tmp/img1.png"] concept_sentence = "p3rs0n" captions = ["", ""] # Generator — yields updated caption list after each image is processed for updated_captions in run_captioning(images, concept_sentence, *captions): print(updated_captions) # Output after img0.png: # ["p3rs0n a person wearing a red jacket standing in a park", ""] # Output after img1.png: # ["p3rs0n a person wearing a red jacket standing in a park", # "p3rs0n a close-up portrait of a person with curly hair"] ``` ``` -------------------------------- ### Hugging Face Login and LoRA Upload Source: https://context7.com/cocktailpeanut/fluxgym/llms.txt Authenticates with Hugging Face using a token, saving it locally for subsequent uploads. Uploads the trained LoRA folder, including weights and README, to a specified Hugging Face repository. Ensure the LoRA output path is correct and repository details are provided. ```python # Step 1: authenticate (triggered by "Login" button) # Token is saved to ./HF_TOKEN — never sent anywhere except Hugging Face login_hf("hf_yourTokenHere...") # On success: saves token, returns updated UI visibility states # Step 2: publish trained LoRA (triggered by "Upload to HuggingFace" button) upload_hf( base_model="flux-dev", lora_rows="/abs/path/outputs/my-persian-miniature-style", repo_owner="myusername", repo_name="my-persian-miniature-style-lora", repo_visibility="public", # or "private" hf_token="hf_yourTokenHere..." ) # Uploads all files in the LoRA output folder to: # https://huggingface.co/myusername/my-persian-miniature-style-lora # Displays: [Upload Complete] https://huggingface.co/myusername/my-persian-miniature-style-lora ``` -------------------------------- ### Generate Dataset Configuration (TOML) Source: https://context7.com/cocktailpeanut/fluxgym/llms.txt Generates the TOML dataset configuration string consumed by Kohya's training script. Configures shuffling, caption extension, batch size, resolution, and the image subset with its trigger token and repeat count. ```python toml_config = gen_toml( dataset_folder="datasets/my-lora", resolution=512, class_tokens="p3rs0n", num_repeats=10 ) print(toml_config) # [general] # shuffle_caption = false # caption_extension = '.txt' # keep_tokens = 1 # # [[datasets]] # resolution = 512 # batch_size = 1 # keep_tokens = 1 # # [[datasets.subsets]] # image_dir = '/absolute/path/to/datasets/my-lora' # class_tokens = 'p3rs0n' # num_repeats = 10 ``` -------------------------------- ### Generate AI Captions with Florence-2 Source: https://context7.com/cocktailpeanut/fluxgym/llms.txt Uses the multimodalart/Florence-2-large-no-flash-attn model to generate detailed captions for training images. The concept sentence is prepended to each caption. The model is loaded on-demand to GPU and unloaded after completion. ```python # Triggered when the user clicks "Add AI captions with Florence-2" in the UI # images: list of file paths to uploaded images # concept_sentence: trigger word, e.g. "p3rs0n" # captions: current caption values (can be empty strings) images = ["/tmp/img0.png", "/tmp/img1.png"] concept_sentence = "p3rs0n" captions = ["", ""] # Generator — yields updated caption list after each image is processed for updated_captions in run_captioning(images, concept_sentence, *captions): print(updated_captions) # Output after img0.png: # ["p3rs0n a person wearing a red jacket standing in a park", ""] # Output after img1.png: # ["p3rs0n a person wearing a red jacket standing in a park", # "p3rs0n a close-up portrait of a person with curly hair"] ``` -------------------------------- ### gen_toml Source: https://context7.com/cocktailpeanut/fluxgym/llms.txt Generates the TOML configuration string required by Kohya's training script. It sets parameters such as resolution, caption extension, and defines the image subset with its trigger token and repeat count. ```APIDOC ## `gen_toml(dataset_folder, resolution, class_tokens, num_repeats)` — Dataset Config Generation Generates the TOML dataset configuration string consumed by Kohya's training script. Configures shuffling, caption extension, batch size, resolution, and the image subset with its trigger token and repeat count. ```python toml_config = gen_toml( dataset_folder="datasets/my-lora", resolution=512, class_tokens="p3rs0n", num_repeats=10 ) print(toml_config) # [general] # shuffle_caption = false # caption_extension = '.txt' # keep_tokens = 1 # # [[datasets]] # resolution = 512 # batch_size = 1 # keep_tokens = 1 # # [[datasets.subsets]] # image_dir = '/absolute/path/to/datasets/my-lora' # class_tokens = 'p3rs0n' # num_repeats = 10 ``` ``` -------------------------------- ### login_hf and upload_hf Source: https://context7.com/cocktailpeanut/fluxgym/llms.txt Handles Hugging Face authentication and publishing of trained LoRA models. `login_hf` validates and saves the token, while `upload_hf` pushes the model to a specified Hugging Face repository. ```APIDOC ## `login_hf(hf_token)` / `upload_hf(...)` — Hugging Face Publishing `login_hf` validates a Hugging Face token via the `HfApi`, saves it to a local `HF_TOKEN` file, and updates the UI to show the authenticated account. `upload_hf` uses `huggingface_util.upload` from Kohya to push the selected trained LoRA folder (including safetensors weights and auto-generated README) to a new or existing Hugging Face repository. ```python # Step 1: authenticate (triggered by "Login" button) # Token is saved to ./HF_TOKEN — never sent anywhere except Hugging Face login_hf("hf_yourTokenHere...") # On success: saves token, returns updated UI visibility states # Step 2: publish trained LoRA (triggered by "Upload to HuggingFace" button) upload_hf( base_model="flux-dev", lora_rows="/abs/path/outputs/my-persian-miniature-style", repo_owner="myusername", repo_name="my-persian-miniature-style-lora", repo_visibility="public", # or "private" hf_token="hf_yourTokenHere..." ) # Uploads all files in the LoRA output folder to: # https://huggingface.co/myusername/my-persian-miniature-style-lora # Displays: [Upload Complete] https://huggingface.co/myusername/my-persian-miniature-style-lora ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.