| import os |
| from functools import partial |
| import sys |
| import subprocess |
| from concurrent.futures import ThreadPoolExecutor |
|
|
| output_dir = 'target_imgs_v95' |
|
|
| def process_skin(skin_id): |
| input_path = f'skins/{skin_id}.png' |
| output_path = f'{output_dir}/{skin_id}.png' |
|
|
| os.makedirs(os.path.dirname(output_path), exist_ok=True) |
|
|
| if not os.path.exists(output_path): |
| print(f"Starting process for skin: {skin_id}") |
|
|
| result = subprocess.run( |
| [ |
| sys.executable, |
| 'build_target_img.py', |
| input_path, |
| output_path, |
| ], |
| capture_output=True, |
| text=True |
| ) |
|
|
| if result.returncode == 0: |
| print(f"Successfully processed: {skin_id}") |
| else: |
| print(f"Error processing skin {skin_id}:") |
| print(result.stderr or result.stdout) |
| def main(): |
| os.makedirs(output_dir, exist_ok=True) |
| iset = set() |
| for id in os.listdir('skins'): |
| if id.endswith('.png') and not id.startswith('.'): |
| iset.add(id.split('.')[0]) |
|
|
| |
| |
| max_workers = 4 |
| print(f"Processing {len(iset)} skins using {max_workers} parallel workers...") |
| with ThreadPoolExecutor(max_workers=max_workers) as executor: |
| executor.map( |
| process_skin, |
| sorted(list(iset)) |
| ) |
| if __name__ == '__main__': |
| main() |
|
|