azad-uddin commited on
Commit
bbcd9bd
·
verified ·
1 Parent(s): 1f9424f

Upload folder using huggingface_hub

Browse files
BananaFi.png ADDED

Git LFS Details

  • SHA256: de0d716466b1e83e78238b32d10e5fb79c886a8c92c0c4410aeeafc686eb8e3e
  • Pointer size: 132 Bytes
  • Size of remote file: 2.54 MB
Elon Goatcoin.png ADDED

Git LFS Details

  • SHA256: da1ad28e4fa59751af66f9392577f7ef3924a30a759a1446aa51c2aea8745b7c
  • Pointer size: 132 Bytes
  • Size of remote file: 2.05 MB
FEDcoin.png ADDED

Git LFS Details

  • SHA256: cd03bfba0e3974016d3b2e8077b494e6e0d3c8f84ce7932e17c399c8a01c11e5
  • Pointer size: 132 Bytes
  • Size of remote file: 2.62 MB
Frogzilla Coin.png ADDED

Git LFS Details

  • SHA256: 1d0133d288264974829b3115b4f084999794200bf124e807e5359218c3d1b6fa
  • Pointer size: 132 Bytes
  • Size of remote file: 1.99 MB
GPT-Overlord Token.png ADDED

Git LFS Details

  • SHA256: a932687c3b77e908d747aa3eef8d082d53e4ce93982f11e3ff0494f9a2c49006
  • Pointer size: 132 Bytes
  • Size of remote file: 2.49 MB
Grumpy Cat Cash.png ADDED

Git LFS Details

  • SHA256: c2af6d6c792a5be5bd0b6515901601dcbf4cd408c4cdd7d9d0035e1f0210cb56
  • Pointer size: 132 Bytes
  • Size of remote file: 2.27 MB
KarenCoin.png ADDED

Git LFS Details

  • SHA256: f04c8d1d916d87bcbcaa99175db12b1d10e542587d65d4dd01703e38f2e581c1
  • Pointer size: 132 Bytes
  • Size of remote file: 2.41 MB
Kim Jong Unicorn.png ADDED

Git LFS Details

  • SHA256: 56aeac68c8198d243cb5264a6edf5d91f4b1734b95d07580977c20ff053041d4
  • Pointer size: 132 Bytes
  • Size of remote file: 1.57 MB
Muskrat Coin.png ADDED

Git LFS Details

  • SHA256: b8452834f5fd9bb5170db7b33fbdbd133dd13e3229200f4e84f7182897e0b846
  • Pointer size: 132 Bytes
  • Size of remote file: 2.64 MB
Putin Pug.png ADDED

Git LFS Details

  • SHA256: 3bd0082f72aaffc9a16a8b103e56c3928d0b165a88774269b50a71ff2ca1b646
  • Pointer size: 132 Bytes
  • Size of remote file: 1.71 MB
