shweaung commited on
Commit
bcdbd25
1 Parent(s): 4d3ac83

Upload folder using huggingface_hub

Browse files
Files changed (34) hide show
  1. An ancient Burmese harpist in Traditional costume 1.jpeg +3 -0
  2. An ancient Burmese harpist in Traditional costume 2.jpeg +3 -0
  3. An ancient Burmese harpist in Traditional costume.jpeg +3 -0
  4. Ancient Burmese dress for man 10.jpeg +3 -0
  5. Ancient Burmese dress for man 11.jpeg +3 -0
  6. Ancient Burmese dress for man 12.jpeg +3 -0
  7. Ancient Burmese dress for man 13.jpeg +3 -0
  8. Ancient Burmese dress for man 14.jpeg +3 -0
  9. Ancient Burmese dress for man 3.jpeg +3 -0
  10. Ancient Burmese dress for man 4.jpeg +3 -0
  11. Ancient Burmese dress for man 5.jpeg +3 -0
  12. Ancient Burmese dress for man 9.jpeg +3 -0
  13. Ancient Burmese dress for man in palace.jpeg +3 -0
  14. Ancient Burmese dress for man with knife.jpeg +3 -0
  15. Ancient Burmese dress for man.jpeg +3 -0
  16. Ancient Burmese dress for man7.jpeg +3 -0
  17. Burma people ဗမလမ 1.jpeg +3 -0
  18. Burma people ဗမလမ 2.jpeg +3 -0
  19. Burma people ဗမလမ.jpeg +3 -0
  20. Burmese ancient traditional costume for man.jpeg +3 -0
  21. Burmese dress.jpeg +3 -0
  22. Burmese man in traditional costume 2.jpeg +3 -0
  23. Burmese man in traditional costume 6.jpeg +3 -0
  24. Burmese man in traditional costume 7.jpeg +3 -0
  25. Burmese man in traditional costume.jpeg +3 -0
  26. Burmese traditional costume male.jpeg +3 -0
  27. Myanmar _ Burmese traditional costume.jpeg +3 -0
  28. Myanmar _Burma traditional costume.jpeg +3 -0
  29. Traditional Costume of Burmese Men In Amarapura Period -MyanmarBurma.jpeg +3 -0
  30. config.yaml +66 -0
  31. images 69.jpeg +3 -0
  32. metadata.jsonl +30 -0
  33. requirements.txt +21 -0
  34. script.py +96 -0
An ancient Burmese harpist in Traditional costume 1.jpeg ADDED

Git LFS Details

  • SHA256: 1f45ff6bb63a40dc6ff77e9ee2d5472fcb2de0875d114d0854b6dcc29fd63f53
  • Pointer size: 130 Bytes
  • Size of remote file: 66.5 kB
An ancient Burmese harpist in Traditional costume 2.jpeg ADDED

Git LFS Details

  • SHA256: bbf8518187ffda7e3b048a3cc510e9991ba53107431102fe1d4087b7906836db
  • Pointer size: 130 Bytes
  • Size of remote file: 54.2 kB
An ancient Burmese harpist in Traditional costume.jpeg ADDED

Git LFS Details

  • SHA256: e1340a3c3f53a1a9436646984e1933fada685f3deeea0d2b536f7b5fa36c64ce
  • Pointer size: 130 Bytes
  • Size of remote file: 77.6 kB
Ancient Burmese dress for man 10.jpeg ADDED

Git LFS Details

  • SHA256: 1b5e9662350e5f88da03708a2270c2d2354c2e1e904e0541539b4653bcc96569
  • Pointer size: 130 Bytes
  • Size of remote file: 40 kB
Ancient Burmese dress for man 11.jpeg ADDED

Git LFS Details

  • SHA256: be40b71f720e68a0a960360d11084a29c33939b8d8fd7315f29f4f3db2993f9e
  • Pointer size: 130 Bytes
  • Size of remote file: 24.2 kB
Ancient Burmese dress for man 12.jpeg ADDED

