File size: 1,513 Bytes
5bbe62a
eb0ee82
5bbe62a
 
 
 
d0e5423
eb0ee82
ccfa6b3
 
 
eb0ee82
 
5bbe62a
 
ccfa6b3
eb0ee82
5bbe62a
eb0ee82
 
 
 
 
 
5bbe62a
 
 
eb0ee82
5bbe62a
 
 
 
 
 
 
ccfa6b3
 
 
 
5bbe62a
ccfa6b3
 
 
 
 
 
 
 
 
5bbe62a
544fd79
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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])

    # Process skins in parallel using a pool of subprocesses
    # Using 4 workers for fast parallel rendering on Mac
    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()