shweaung
commited on
Commit
β’
2d7fde6
1
Parent(s):
bd8db30
Upload folder using huggingface_hub
Browse files- config.yaml +66 -0
- images 51.jpeg +3 -0
- images 52.jpeg +3 -0
- images 54.jpeg +3 -0
- images 55.jpeg +3 -0
- images 56.jpeg +3 -0
- images 58.jpeg +3 -0
- images 59.jpeg +3 -0
- images 60.jpeg +3 -0
- images 61.jpeg +3 -0
- images 62.jpeg +3 -0
- images 63.jpeg +3 -0
- images 64.jpeg +3 -0
- images 65.jpeg +3 -0
- images 66.jpeg +3 -0
- images 67.jpeg +3 -0
- metadata.jsonl +16 -0
- requirements.txt +21 -0
- script.py +96 -0
- ααααα Kahtein Festival large.png_1713719538.png +3 -0
config.yaml
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
config:
|
2 |
+
name: myanmar-kathein-festival-cartoon
|
3 |
+
process:
|
4 |
+
- datasets:
|
5 |
+
- cache_latents_to_disk: true
|
6 |
+
caption_dropout_rate: 0.05
|
7 |
+
caption_ext: txt
|
8 |
+
folder_path: datasets/2671791f-966a-4502-a163-5e9cf151cc87
|
9 |
+
resolution:
|
10 |
+
- 512
|
11 |
+
- 768
|
12 |
+
- 1024
|
13 |
+
shuffle_tokens: false
|
14 |
+
device: cuda:0
|
15 |
+
model:
|
16 |
+
assistant_lora_path: ostris/FLUX.1-schnell-training-adapter
|
17 |
+
is_flux: true
|
18 |
+
low_vram: true
|
19 |
+
name_or_path: black-forest-labs/FLUX.1-schnell
|
20 |
+
quantize: true
|
21 |
+
network:
|
22 |
+
linear: 16
|
23 |
+
linear_alpha: 16
|
24 |
+
type: lora
|
25 |
+
sample:
|
26 |
+
guidance_scale: 4
|
27 |
+
height: 1024
|
28 |
+
neg: ''
|
29 |
+
prompts:
|
30 |
+
- people are celebrate festival, kathein festival cartoon
|
31 |
+
sample_every: 1000
|
32 |
+
sample_steps: 4
|
33 |
+
sampler: flowmatch
|
34 |
+
seed: 42
|
35 |
+
walk_seed: true
|
36 |
+
width: 1024
|
37 |
+
save:
|
38 |
+
dtype: float16
|
39 |
+
hf_private: true
|
40 |
+
hf_repo_id: shweaung/myanmar-kathein-festival-cartoon
|
41 |
+
max_step_saves_to_keep: 4
|
42 |
+
push_to_hub: true
|
43 |
+
save_every: 10000
|
44 |
+
train:
|
45 |
+
batch_size: 1
|
46 |
+
disable_sampling: false
|
47 |
+
dtype: bf16
|
48 |
+
ema_config:
|
49 |
+
ema_decay: 0.99
|
50 |
+
use_ema: true
|
51 |
+
gradient_accumulation_steps: 1
|
52 |
+
gradient_checkpointing: true
|
53 |
+
lr: 0.0004
|
54 |
+
noise_scheduler: flowmatch
|
55 |
+
optimizer: adamw8bit
|
56 |
+
skip_first_sample: true
|
57 |
+
steps: 1000
|
58 |
+
train_text_encoder: false
|
59 |
+
train_unet: true
|
60 |
+
training_folder: output
|
61 |
+
trigger_word: kathein festival cartoon
|
62 |
+
type: sd_trainer
|
63 |
+
job: extension
|
64 |
+
meta:
|
65 |
+
name: '[name]'
|
66 |
+
version: '1.0'
|
images 51.jpeg
ADDED
Git LFS Details
|
images 52.jpeg
ADDED
Git LFS Details
|
images 54.jpeg
ADDED
Git LFS Details
|
images 55.jpeg
ADDED
Git LFS Details
|
images 56.jpeg
ADDED
Git LFS Details
|
images 58.jpeg
ADDED
Git LFS Details
|
images 59.jpeg
ADDED
Git LFS Details
|
images 60.jpeg
ADDED
Git LFS Details
|
images 61.jpeg
ADDED
Git LFS Details
|
images 62.jpeg
ADDED
Git LFS Details
|
images 63.jpeg
ADDED
Git LFS Details
|
images 64.jpeg
ADDED
Git LFS Details
|
images 65.jpeg
ADDED
Git LFS Details
|
images 66.jpeg
ADDED
Git LFS Details
|
images 67.jpeg
ADDED
Git LFS Details
|
metadata.jsonl
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{"file_name": "images 67.jpeg", "prompt": "[trigger]"}
|
2 |
+
{"file_name": "images 66.jpeg", "prompt": "[trigger]"}
|
3 |
+
{"file_name": "images 65.jpeg", "prompt": "[trigger]"}
|
4 |
+
{"file_name": "images 64.jpeg", "prompt": "[trigger]"}
|
5 |
+
{"file_name": "images 63.jpeg", "prompt": "[trigger]"}
|
6 |
+
{"file_name": "images 62.jpeg", "prompt": "[trigger]"}
|
7 |
+
{"file_name": "images 61.jpeg", "prompt": "[trigger]"}
|
8 |
+
{"file_name": "\u1000\u1011\u1014\u1015\u1010 Kahtein Festival large.png_1713719538.png", "prompt": "[trigger]"}
|
9 |
+
{"file_name": "images 59.jpeg", "prompt": "[trigger]"}
|
10 |
+
{"file_name": "images 60.jpeg", "prompt": "[trigger]"}
|
11 |
+
{"file_name": "images 58.jpeg", "prompt": "[trigger]"}
|
12 |
+
{"file_name": "images 56.jpeg", "prompt": "[trigger]"}
|
13 |
+
{"file_name": "images 55.jpeg", "prompt": "[trigger]"}
|
14 |
+
{"file_name": "images 54.jpeg", "prompt": "[trigger]"}
|
15 |
+
{"file_name": "images 52.jpeg", "prompt": "[trigger]"}
|
16 |
+
{"file_name": "images 51.jpeg", "prompt": "[trigger]"}
|
requirements.txt
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
git+https://github.com/huggingface/diffusers.git
|
2 |
+
lycoris-lora==1.8.3
|
3 |
+
flatten_json
|
4 |
+
pyyaml
|
5 |
+
oyaml
|
6 |
+
tensorboard
|
7 |
+
kornia
|
8 |
+
invisible-watermark
|
9 |
+
einops
|
10 |
+
toml
|
11 |
+
albumentations
|
12 |
+
pydantic
|
13 |
+
omegaconf
|
14 |
+
k-diffusion
|
15 |
+
open_clip_torch
|
16 |
+
prodigyopt
|
17 |
+
controlnet_aux==0.0.7
|
18 |
+
python-dotenv
|
19 |
+
lpips
|
20 |
+
pytorch_fid
|
21 |
+
optimum-quanto
|
script.py
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from huggingface_hub import snapshot_download, delete_repo, metadata_update
|
3 |
+
import uuid
|
4 |
+
import json
|
5 |
+
import yaml
|
6 |
+
import subprocess
|
7 |
+
|
8 |
+
HF_TOKEN = os.environ.get("HF_TOKEN")
|
9 |
+
HF_DATASET = os.environ.get("DATA_PATH")
|
10 |
+
|
11 |
+
|
12 |
+
def download_dataset(hf_dataset_path: str):
|
13 |
+
random_id = str(uuid.uuid4())
|
14 |
+
snapshot_download(
|
15 |
+
repo_id=hf_dataset_path,
|
16 |
+
token=HF_TOKEN,
|
17 |
+
local_dir=f"/tmp/{random_id}",
|
18 |
+
repo_type="dataset",
|
19 |
+
)
|
20 |
+
return f"/tmp/{random_id}"
|
21 |
+
|
22 |
+
|
23 |
+
def process_dataset(dataset_dir: str):
|
24 |
+
# dataset dir consists of images, config.yaml and a metadata.jsonl (optional) with fields: file_name, prompt
|
25 |
+
# generate .txt files with the same name as the images with the prompt as the content
|
26 |
+
# remove metadata.jsonl
|
27 |
+
# return the path to the processed dataset
|
28 |
+
|
29 |
+
# check if config.yaml exists
|
30 |
+
if not os.path.exists(os.path.join(dataset_dir, "config.yaml")):
|
31 |
+
raise ValueError("config.yaml does not exist")
|
32 |
+
|
33 |
+
# check if metadata.jsonl exists
|
34 |
+
if os.path.exists(os.path.join(dataset_dir, "metadata.jsonl")):
|
35 |
+
metadata = []
|
36 |
+
with open(os.path.join(dataset_dir, "metadata.jsonl"), "r") as f:
|
37 |
+
for line in f:
|
38 |
+
if len(line.strip()) > 0:
|
39 |
+
metadata.append(json.loads(line))
|
40 |
+
for item in metadata:
|
41 |
+
txt_path = os.path.join(dataset_dir, item["file_name"])
|
42 |
+
txt_path = txt_path.rsplit(".", 1)[0] + ".txt"
|
43 |
+
with open(txt_path, "w") as f:
|
44 |
+
f.write(item["prompt"])
|
45 |
+
|
46 |
+
# remove metadata.jsonl
|
47 |
+
os.remove(os.path.join(dataset_dir, "metadata.jsonl"))
|
48 |
+
|
49 |
+
with open(os.path.join(dataset_dir, "config.yaml"), "r") as f:
|
50 |
+
config = yaml.safe_load(f)
|
51 |
+
|
52 |
+
# update config with new dataset
|
53 |
+
config["config"]["process"][0]["datasets"][0]["folder_path"] = dataset_dir
|
54 |
+
|
55 |
+
with open(os.path.join(dataset_dir, "config.yaml"), "w") as f:
|
56 |
+
yaml.dump(config, f)
|
57 |
+
|
58 |
+
return dataset_dir
|
59 |
+
|
60 |
+
|
61 |
+
def run_training(hf_dataset_path: str):
|
62 |
+
|
63 |
+
dataset_dir = download_dataset(hf_dataset_path)
|
64 |
+
dataset_dir = process_dataset(dataset_dir)
|
65 |
+
|
66 |
+
# run training
|
67 |
+
commands = "git clone https://github.com/ostris/ai-toolkit.git ai-toolkit && cd ai-toolkit && git checkout bc693488eb3cf48ded8bc2af845059d80f4cf7d0 && git submodule update --init --recursive"
|
68 |
+
subprocess.run(commands, shell=True)
|
69 |
+
|
70 |
+
commands = f"python run.py {os.path.join(dataset_dir, 'config.yaml')}"
|
71 |
+
process = subprocess.Popen(commands, shell=True, cwd="ai-toolkit", env=os.environ)
|
72 |
+
|
73 |
+
return process, dataset_dir
|
74 |
+
|
75 |
+
|
76 |
+
if __name__ == "__main__":
|
77 |
+
process, dataset_dir = run_training(HF_DATASET)
|
78 |
+
process.wait() # Wait for the training process to finish
|
79 |
+
|
80 |
+
with open(os.path.join(dataset_dir, "config.yaml"), "r") as f:
|
81 |
+
config = yaml.safe_load(f)
|
82 |
+
repo_id = config["config"]["process"][0]["save"]["hf_repo_id"]
|
83 |
+
|
84 |
+
metadata = {
|
85 |
+
"tags": [
|
86 |
+
"autotrain",
|
87 |
+
"spacerunner",
|
88 |
+
"text-to-image",
|
89 |
+
"flux",
|
90 |
+
"lora",
|
91 |
+
"diffusers",
|
92 |
+
"template:sd-lora",
|
93 |
+
]
|
94 |
+
}
|
95 |
+
metadata_update(repo_id, metadata, token=HF_TOKEN, repo_type="model", overwrite=True)
|
96 |
+
delete_repo(HF_DATASET, token=HF_TOKEN, repo_type="dataset", missing_ok=True)
|
ααααα Kahtein Festival large.png_1713719538.png
ADDED
Git LFS Details
|