File size: 1,829 Bytes
5bbe62a
eb0ee82
5bbe62a
 
 
 
544fd79
eb0ee82
 
 
 
 
 
5bbe62a
 
eb0ee82
 
5bbe62a
eb0ee82
 
 
 
 
 
5bbe62a
 
 
eb0ee82
5bbe62a
 
 
 
 
 
 
eb0ee82
 
 
 
 
 
 
 
 
5bbe62a
eb0ee82
 
 
 
 
 
 
 
 
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
53
54
55
56
57
import os
from functools import partial
import sys
import subprocess
from concurrent.futures import ThreadPoolExecutor

output_dir = 'target_imgs_v92'

def process_skin(skin_id, skin_style):
    input_path = f'skins/{skin_style}/{skin_id}.png'
    output_path = f'{output_dir}/{skin_style}/{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}, style: {skin_style}...")

        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)
    for skin_style in os.listdir('skins'):
        if skin_style.startswith('.'):
            continue
        if skin_style != 'lowpoly':
            continue
        iset = set()
        for i in os.listdir(f'skins/{skin_style}'):
            if i.endswith('.png') and not i.startswith('.'):
                iset.add(i.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(
                partial(process_skin, skin_style=skin_style),
                sorted(list(iset))
            )
if __name__ == '__main__':
    main()