mirror of
https://github.com/kohya-ss/sd-scripts.git
synced 2026-04-06 13:47:06 +00:00
Merge branch 'sd3' into faster-block-swap
This commit is contained in:
@@ -1404,12 +1404,12 @@ class BaseDataset(torch.utils.data.Dataset):
|
||||
# return imagesize.get(image_path)
|
||||
image_size = imagesize.get(image_path)
|
||||
if image_size[0] <= 0:
|
||||
# imagesize doesn't work for some images, so use cv2
|
||||
img = cv2.imread(image_path)
|
||||
if img is not None:
|
||||
image_size = (img.shape[1], img.shape[0])
|
||||
else:
|
||||
logger.warning(f"failed to get image size: {image_path}")
|
||||
# imagesize doesn't work for some images, so use PIL as a fallback
|
||||
try:
|
||||
with Image.open(image_path) as img:
|
||||
image_size = img.size
|
||||
except Exception as e:
|
||||
logger.warning(f"failed to get image size: {image_path}, error: {e}")
|
||||
image_size = (0, 0)
|
||||
return image_size
|
||||
|
||||
|
||||
Reference in New Issue
Block a user