openfree commited on
Commit
f28b7ec
1 Parent(s): b8acf2f

Upload folder using huggingface_hub

Browse files
Files changed (24) hide show
  1. 10.PNG +3 -0
  2. 106.PNG +3 -0
  3. 108.PNG +3 -0
  4. 109.PNG +3 -0
  5. 110.PNG +3 -0
  6. 112.PNG +3 -0
  7. 113.PNG +3 -0
  8. 15.PNG +3 -0
  9. 16.PNG +3 -0
  10. 52.PNG +3 -0
  11. 55.PNG +3 -0
  12. 65.PNG +3 -0
  13. 66.PNG +3 -0
  14. 69.PNG +3 -0
  15. 71.PNG +3 -0
  16. 77.PNG +3 -0
  17. 8.PNG +3 -0
  18. 82.PNG +3 -0
  19. 89.PNG +3 -0
  20. 90.PNG +3 -0
  21. config.yaml +70 -0
  22. metadata.jsonl +20 -0
  23. requirements.txt +21 -0
  24. script.py +96 -0
10.PNG ADDED

Git LFS Details

  • SHA256: 8c788761713f39889a74a60ba53341106f2ae1e2d130950456d81b4ebbdde032
  • Pointer size: 131 Bytes
  • Size of remote file: 208 kB
106.PNG ADDED

Git LFS Details

  • SHA256: 81e16c9faecef4428115ee4435627393af2e8aa58906aa72ab59a211a69819ad
  • Pointer size: 131 Bytes
  • Size of remote file: 389 kB
108.PNG ADDED

Git LFS Details

  • SHA256: e363accd9e22896e9f24b564567b362978b92bad7bf46250836c3bbdf59af9c0
  • Pointer size: 131 Bytes
  • Size of remote file: 438 kB
109.PNG ADDED

Git LFS Details

  • SHA256: 73be0849f4ae17e19e29fc1adc3e771cde1b1c21747dc36cd9ff02be04f41edc
  • Pointer size: 131 Bytes
  • Size of remote file: 469 kB
110.PNG ADDED

Git LFS Details

  • SHA256: 75d672cbe30e6300e25f2dfdc99d21afa054cbdcb751ae32bca9c176f5b9ad23
  • Pointer size: 131 Bytes
  • Size of remote file: 419 kB
112.PNG ADDED

Git LFS Details

  • SHA256: cddc2dc70cbf9965a568347ad7708628afa4ecc56cdc2a67f1f724a720669d1d
  • Pointer size: 131 Bytes
  • Size of remote file: 374 kB
113.PNG ADDED

Git LFS Details

  • SHA256: f037f443f91c3713e30b00431d1a536793b27655a6132813a0a0d29dbf4402f0
  • Pointer size: 131 Bytes
  • Size of remote file: 353 kB
15.PNG ADDED

Git LFS Details

  • SHA256: e5d74313d6b6de196c8b234add2625350ef1fcdf92f99fa7c2fa403b601c4964
  • Pointer size: 131 Bytes
  • Size of remote file: 488 kB
16.PNG ADDED

Git LFS Details

  • SHA256: 007b0d27bd6a56b54df5d125ff90aff4803305aac40b3de76993d6f3bd77d0f0
  • Pointer size: 131 Bytes
  • Size of remote file: 189 kB
52.PNG ADDED

Git LFS Details

  • SHA256: 434eca01056f882215c7ccf0ef78973c000af83be0dd8f20855aa9372e002220
  • Pointer size: 131 Bytes
  • Size of remote file: 734 kB
55.PNG ADDED

Git LFS Details

  • SHA256: a2ae144989ff1683511ce382de3a73df234d445b8f3b10d48f43a8f3c5bd40bc
  • Pointer size: 131 Bytes
  • Size of remote file: 754 kB
65.PNG ADDED

Git LFS Details

  • SHA256: 2f1d747775b8a58ab7549be5faf58a80e649da14409c0f2a5823fb673cdb04e2
  • Pointer size: 131 Bytes
  • Size of remote file: 748 kB
66.PNG ADDED

Git LFS Details

  • SHA256: 71d3bef9e898dea7c95b70fc3aa539c6383df240bf5421bb49e970969464294e
  • Pointer size: 132 Bytes
  • Size of remote file: 1.15 MB
69.PNG ADDED

Git LFS Details

  • SHA256: cc2affc7b30fc4fb6a1a95fc5ae7bf45383f3c6d4758470a493a273affed067c
  • Pointer size: 131 Bytes
  • Size of remote file: 796 kB
71.PNG ADDED

Git LFS Details

  • SHA256: 33e0cc455bbf0ce21b6a98a2f76e82cd389cd59c9622146a17123831d3af80fa
  • Pointer size: 131 Bytes
  • Size of remote file: 637 kB
77.PNG ADDED

Git LFS Details

  • SHA256: 734fd32b432d333b4a535a7be7cc44c9cf0a8e37b1fd00c952812ccc3b75c771
  • Pointer size: 131 Bytes
  • Size of remote file: 135 kB
8.PNG ADDED

Git LFS Details

  • SHA256: 4033ea2392a38a4c3901206bd51318eb2b1de83d1b92d0017ba9213978044337
  • Pointer size: 130 Bytes
  • Size of remote file: 67.1 kB
82.PNG ADDED

Git LFS Details

  • SHA256: 0b5f17e9e5860d3fdc1ccd8a2b72fb698993bd1c40651e57a39b19df078841f8
  • Pointer size: 131 Bytes
  • Size of remote file: 512 kB
89.PNG ADDED

Git LFS Details

  • SHA256: 21f77b82689dc5aa98766ef5a71aac8450525306a8f70bd44236320251dcc936
  • Pointer size: 131 Bytes
  • Size of remote file: 310 kB
90.PNG ADDED

Git LFS Details

  • SHA256: b9aeedc2a20032fe36e79cc2dc9a54557714cd1b5d2aea39a9c144437fb3afdb
  • Pointer size: 131 Bytes
  • Size of remote file: 517 kB
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)