config.yaml ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ config:
2
+ name: meme-token
3
+ process:
4
+ - datasets:
5
+ - cache_latents_to_disk: true
6
+ caption_dropout_rate: 0.05
7
+ caption_ext: txt
8
+ folder_path: datasets/cc23b530-d366-4138-ae81-8f3bd5709ef1
9
+ resolution:
10
+ - 1024
11
+ shuffle_tokens: false
12
+ device: cuda:0
13
+ model:
14
+ is_flux: true
15
+ low_vram: true
16
+ name_or_path: black-forest-labs/FLUX.1-dev
17
+ quantize: true
18
+ network:
19
+ linear: 64
20
+ linear_alpha: 64
21
+ type: lora
22
+ sample:
23
+ guidance_scale: 4
24
+ height: 1024
25
+ neg: ''
26
+ prompts:
27
+ - memestylx, smiling hulk crypto coin, make everyone happy, all within a circular
28
+ emblem
29
+ - memestylx, flappy bird, takes you to height, all within a circular emblem
30
+ sample_every: 800
31
+ sample_steps: 28
32
+ sampler: flowmatch
33
+ seed: 42
34
+ walk_seed: true
35
+ width: 1024
36
+ save:
37
+ dtype: float16
38
+ hf_private: true
39
+ hf_repo_id: azad-uddin/meme-token
40
+ max_step_saves_to_keep: 4
41
+ push_to_hub: true
42
+ save_every: 10000
43
+ train:
44
+ batch_size: 1
45
+ disable_sampling: false
46
+ dtype: bf16
47
+ ema_config:
48
+ ema_decay: 0.99
49
+ use_ema: true
50
+ gradient_accumulation_steps: 1
51
+ gradient_checkpointing: true
52
+ lr: 0.0004
53
+ noise_scheduler: flowmatch
54
+ optimizer: adamw8bit
55
+ skip_first_sample: true
56
+ steps: 800
57
+ train_text_encoder: false
58
+ train_unet: true
59
+ training_folder: output
60
+ trigger_word: memestylx
61
+ type: sd_trainer
62
+ job: extension
63
+ meta:
64
+ name: '[name]'
65
+ version: '1.0'
metadata.jsonl ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {"file_name": "BananaFi.png", "prompt": " [trigger], A cartoon banana wearing a suit and sunglasses, sitting at a laptop, surrounded by four serious-looking apes, with \"BANANAFI\" at the top and \"POTASSIUM-BACKED DEFI FOR APES ONLY\" at the bottom, all within a circular emblem"}
2
+ {"file_name": "Elon Goatcoin.png", "prompt": "[trigger], A cartoon Elon goat in a space suit and sunglasses, holding a Dogecoin in one hand and a rocket labeled \"GOAT\" in the other, set against a dark blue background with stars and a planet, encircled by \"ELON GOATCOIN\", all within a circular emblem"}
3
+ {"file_name": "FEDcoin.png", "prompt": "[trigger], a logo with the words \"Fedcoin Print Money, Print Memes\" written on it, accompanied by a picture of a printer printing currency note and meme coin, all within a circular emblem"}
4
+ {"file_name": "Frogzilla Coin.png", "prompt": "[trigger], A large, green cartoon frog resembling Godzilla, with a sad expression and smoke coming from its mouth, stomping on a building, and the words \"Frogzilla Coin\", all within a circular emblem"}
5
+ {"file_name": "GPT-Overlord Token.png", "prompt": "[trigger], A stylized robot with a crown on its head, holding a chart showing an upward trend in one hand and a hexagonal, interconnected data symbol in the other. The text \"GPT-OVERLORD TOKEN\" is at the top, and \"BOW BEFORE YOUR ALGORITHMIC RULER\" is at the bottom, all within a circular emblem"}
6
+ {"file_name": "Grumpy Cat Cash.png", "prompt": "[trigger], a grumpy cat holding a sign that reads \"Hodl\" with a few gold cubes in the background. The cat has a mischievous expression on its face, and its fur is a light brown color, all within a circular emblem"}
7
+ {"file_name": "KarenCoin.png", "prompt": "[trigger], A cartoon woman with short blonde hair and an angry expression KAREN, holding a coin labeled \"KAREN\" in one hand and a paper labeled \"RETURN\" in the other. The text \"KARENCOIN\" is at the top and \"LET ME SPEAK TO YOUR FINANAL MANAGR\" is at the bottom, all within a circular emblem"}
8
+ {"file_name": "Kim Jong Unicorn.png", "prompt": "[trigger], A cartoon depiction of Kim Jong Un as a unicorn, with a rocket launching from behind his head, all within a circular emblem"}
9
+ {"file_name": "Muskrat Coin.png", "prompt": "[trigger], A cartoon muskrat wearing a suit and driving a red car (resembling a Tesla) through a tunnel. The text \"MUSKRAT COIN\" is at the top and \"TUNN INTO YOUR OUR WALLET\" is at the bottom, all within a circular emblem"}
10
+ {"file_name": "Putin Pug.png", "prompt": "[trigger], A cartoon pug wearing a military uniform and hat with a red star, riding on the back of a brown bear, with several gold dollar coins floating around them, all within a circular emblem"}
requirements.txt ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ torch==2.6.0
2
+ torchvision==0.21.0
3
+ torchao==0.9.0
4
+ safetensors
5
+ git+https://github.com/jaretburkett/easy_dwpose.git
6
+ git+https://github.com/huggingface/diffusers@363d1ab7e24c5ed6c190abb00df66d9edb74383b
7
+ transformers==4.52.4
8
+ lycoris-lora==1.8.3
9
+ flatten_json
10
+ pyyaml
11
+ oyaml
12
+ tensorboard
13
+ kornia
14
+ invisible-watermark
15
+ einops
16
+ accelerate
17
+ toml
18
+ albumentations==1.4.15
19
+ albucore==0.0.16
20
+ pydantic
21
+ omegaconf
22
+ k-diffusion
23
+ open_clip_torch
24
+ timm
25
+ prodigyopt
26
+ controlnet_aux==0.0.10
27
+ python-dotenv
28
+ bitsandbytes
29
+ hf_transfer
30
+ lpips
31
+ pytorch_fid
32
+ optimum-quanto==0.2.4
33
+ sentencepiece
34
+ huggingface_hub
35
+ peft>=0.15.0
36
+ gradio
37
+ python-slugify
38
+ opencv-python
39
+ pytorch-wavelets==1.3.0
40
+ matplotlib==3.10.1
script.py ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ print(HF_DATASET);
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
+ print("+++ Process Dataset +++");
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
+ print("+++ Run Training +++");
64
+ dataset_dir = download_dataset(hf_dataset_path)
65
+ dataset_dir = process_dataset(dataset_dir)
66
+
67
+ # run training
68
+ commands = "git clone https://github.com/ostris/ai-toolkit.git ai-toolkit && cd ai-toolkit && git checkout 3f0ae99d48c0d3b23687011f452207c1e0ee3427 && git submodule update --init --recursive"
69
+ subprocess.run(commands, shell=True)
70
+
71
+ commands = f"python run.py {os.path.join(dataset_dir, 'config.yaml')}"
72
+ process = subprocess.Popen(commands, shell=True, cwd="ai-toolkit", env=os.environ)
73
+
74
+ return process, dataset_dir
75
+
76
+
77
+ if __name__ == "__main__":
78
+
79
+ print("+++ Run Main Command +++");
80
+ process, dataset_dir = run_training(HF_DATASET)
81
+ process.wait() # Wait for the training process to finish
82
+
83
+ with open(os.path.join(dataset_dir, "config.yaml"), "r") as f:
84
+ config = yaml.safe_load(f)
85
+ repo_id = config["config"]["process"][0]["save"]["hf_repo_id"]
86
+
87
+ metadata = {
88
+ "tags": [
89
+ "autotrain",
90
+ "spacerunner",
91
+ "text-to-image",
92
+ "flux",
93
+ "lora",
94
+ "diffusers",
95
+ "template:sd-lora",
96
+ ]
97
+ }
98
+ metadata_update(repo_id, metadata, token=HF_TOKEN, repo_type="model", overwrite=True)
99
+ delete_repo(HF_DATASET, token=HF_TOKEN, repo_type="dataset", missing_ok=True)