Upload folder using huggingface_hub
Browse files- 10.PNG +3 -0
- 106.PNG +3 -0
- 108.PNG +3 -0
- 109.PNG +3 -0
- 110.PNG +3 -0
- 112.PNG +3 -0
- 113.PNG +3 -0
- 15.PNG +3 -0
- 16.PNG +3 -0
- 52.PNG +3 -0
- 55.PNG +3 -0
- 65.PNG +3 -0
- 66.PNG +3 -0
- 69.PNG +3 -0
- 71.PNG +3 -0
- 77.PNG +3 -0
- 8.PNG +3 -0
- 82.PNG +3 -0
- 89.PNG +3 -0
- 90.PNG +3 -0
- config.yaml +70 -0
- metadata.jsonl +20 -0
- requirements.txt +21 -0
- script.py +96 -0
10.PNG
ADDED
Git LFS Details
|
106.PNG
ADDED
Git LFS Details
|
108.PNG
ADDED
Git LFS Details
|
109.PNG
ADDED
Git LFS Details
|
110.PNG
ADDED
Git LFS Details
|
112.PNG
ADDED
Git LFS Details
|
113.PNG
ADDED
Git LFS Details
|
15.PNG
ADDED
Git LFS Details
|
16.PNG
ADDED
Git LFS Details
|
52.PNG
ADDED
Git LFS Details
|
55.PNG
ADDED
Git LFS Details
|
65.PNG
ADDED
Git LFS Details
|
66.PNG
ADDED
Git LFS Details
|
69.PNG
ADDED
Git LFS Details
|
71.PNG
ADDED
Git LFS Details
|
77.PNG
ADDED
Git LFS Details
|
8.PNG
ADDED
Git LFS Details
|
82.PNG
ADDED
Git LFS Details
|
89.PNG
ADDED
Git LFS Details
|
90.PNG
ADDED
Git LFS Details
|
config.yaml
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
config:
|
2 |
+
name: flx-fash-test
|
3 |
+
process:
|
4 |
+
- datasets:
|
5 |
+
- cache_latents_to_disk: true
|
6 |
+
caption_dropout_rate: 0.05
|
7 |
+
caption_ext: txt
|
8 |
+
folder_path: datasets/b3d57c70-f303-4b1e-becb-cc044bb98d57
|
9 |
+
resolution:
|
10 |
+
- 512
|
11 |
+
- 768
|
12 |
+
- 1024
|
13 |
+
shuffle_tokens: false
|
14 |
+
device: cuda:0
|
15 |
+
model:
|
16 |
+
is_flux: true
|
17 |
+
low_vram: true
|
18 |
+
name_or_path: black-forest-labs/FLUX.1-dev
|
19 |
+
quantize: true
|
20 |
+
network:
|
21 |
+
linear: 16
|
22 |
+
linear_alpha: 16
|
23 |
+
type: lora
|
24 |
+
sample:
|
25 |
+
guidance_scale: 4
|
26 |
+
height: 1024
|
27 |
+
neg: ''
|
28 |
+
prompts:
|
29 |
+
- a woman standing on the sidewalk, holding an umbrella in her hand. She is
|
30 |
+
wearing a beige trench coat and black shorts, and in the background there
|
31 |
+
is a person walking on the footpath, a pole, and a building. [trigger]
|
32 |
+
- a woman wearing a beige trench coat and black pants, with a watch on her wrist,
|
33 |
+
taking a selfie in front of a mirror. In the background, there is a table
|
34 |
+
and a wall. [trigger]
|
35 |
+
sample_every: 1000
|
36 |
+
sample_steps: 28
|
37 |
+
sampler: flowmatch
|
38 |
+
seed: 42
|
39 |
+
walk_seed: true
|
40 |
+
width: 1024
|
41 |
+
save:
|
42 |
+
dtype: float16
|
43 |
+
hf_private: true
|
44 |
+
hf_repo_id: openfree/flx-fash-test
|
45 |
+
max_step_saves_to_keep: 4
|
46 |
+
push_to_hub: true
|
47 |
+
save_every: 10000
|
48 |
+
train:
|
49 |
+
batch_size: 1
|
50 |
+
disable_sampling: false
|
51 |
+
dtype: bf16
|
52 |
+
ema_config:
|
53 |
+
ema_decay: 0.99
|
54 |
+
use_ema: true
|
55 |
+
gradient_accumulation_steps: 1
|
56 |
+
gradient_checkpointing: true
|
57 |
+
lr: 0.0004
|
58 |
+
noise_scheduler: flowmatch
|
59 |
+
optimizer: adamw8bit
|
60 |
+
skip_first_sample: true
|
61 |
+
steps: 1000
|
62 |
+
train_text_encoder: false
|
63 |
+
train_unet: true
|
64 |
+
training_folder: output
|
65 |
+
trigger_word: 'trench coat '
|
66 |
+
type: sd_trainer
|
67 |
+
job: extension
|
68 |
+
meta:
|
69 |
+
name: '[name]'
|
70 |
+
version: '1.0'
|
metadata.jsonl
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{"file_name": "8.PNG", "prompt": "a woman standing in front of a wooden door wearing a beige trench coat and black boots. She is holding a mobile phone in one hand and a bag in the other. On the left side of the image, there is a table with various objects on it. [trigger]"}
|
2 |
+
{"file_name": "77.PNG", "prompt": "a beige trench coat hanging on a wall next to a window, with a lamp and other objects on the table below. Through the window, a car can be seen driving on the road. [trigger]"}
|
3 |
+
{"file_name": "82.PNG", "prompt": "a woman standing on the sidewalk, holding an umbrella in her hand. She is wearing a beige trench coat and black shorts, and in the background there is a person walking on the footpath, a pole, and a building. [trigger]"}
|
4 |
+
{"file_name": "89.PNG", "prompt": "a woman wearing a beige trench coat and black pants, holding a mobile phone in her hand. In the background, there is a wall with a photo frame and other objects. [trigger]"}
|
5 |
+
{"file_name": "90.PNG", "prompt": "a woman wearing a beige trench coat and black skirt, holding a cup of coffee in one hand and a mobile phone in the other. She is standing in front of a wall with a frame attached to it, and there is a table and chair to her left. [trigger]"}
|
6 |
+
{"file_name": "52.PNG", "prompt": "a woman wearing a beige trench coat and a black skirt, holding a bouquet of flowers in her hand. She is standing in front of a wall with a window in the background. [trigger]"}
|
7 |
+
{"file_name": "55.PNG", "prompt": "a woman wearing a beige trench coat and a black skirt, holding a bouquet of flowers in her hand. She is standing in front of a wall with a door in the background. [trigger]"}
|
8 |
+
{"file_name": "65.PNG", "prompt": "a woman wearing a beige trench coat and black shorts standing on the ground, holding a book and a mobile phone in her hands. On the left side of the image there is a table with a flower bouquet placed on it, and in the background there are doors. [trigger]"}
|
9 |
+
{"file_name": "66.PNG", "prompt": "a woman wearing a beige trench coat and black shorts, standing on the ground with a bag in her hand. Behind her is a chair and a table, and in the background is a glass door. [trigger]"}
|
10 |
+
{"file_name": "69.PNG", "prompt": "a woman wearing a beige trench coat and black shorts, standing on the floor and holding a mobile phone in her hand. In the background, there is a wooden door and a chair. [trigger]"}
|
11 |
+
{"file_name": "71.PNG", "prompt": "a woman standing in front of a door wearing a beige trench coat and black shorts, holding a cup of coffee in one hand and a mobile phone in the other. She is also carrying a bag. [trigger]"}
|
12 |
+
{"file_name": "10.PNG", "prompt": "a woman wearing a beige trench coat and black pants, with a watch on her wrist, taking a selfie in front of a mirror. In the background, there is a table and a wall. [trigger]"}
|
13 |
+
{"file_name": "15.PNG", "prompt": "a woman wearing a beige trench coat and a black skirt, standing on the floor with a bag in her hand and a pair of spectacles on her face. In the background, there is a wall and a door. [trigger]"}
|
14 |
+
{"file_name": "16.PNG", "prompt": "a woman standing in front of a wooden door wearing a beige trench coat and black shorts. She is holding a mobile phone in one hand and a bag in the other, and there is a cover on the left side of the image. [trigger]"}
|
15 |
+
{"file_name": "106.PNG", "prompt": "a woman wearing a beige trench coat and blue jeans, holding a bag in one hand and a newspaper in the other. She is standing in front of a wall with a board in the background. [trigger]"}
|
16 |
+
{"file_name": "108.PNG", "prompt": "a woman standing in front of a door wearing a beige trench coat and a black skirt. She is also wearing spectacles and carrying a bag. On the left side of the image there is a wall. [trigger]"}
|
17 |
+
{"file_name": "109.PNG", "prompt": "a woman wearing a beige trench coat and black skirt, standing on the floor with a bag in her hand and a pair of spectacles on her face. In the background, there is a wall and a door. [trigger]"}
|
18 |
+
{"file_name": "110.PNG", "prompt": "a woman standing in front of a white door wearing a beige trench coat and a black dress. The wall behind her is visible, adding to the overall composition of the image. [trigger]"}
|
19 |
+
{"file_name": "112.PNG", "prompt": "a woman wearing a beige trench coat with black buttons against a white background. The coat has a classic silhouette with a double-breasted front, long sleeves, and a notched lapel collar. The fabric is lightweight and water-resistant, making it perfect for any season. [trigger]"}
|
20 |
+
{"file_name": "113.PNG", "prompt": "a woman wearing a beige trench coat on a white background. The coat has a classic double-breasted design with a notched lapel collar, long sleeves, and two front pockets. The fabric is lightweight and has a subtle sheen, giving it a timeless look. [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 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)
|