memoryai commited on
Commit
252cd07
·
verified ·
1 Parent(s): 32ae43b

v9: download 100K COYO images (5 partitions), 4 processes, 256 threads

Browse files
Files changed (1) hide show
  1. job_ml.sh +32 -25
job_ml.sh CHANGED
@@ -154,7 +154,7 @@ for i in range(torch.cuda.device_count()):
154
  "
155
 
156
  ###############################################################################
157
- # 5. DATA
158
  ###############################################################################
159
  log "=== [5/7] Data ==="
160
  SHARD_DIR="$DATA0/datasets/processed/flux_train/shards"
@@ -163,11 +163,12 @@ mkdir -p "$SHARD_DIR"
163
  SHARD_COUNT=$(find "$SHARD_DIR" -name "*.tar" 2>/dev/null | wc -l | tr -d '[:space:]')
164
  SHARD_COUNT=${SHARD_COUNT:-0}
165
 
166
- if [ "$SHARD_COUNT" -ge 2 ]; then
 
167
  log " Shards ready ($SHARD_COUNT)"
168
  else
169
- # Try pull from HF first
170
- log " Pulling shards from HF..."
171
  python3 -u << PYEOF || true
172
  from huggingface_hub import snapshot_download
173
  try:
@@ -185,43 +186,48 @@ PYEOF
185
  SHARD_COUNT=$(find "$SHARD_DIR" -name "*.tar" 2>/dev/null | wc -l | tr -d '[:space:]')
186
  SHARD_COUNT=${SHARD_COUNT:-0}
187
 
188
- if [ "$SHARD_COUNT" -lt 2 ]; then
189
- # Download from COYO
190
- log " Downloading from COYO (1 partition, top 20K images)..."
191
  COYO_RAW="$DATA0/datasets/raw/coyo"
192
  COYO_FILTERED="$DATA0/datasets/raw/coyo_filtered"
193
 
194
- # Download 1 parquet only
195
  python3 -u << PYEOF
196
  from huggingface_hub import snapshot_download
197
  snapshot_download(
198
  repo_id='kakaobrain/coyo-700m',
199
  repo_type='dataset',
200
  local_dir='$COYO_RAW',
201
- allow_patterns=['data/part-00000-*.parquet'],
202
- max_workers=4,
 
 
 
 
 
 
203
  )
204
  print(' Metadata OK')
205
  PYEOF
206
 
207
- # Filter
208
  mkdir -p "$COYO_FILTERED"
209
  python3 -u "$PROJECT_DIR/scripts/data_collection/filter_coyo.py" \
210
  --input-dir "$COYO_RAW/data" \
211
  --output-dir "$COYO_FILTERED" \
212
- --min-aesthetic 6.0 \
213
- --min-clip 0.25 \
214
- --max-watermark 0.5 \
215
- --max-records 20000
216
 
217
- # img2dataset
218
  python3 -u -c "
219
  import pandas as pd
220
  df = pd.read_parquet('$COYO_FILTERED/coyo_aesthetic.parquet')
221
  df[['url','text']].rename(columns={'url':'URL','text':'TEXT'}).to_parquet('$SHARD_DIR/_urls.parquet', index=False)
222
- print(f' {len(df)} URLs ready')
223
  "
224
- log " Running img2dataset..."
225
  img2dataset \
226
  --url_list "$SHARD_DIR/_urls.parquet" \
227
  --input_format parquet \
@@ -229,24 +235,25 @@ print(f' {len(df)} URLs ready')
229
  --caption_col TEXT \
230
  --output_format webdataset \
231
  --output_folder "$SHARD_DIR" \
232
- --processes_count 2 \
233
- --thread_count 128 \
234
  --image_size 1024 \
235
  --resize_mode center_crop \
236
  --resize_only_if_bigger True \
237
  --number_sample_per_shard 1000 \
238
- --retries 3 2>&1 | tail -10
239
 
240
  SHARD_COUNT=$(find "$SHARD_DIR" -name "*.tar" 2>/dev/null | wc -l | tr -d '[:space:]')
241
  SHARD_COUNT=${SHARD_COUNT:-0}
 
242
 
243
- if [ "$SHARD_COUNT" -eq 0 ]; then
244
- log " FATAL: No shards"
245
  exit 1
246
  fi
247
 
248
- # Upload shards to HF so next run is instant
249
- log " Uploading shards to HF..."
250
  python3 -u << PYEOF || true
251
  from huggingface_hub import HfApi, upload_folder
