VideoObjectMover / code /transfer /collect_all_old256_inventory.py
FrontRear's picture
Add old 256 transfer and inventory scripts
bb34dc3 verified
Raw History Blame
2.19 kB
"""Remote read-only inventory for the old 256-pair release.
Run via `ssh 6000D ... python -B - < this_script > evidence/file.json`.
It does not edit the training machine, and does not claim an index is usable data.
"""
import json
import pathlib
import re
import sys
base = pathlib.Path('/root/autodl-tmp/LampEditTraining/data_v2')
bbox = base/'bbox_conditions_v003_20261021'
index = json.loads((bbox/'INDEX.json').read_text())
sources = [base/'train_manifest.mixed256.json', base/'train_manifest.new118.json']
groups = index['groups']
sources.extend(pathlib.Path(g['manifest']) for g in groups)
pat_data = re.compile(rb'data_v2/assets/([0-9a-f]{32})')
pat_bbox = re.compile(rb'bbox_v3/assets/([0-9a-f]{32})')
data_ids, bbox_ids = set(), set()
missing = []
for p in sources:
if not p.is_file():
missing.append(str(p))
continue
with p.open('rb') as f:
for line in f:
data_ids.update(x.decode('ascii') for x in pat_data.findall(line))
bbox_ids.update(x.decode('ascii') for x in pat_bbox.findall(line))
# Each factored render can itself point to base data assets and bbox assets.
recipes = 0
for asset in sorted(bbox_ids):
path = bbox/'assets'/asset
if not path.is_dir():
missing.append(str(path))
continue
for recipe in path.rglob('RENDER.json'):
b = recipe.read_bytes()
data_ids.update(x.decode('ascii') for x in pat_data.findall(b))
bbox_ids.update(x.decode('ascii') for x in pat_bbox.findall(b))
recipes += 1
output = {
'scope': 'old 256 manifest and indexed bbox resources; additional dependencies may exist',
'index_groups': len(groups), 'pair_count_in_bbox_index': index.get('pairs'),
'mixed_and_new118_manifests': [str(p) for p in sources[:2]],
'data_asset_ids': sorted(data_ids), 'bbox_asset_ids': sorted(bbox_ids),
'bbox_group_paths': sorted(str(pathlib.Path(g['manifest']).parent.relative_to(base)) for g in groups),
'factored_render_recipes_scanned': recipes, 'missing_source_paths': missing,
'no_512_data_included_by_design': True, 'remote_mutations': False,
}
json.dump(output, sys.stdout, ensure_ascii=False)
sys.stdout.write('\n')