ml4a / ml4a

A python library and collection of notebooks for making art with machine learning.

Home Page:https://ml4a.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unsupported operand type(s) for +: 'NoneType' and 'NoneType' in dataset_utils.py

heaversm opened this issue · comments

Running the following:

python dataset_utils.py --input_src ./img/ --output_dir ./faces/ --save_mode split --action face --w 256 --h 256 --centered --face_crop 0.7

where ./img/ is a directory relative to the script that has jpgs of all images with faces, and ./faces/ is an empty folder on the drive, and ./targetface.jpg is a reference jpg. I get this error:

Traceback (most recent call last):
  File "dataset_utils.py", line 236, in <module>
    main(args)
  File "dataset_utils.py", line 185, in main
    img = img.crop((jx, jy, jx + jw, jy + jh))
TypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType'

Seems to be an issue with this line:

if face_crop is not None:
            jx, jy, jw, jh = get_crop_around_face(img, target_encodings, out_w/out_h, face_crop, face_crop_lerp)
            img = img.crop((jx, jy, jx + jw, jy + jh))

Looks like my values for jx, jy, jw, and jh are all 'None'.

like the other issue, i think this is when it doesn't find a face (either target or one of the frames). i need to add no-face-found handling here.