Git LFS Details

  • SHA256: 8ed65b918b1e1ba6ed2bb1ac5a067139bdcee470109a00138906e1210b34a30e
  • Pointer size: 130 Bytes
  • Size of remote file: 25.1 kB
Ancient Burmese dress for man 13.jpeg ADDED

Git LFS Details

  • SHA256: e63635c5a9c09e008b1f0def2a4dc4a449c3db010ea3e0c7e7a27f7224f2fc8f
  • Pointer size: 130 Bytes
  • Size of remote file: 37 kB
Ancient Burmese dress for man 14.jpeg ADDED

Git LFS Details

  • SHA256: 197dc35e8cc3ffd4452fd02fb7fad82bd3ca5e3077ffae5cda7d55ffc54eac00
  • Pointer size: 130 Bytes
  • Size of remote file: 55.5 kB
Ancient Burmese dress for man 3.jpeg ADDED

Git LFS Details

  • SHA256: 178adda735ce3bfb5de4d8e589458e99ea59deb7e1fb04060c7dc51d03606af9
  • Pointer size: 130 Bytes
  • Size of remote file: 92.6 kB
Ancient Burmese dress for man 4.jpeg ADDED

Git LFS Details

  • SHA256: 8da4895a8d94e042825eef31b40bb8f2f6dd5be4120441981d4592b1728664ee
  • Pointer size: 130 Bytes
  • Size of remote file: 70.9 kB
Ancient Burmese dress for man 5.jpeg ADDED

Git LFS Details

  • SHA256: b26e83b377608b71f8626f74eae7637b46b731b2b474ceecec0d5a53329789f8
  • Pointer size: 130 Bytes
  • Size of remote file: 82.8 kB
Ancient Burmese dress for man 9.jpeg ADDED

Git LFS Details

  • SHA256: 791139e46a6ed943d488984c272dd108d3079c9b792e8778e3961f389f214bc6
  • Pointer size: 130 Bytes
  • Size of remote file: 46.6 kB
Ancient Burmese dress for man in palace.jpeg ADDED

Git LFS Details

  • SHA256: 7fcac2e552f5dd2ed590cb2bfe636f45cea7465b3467bc57d0df63098bc2e9ea
  • Pointer size: 131 Bytes
  • Size of remote file: 127 kB
Ancient Burmese dress for man with knife.jpeg ADDED

Git LFS Details

  • SHA256: fa68c8d3fad500f42744dac6cd8727a00e4672cb0e71d3ccf8a4e5b1537595e6
  • Pointer size: 130 Bytes
  • Size of remote file: 22.9 kB
Ancient Burmese dress for man.jpeg ADDED

Git LFS Details

  • SHA256: 4cbedbeb404655b8d5f2c4dc670edfce6cac9ca86d3abc3254623680c530c417
  • Pointer size: 130 Bytes
  • Size of remote file: 67.1 kB
Ancient Burmese dress for man7.jpeg ADDED

Git LFS Details

  • SHA256: 30f6a715811617172a9889e9b1b58391d2710e684fd6ef8f13aecd3beef4009d
  • Pointer size: 130 Bytes
  • Size of remote file: 40.7 kB
Burma people ဗမလမ 1.jpeg ADDED

Git LFS Details

  • SHA256: 0ce70964f60751898df96b937000bf39089fe874791d8c097de45e4de88d0402
  • Pointer size: 130 Bytes
  • Size of remote file: 86.6 kB
Burma people ဗမလမ 2.jpeg ADDED

Git LFS Details

  • SHA256: 8e0e78c016467b351d0b3b6d1391c3a85b4dfca20dd28c041c8b2fa54ba46f11
  • Pointer size: 131 Bytes
  • Size of remote file: 105 kB
Burma people ဗမလမ.jpeg ADDED

Git LFS Details

  • SHA256: 3ca416174fd5dcf27c8d86e79eee0f0d6745c7ca8683b8531ece4e0d95bd2e4a
  • Pointer size: 131 Bytes
  • Size of remote file: 115 kB
Burmese ancient traditional costume for man.jpeg ADDED

