awoo
Browse filesSigned-off-by: Balazs Horvath <[email protected]>
scripts/convert-to-16-bit.py
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import glob
|
2 |
+
import os
|
3 |
+
from PIL import Image
|
4 |
+
import multiprocessing as mp
|
5 |
+
|
6 |
+
def convert_image(image_path):
|
7 |
+
try:
|
8 |
+
# Open the image
|
9 |
+
image = Image.open(image_path)
|
10 |
+
|
11 |
+
# Get the image mode
|
12 |
+
mode = image.mode
|
13 |
+
|
14 |
+
# Check if the image depth is higher than 16-bit
|
15 |
+
if mode == 'I;16' or mode == 'I;16L' or mode == 'I;16B':
|
16 |
+
# Image is already 16-bit or lower, skip conversion
|
17 |
+
return
|
18 |
+
|
19 |
+
# Convert the image to 16-bit depth
|
20 |
+
image = image.convert('I')
|
21 |
+
|
22 |
+
# Save the converted image
|
23 |
+
image.save(image_path)
|
24 |
+
print(f"Converted {image_path} to 16-bit.")
|
25 |
+
|
26 |
+
except Exception as e:
|
27 |
+
print(f"Error converting {image_path}: {e}")
|
28 |
+
|
29 |
+
def process_directory(root_dir):
|
30 |
+
# Create a list of image file paths
|
31 |
+
image_files = []
|
32 |
+
for ext in ['.png', '.jpg', '.jpeg']:
|
33 |
+
image_files.extend(glob.glob(os.path.join(root_dir, '**', f'*{ext}'), recursive=True))
|
34 |
+
|
35 |
+
# Create a pool of worker processes
|
36 |
+
pool = mp.Pool(processes=mp.cpu_count())
|
37 |
+
|
38 |
+
# Convert each image in parallel
|
39 |
+
pool.map(convert_image, image_files)
|
40 |
+
|
41 |
+
# Close the pool
|
42 |
+
pool.close()
|
43 |
+
pool.join()
|
44 |
+
|
45 |
+
if __name__ == '__main__':
|
46 |
+
#root_dir = r'E:\training_dir_staging'
|
47 |
+
root_dir = r'E:\training_dir'
|
48 |
+
process_directory(root_dir)
|
tests/realistic-v5-candidate1.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6096f1ec8340c6e5b28421e80e265374b9db1870c26cc6c202d45fe745dcf57f
|
3 |
+
size 240606160
|