252
  api = HfApi()
 
154
  "
155
 
156
  ###############################################################################
157
+ # 5. DATA - Download COYO (100K images)
158
  ###############################################################################
159
  log "=== [5/7] Data ==="
160
  SHARD_DIR="$DATA0/datasets/processed/flux_train/shards"
 
163
  SHARD_COUNT=$(find "$SHARD_DIR" -name "*.tar" 2>/dev/null | wc -l | tr -d '[:space:]')
164
  SHARD_COUNT=${SHARD_COUNT:-0}
165
 
166
+ # Need at least 20 shards (~20K images) to train properly
167
+ if [ "$SHARD_COUNT" -ge 20 ]; then
168
  log " Shards ready ($SHARD_COUNT)"
169
  else
170
+ # Pull existing shards from HF first
171
+ log " Pulling existing shards from HF..."
172
  python3 -u << PYEOF || true
173
  from huggingface_hub import snapshot_download
174
  try:
 
186
  SHARD_COUNT=$(find "$SHARD_DIR" -name "*.tar" 2>/dev/null | wc -l | tr -d '[:space:]')
187
  SHARD_COUNT=${SHARD_COUNT:-0}
188
 
189
+ if [ "$SHARD_COUNT" -lt 20 ]; then
190
+ # Download from COYO - 5 partitions, filter top 100K images
191
+ log " Downloading COYO metadata (5 partitions)..."
192
  COYO_RAW="$DATA0/datasets/raw/coyo"
193
  COYO_FILTERED="$DATA0/datasets/raw/coyo_filtered"
194
 
 
195
  python3 -u << PYEOF
196
  from huggingface_hub import snapshot_download
197
  snapshot_download(
198
  repo_id='kakaobrain/coyo-700m',
199
  repo_type='dataset',
200
  local_dir='$COYO_RAW',
201
+ allow_patterns=[
202
+ 'data/part-00000-*.parquet',
203
+ 'data/part-00001-*.parquet',
204
+ 'data/part-00002-*.parquet',
205
+ 'data/part-00003-*.parquet',
206
+ 'data/part-00004-*.parquet',
207
+ ],
208
+ max_workers=8,
209
  )
210
  print(' Metadata OK')
211
  PYEOF
212
 
213
+ # Filter - top 100K aesthetic images
214
  mkdir -p "$COYO_FILTERED"
215
  python3 -u "$PROJECT_DIR/scripts/data_collection/filter_coyo.py" \
216
  --input-dir "$COYO_RAW/data" \
217
  --output-dir "$COYO_FILTERED" \
218
+ --min-aesthetic 5.5 \
219
+ --min-clip 0.2 \
220
+ --max-watermark 0.7 \
221
+ --max-records 100000
222
 
223
+ # img2dataset - download images
224
  python3 -u -c "
225
  import pandas as pd
226
  df = pd.read_parquet('$COYO_FILTERED/coyo_aesthetic.parquet')
227
  df[['url','text']].rename(columns={'url':'URL','text':'TEXT'}).to_parquet('$SHARD_DIR/_urls.parquet', index=False)
228
+ print(f' {len(df)} URLs ready for download')
229
  "
230
+ log " Running img2dataset (100K images, ~30-60 min)..."
231
  img2dataset \
232
  --url_list "$SHARD_DIR/_urls.parquet" \
233
  --input_format parquet \
 
235
  --caption_col TEXT \
236
  --output_format webdataset \
237
  --output_folder "$SHARD_DIR" \
238
+ --processes_count 4 \
239
+ --thread_count 256 \
240
  --image_size 1024 \
241
  --resize_mode center_crop \
242
  --resize_only_if_bigger True \
243
  --number_sample_per_shard 1000 \
244
+ --retries 3 2>&1 | tail -20
245
 
246
  SHARD_COUNT=$(find "$SHARD_DIR" -name "*.tar" 2>/dev/null | wc -l | tr -d '[:space:]')
247
  SHARD_COUNT=${SHARD_COUNT:-0}
248
+ log " Download complete: $SHARD_COUNT shards"
249
 
250
+ if [ "$SHARD_COUNT" -lt 5 ]; then
251
+ log " FATAL: Too few shards ($SHARD_COUNT)"
252
  exit 1
253
  fi
254
 
255
+ # Upload shards to HF for next run
256
+ log " Uploading shards to HF (for faster resume)..."
257
  python3 -u << PYEOF || true
258
  from huggingface_hub import HfApi, upload_folder
259
  api = HfApi()