Git LFS Details

  • SHA256: 63a8a8af55b046c805a133eef70b6b9cbba0a5cc9ced6e855912161b5b48bd4b
  • Pointer size: 131 Bytes
  • Size of remote file: 114 kB
Burmese dress.jpeg ADDED

Git LFS Details

  • SHA256: 3971a3dd571f2e6e8079ed75844a6bbe4035924f8523ccc2ac60ffa96bac9c10
  • Pointer size: 130 Bytes
  • Size of remote file: 54.3 kB
Burmese man in traditional costume 2.jpeg ADDED

Git LFS Details

  • SHA256: 83fdc23440377c7d93e28798259cb905e552ba46bfab78e5747aa746f5e5a54b
  • Pointer size: 130 Bytes
  • Size of remote file: 68.8 kB
Burmese man in traditional costume 6.jpeg ADDED

Git LFS Details

  • SHA256: 45bcb6d1cdc4885c4497cb1c312cec62894c562147aee564ab66393e6b1a804b
  • Pointer size: 131 Bytes
  • Size of remote file: 133 kB
Burmese man in traditional costume 7.jpeg ADDED

Git LFS Details

  • SHA256: 1103ed47e5067d59102191c76dcc08924a1efff8393b7f5c643399cb16d26c61
  • Pointer size: 131 Bytes
  • Size of remote file: 147 kB
Burmese man in traditional costume.jpeg ADDED

Git LFS Details

  • SHA256: 1560fd6bc8acb862406896049f35aeafa501f422223fa817d73b337a373cb7bd
  • Pointer size: 131 Bytes
  • Size of remote file: 112 kB
Burmese traditional costume male.jpeg ADDED

Git LFS Details

  • SHA256: f3823c43021e34bd87cd32532f6327938247859039b33c55b181115d6d7c400c
  • Pointer size: 130 Bytes
  • Size of remote file: 64.2 kB
Myanmar _ Burmese traditional costume.jpeg ADDED

Git LFS Details

  • SHA256: 807119bb8e68d9ea37b0fe5553305cae52521594699d1883b63ee18f2ed87464
  • Pointer size: 130 Bytes
  • Size of remote file: 90.3 kB
Myanmar _Burma traditional costume.jpeg ADDED

Git LFS Details

  • SHA256: ce6e1bcd121df9abb478e9f313ffc632b61eed83eeba1e5eafa8558fdd13b5b4
  • Pointer size: 130 Bytes
  • Size of remote file: 70.4 kB
Traditional Costume of Burmese Men In Amarapura Period -MyanmarBurma.jpeg ADDED

Git LFS Details

  • SHA256: 9bd7ab6d0c626aa869d6dbc9a371db5fe3ffa5cf0918047799db3f0a956c8f78
  • Pointer size: 130 Bytes
  • Size of remote file: 65 kB
config.yaml ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ config:
2
+ name: myanmar-ancient-male
3
+ process:
4
+ - datasets:
5
+ - cache_latents_to_disk: true
6
+ caption_dropout_rate: 0.05
7
+ caption_ext: txt
8
+ folder_path: datasets/aa5ff0ce-d202-4d14-a238-731d18e340ea
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 person in a bustling cafe Burmese ancient man
30
+ - Burmese ancient man in a mall
31
+ sample_every: 1000
32
+ sample_steps: 28
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-ancient-male
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: Burmese ancient man
62
+ type: sd_trainer
63
+ job: extension
64
+ meta:
65
+ name: '[name]'
66
+ version: '1.0'
images 69.jpeg ADDED

Git LFS Details

  • SHA256: 930fbf7c78706d51e1ba55374a7c283e9af22bd99c3dadd7281a77efc131b5d9
  • Pointer size: 130 Bytes
  • Size of remote file: 46 kB
