Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,122 @@
|
|
| 1 |
-
---
|
| 2 |
-
license:
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: creativeml-openrail-m
|
| 3 |
+
datasets:
|
| 4 |
+
- SubMaroon/danbooru-colored
|
| 5 |
+
base_model:
|
| 6 |
+
- John6666/nsfw-anime-xl-v1-sdxl
|
| 7 |
+
tags:
|
| 8 |
+
- controlnet
|
| 9 |
+
- anime
|
| 10 |
+
- stable
|
| 11 |
+
- diffusion
|
| 12 |
+
---
|
| 13 |
+
# ControlNet for Manga Colorization
|
| 14 |
+
|
| 15 |
+
**Model Name:** `SubMaroon/controlnet_mangaRecolor`
|
| 16 |
+
**Base model:** `John6666/nsfw-anime-xl-v1-sdxl`
|
| 17 |
+
**Task:** Conditional image generation — Colorization
|
| 18 |
+
**Conditioning:** Grayscale manga panel (lineart or filled)
|
| 19 |
+
**Trained with:** [Hugging Face diffusers](https://github.com/huggingface/diffusers) ControlNet training pipeline
|
| 20 |
+
|
| 21 |
+
---
|
| 22 |
+
|
| 23 |
+
## Description
|
| 24 |
+
|
| 25 |
+
This is a custom-trained **ControlNet** model designed to perform **automatic colorization of grayscale manga** images.
|
| 26 |
+
|
| 27 |
+
The model takes in a **black-and-white manga scan** (converted to RGB) as conditioning input and generates a **colorized version** using Stable Diffusion.
|
| 28 |
+
|
| 29 |
+
It is trained to act as a ControlNet module and requires a compatible SD base model — such as `nsfw-anime-xl-v1-sdxl` or other anime/manga-focused SD models.
|
| 30 |
+
|
| 31 |
+
---
|
| 32 |
+
|
| 33 |
+
## Training details
|
| 34 |
+
|
| 35 |
+
- **Base model:** `John6666/nsfw-anime-xl-v1-sdxl`
|
| 36 |
+
- **Dataset:** Custom dataset of ~6,000 image pairs from **Danbooru-based manga scans**, manually cleaned and resized to `512x512`
|
| 37 |
+
- **Inputs:**
|
| 38 |
+
- `conditioning_image`: black-and-white manga scan (RGB)
|
| 39 |
+
- `text prompt`: optional (e.g. "colorized version of this panel")
|
| 40 |
+
- **Loss:** MSE with FP16, trained on 1×A100, 20 epochs
|
| 41 |
+
- **Resolution:** 512x512
|
| 42 |
+
- **Scheduler:** default diffusers setup
|
| 43 |
+
- **Optimizer:** AdamW, LR: `1e-5`
|
| 44 |
+
|
| 45 |
+
---
|
| 46 |
+
|
| 47 |
+
## Usage (Diffusers)
|
| 48 |
+
|
| 49 |
+
```python
|
| 50 |
+
from diffusers import StableDiffusionControlNetPipeline, ControlNetModel
|
| 51 |
+
from diffusers.utils import load_image
|
| 52 |
+
import torch
|
| 53 |
+
|
| 54 |
+
# Load ControlNet
|
| 55 |
+
controlnet = ControlNetModel.from_pretrained("SubMaroon/controlnet_mangaRecolor", torch_dtype=torch.float16)
|
| 56 |
+
|
| 57 |
+
# Load base pipeline
|
| 58 |
+
pipe = StableDiffusionControlNetPipeline.from_pretrained(
|
| 59 |
+
"John6666/nsfw-anime-xl-v1-sdxl", controlnet=controlnet, torch_dtype=torch.float16
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
pipe.to("cuda")
|
| 63 |
+
|
| 64 |
+
# Load grayscale manga panel
|
| 65 |
+
conditioning_image = load_image("bw_manga_panel.png").convert("RGB")
|
| 66 |
+
|
| 67 |
+
# Generate
|
| 68 |
+
image = pipe("manga colorization", image=conditioning_image, num_inference_steps=30).images[0]
|
| 69 |
+
image.save("colorized.png")
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
---
|
| 73 |
+
|
| 74 |
+
## Usage in ComfyUI / WebUI
|
| 75 |
+
|
| 76 |
+
- Place `diffusion_pytorch_model.safetensors` into your `ComfyUI/models/controlnet/` folder
|
| 77 |
+
- Make sure to also include the `config.json`
|
| 78 |
+
- Select this ControlNet in your workflow
|
| 79 |
+
- Use grayscale images (512x512) as conditioning inputs
|
| 80 |
+
|
| 81 |
+
---
|
| 82 |
+
|
| 83 |
+
## Alternative training run (SDXL version)
|
| 84 |
+
|
| 85 |
+
This version was trained using the SDXL-compatible ControlNet pipeline with the following CLI command:
|
| 86 |
+
|
| 87 |
+
```bash
|
| 88 |
+
accelerate launch train_controlnet_sdxl.py \
|
| 89 |
+
--pretrained_model_name_or_path John6666/nsfw-anime-xl-v1-sdxl \
|
| 90 |
+
--dataset_name SubMaroon/danbooru-colored \
|
| 91 |
+
--image_column image \
|
| 92 |
+
--conditioning_image_column conditioning_image \
|
| 93 |
+
--caption_column prompt \
|
| 94 |
+
--output_dir ./controlnet-colorization \
|
| 95 |
+
--resolution 512 \
|
| 96 |
+
--train_batch_size 8 \
|
| 97 |
+
--gradient_accumulation_steps 2 \
|
| 98 |
+
--learning_rate 1.4e-4 \
|
| 99 |
+
--num_train_epochs 4 \
|
| 100 |
+
--mixed_precision fp16 \
|
| 101 |
+
--gradient_checkpointing \
|
| 102 |
+
--checkpointing_steps 1000 \
|
| 103 |
+
--validation_steps 1000 \
|
| 104 |
+
--report_to tensorboard \
|
| 105 |
+
--tracker_project_name controlnet-colorization \
|
| 106 |
+
--seed 42
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
---
|
| 110 |
+
|
| 111 |
+
## License
|
| 112 |
+
|
| 113 |
+
The model is released under the **CreativeML Open RAIL-M** license.
|
| 114 |
+
You are free to use it for non-commercial and research purposes. Commercial use may require additional permission.
|
| 115 |
+
|
| 116 |
+
---
|
| 117 |
+
|
| 118 |
+
## Credits
|
| 119 |
+
|
| 120 |
+
Created by [SubMaroon](https://huggingface.co/SubMaroon)
|
| 121 |
+
Based on the Hugging Face [`diffusers`](https://github.com/huggingface/diffusers) ControlNet training example
|
| 122 |
+
Inspired by [lllyasviel's original ControlNet](https://github.com/lllyasviel/ControlNet)
|