Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
sdbds committed Nov 11, 2024
1 parent 551d08f commit 7b4a97a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions library/train_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1404,13 +1404,13 @@ def get_image_size(self, image_path):
# 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}")
image_size = (0, 0)
# imagesize doesn't work for some images, so use PIL
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}, {e}")
image_size = (0, 0)
return image_size

def load_image_with_face_info(self, subset: BaseSubset, image_path: str, alpha_mask=False):
Expand Down

0 comments on commit 7b4a97a

Please sign in to comment.