metadata.jsonl ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"file_name": "Burmese man in traditional costume.jpeg", "prompt": "a man in a white dress and a green turban standing in front of a wooden door. He is wearing a traditional burmese dress, with intricate embroidery and beading, and a bright yellow turban on his head. He has a confident stance and a determined expression on his face, as if he is ready to take on any challenge. [trigger]"}
2
+ {"file_name": "Burmese man in traditional costume 2.jpeg", "prompt": "a man standing in front of a wall wearing a white shirt and a brown skirt, ancient burmese dress, with a white headband on his head. [trigger]"}
3
+ {"file_name": "Myanmar _Burma traditional costume.jpeg", "prompt": "a man sitting on top of a chair in a room, wearing a traditional Myanmar burma ethnic outfit. The background of the image is filled with photo frames on the wall and a wooden object on the left side. There is also a watermark on the image. [trigger]"}
4
+ {"file_name": "Burma people \u1017\u1019\u101c\u1019 2.jpeg", "prompt": "a man in a white shirt and hat standing next to a table with a red object on it. He is holding a cloth in his hand and there is a chair to his left. In the background there is an object and a wall, and the sky is visible at the top of the image. There is also some text on the image, suggesting that it is a Burma Land photoshoot. [trigger]"}
5
+ {"file_name": "Traditional Costume of Burmese Men In Amarapura Period -MyanmarBurma.jpeg", "prompt": "a man in a white shirt and plaid skirt sitting on top of a table, with a wall in the background. He is wearing a traditional burmese costume, with intricate details and vibrant colors. His posture is relaxed and confident, and his eyes are closed, giving the impression of a peaceful and serene atmosphere. [trigger]"}
6
+ {"file_name": "Burma people \u1017\u1019\u101c\u1019 1.jpeg", "prompt": "a man in a white shirt and green skirt standing in front of a building, with a wall in the background and text on the left side. He is wearing a traditional Myanmar burma dress, which is a traditional garment worn in the country. [trigger]"}
7
+ {"file_name": "Burma people \u1017\u1019\u101c\u1019.jpeg", "prompt": "a woman in a white shirt and green skirt dancing in front of a building with arches and a window, with text on the right side and a watermark at the bottom. She is performing a Burma dance, a traditional Burmese dance. [trigger]"}
8
+ {"file_name": "An ancient Burmese harpist in Traditional costume 2.jpeg", "prompt": "a man in a white shirt and blue plaid skirt standing with his arms crossed, wearing a turban on his head. In the background there is a wall and on the right side of the image there is an object. [trigger]"}
9
+ {"file_name": "An ancient Burmese harpist in Traditional costume 1.jpeg", "prompt": "a man sitting on top of a chair next to a table, wearing a white shirt and a blue and white dress. The background is a cream color and there is a watermark at the bottom of the image. [trigger]"}
10
+ {"file_name": "An ancient Burmese harpist in Traditional costume.jpeg", "prompt": "a man sitting on top of a bed, wearing a white t-shirt and blue pants, holding a musical instrument in his hands. The background of the image is a cream-colored wall. [trigger]"}
11
+ {"file_name": "Burmese man in traditional costume 6.jpeg", "prompt": "a man standing in front of a maroon curtain, wearing a white shirt and an orange dhoti. The background of the image is a golden wall. [trigger]"}
12
+ {"file_name": "Burmese man in traditional costume 7.jpeg", "prompt": "a man in a white shirt and red pants standing next to a brick wall, holding something in his hands. He is wearing traditional burmese clothing, with intricate patterns and designs, and his posture is confident and strong. [trigger]"}
13
+ {"file_name": "Burmese ancient traditional costume for man.jpeg", "prompt": "a man in a white and gold dress with a turban on his head, standing in front of a blurred background. He appears to be a burmese king, with a regal air about him. [trigger]"}
14
+ {"file_name": "Myanmar _ Burmese traditional costume.jpeg", "prompt": "a man sitting on a chair wearing a white shirt and maroon pants, with a black turban on his head, against a white background. [trigger]"}
15
+ {"file_name": "Burmese traditional costume male.jpeg", "prompt": "a man in a blue and gold traditional burmese king costume with a crown on his head, standing in front of a brown background\". [trigger]"}
16
+ {"file_name": "Ancient Burmese dress for man.jpeg", "prompt": "a man wearing a white shirt and plaid pants, with a white turban on his head, traditional burmese costume standing against a white background. [trigger]"}
17
+ {"file_name": "Ancient Burmese dress for man in palace.jpeg", "prompt": "a man standing in front of a wooden door with intricate carvings on it. He is wearing a white shirt and a colorful skirt, traditional burmese costume and the background is slightly blurred, giving the image a dreamy feel. [trigger]"}
18
+ {"file_name": "Burmese dress.jpeg", "prompt": "a man in a pink shirt and plaid pants standing and holding an umbrella in his hand. He is wearing a traditional Burmese costume, with intricate embroidery and beading along the neckline and sleeves. His hair is tied up in a bun and he has a serious expression on his face. The background is a neutral color, allowing the focus to remain on the man and his costume. [trigger]"}
19
+ {"file_name": "Ancient Burmese dress for man 3.jpeg", "prompt": "a man sitting at a table with a bowl of food in one hand and a plate of food items in the other. On the table there is a basket, a kettle, and some clothes, and in the background there is an object on the wall. The man is wearing a traditional burmese costume, with a white apron and a black chef's hat. [trigger]"}
20
+ {"file_name": "Ancient Burmese dress for man 4.jpeg", "prompt": "a man standing in front of a cream-colored backdrop wearing a white shirt and blue pants traditional burmese costume, with a headband on his head. [trigger]"}
21
+ {"file_name": "Ancient Burmese dress for man 5.jpeg", "prompt": "a burmese king in a green and red kilt standing on the floor, holding a flute in his hand. Behind him is a table with various objects on it, and in the background there are sculptures and a wall. [trigger]"}
22
+ {"file_name": "Ancient Burmese dress for man 9.jpeg", "prompt": "a man sitting on top of a throne in front of a golden wall adorned with sculptures and lamps. He is wearing a traditional Burmese costume, with intricate details and vibrant colors. [trigger]"}
23
+ {"file_name": "Ancient Burmese dress for man7.jpeg", "prompt": "a man standing in front of a wooden door wearing a traditional burmese costume. The costume is green in color and there is a watermark at the top of the image. [trigger]"}
24
+ {"file_name": "Ancient Burmese dress for man 10.jpeg", "prompt": "a man standing in front of a brick building, wearing a traditional Myanmar outfit. The background of the image is filled with ancient architectures and trees, creating a peaceful atmosphere. [trigger]"}
25
+ {"file_name": "Ancient Burmese dress for man 11.jpeg", "prompt": "an ancient burmese man standing on the bank of the Ganges River in Varanasi, India, wearing a white shirt and a turban. The backdrop of the image is filled with the tranquil blue waters of the river, lush green trees, and a bright blue sky. [trigger]"}
26
+ {"file_name": "Ancient Burmese dress for man 12.jpeg", "prompt": "an ancient burmese man standing in front of a brown wall wearing a white shirt and plaid pants, with a flower vase on the table beside him. [trigger]"}
27
+ {"file_name": "Ancient Burmese dress for man 13.jpeg", "prompt": "an ancient burmese man standing in front of a building wearing a white shirt and a plaid skirt. The background of the image is filled with pillars and trees, creating a peaceful atmosphere. [trigger]"}
28
+ {"file_name": "Ancient Burmese dress for man 14.jpeg", "prompt": "an ancient burmese man standing in front of a stone wall, wearing a white shirt and a pink and green sarong. The background of the image is a wall, and there is a watermark in the top right corner. [trigger]"}
29
+ {"file_name": "images 69.jpeg", "prompt": "an ancient burmese man in a white shirt and brown skirt walking down a sidewalk, surrounded by a building, trees, and a clear blue sky. He is wearing a traditional Thai dress, with intricate patterns and designs, and is likely a model from Thailand. [trigger]"}
30
+ {"file_name": "Ancient Burmese dress for man with knife.jpeg", "prompt": "a man in a black and white dress walking down the street, holding a stick in her hand. In the background, there are a few people, vehicles, and trees, all of which are slightly blurred. This image captures the essence of Myanmar's traditional culture, with its vibrant colors and intricate details. [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)