rotemtzaban / STIT

MIT License
1.2k stars 170 forks source link

TypeError: cannot unpack non-iterable NoneType object #9

Open hnudagger opened 2 years ago

hnudagger commented 2 years ago

File "./utils/alignment.py", line 111. The function "compute_transform" returns None if "lm is None". However, in line 53, and line 157, it need return "c, x, y". It will get NoneType object error.

rotemtzaban commented 2 years ago

@hnudagger This error is caused by the face detector failing to find a face in one of the frames. It might be a result of the video containing some extreme poses. You can try to solve it by replacing the face detector, by adding --use_fa to the command. However, in my experience, the generator also doesn't do well on poses where the alignment fails, So there's a good chance the results wouldn't look great.

rotemtzaban commented 2 years ago

As for the unclear message, I'll make sure to fix that and give a clearer error

Infinitay commented 2 years ago

I came across this issue and simply put compute_transform within a try...except and passed on exception.

Reckon skipping some frames would cause any issues? I also noticed that sometimes it would skip a very identical frame due to not detecting a face, but would work just fine in the next frame.

rotemtzaban commented 2 years ago

@Infinitay Unfortunately I don't think that skipping frames with the current code would work. The editing script assumes that all frames are used, so it would cause a mismatch between the background and the face.

I would assume that the skipped frames are a result of a threshold, and that the next frame passes it closely. I have not tried it myself, but it is possible to control that threshold, as shown here: http://dlib.net/face_detector.py.html Alternatively, using --use_fa gives a better detection rate, without changes in code.

rotemtzaban commented 2 years ago

By the way, just to make sure, are the skipped frames forward facing? Or are they looking more to the sides/up/down?

Infinitay commented 2 years ago

By the way, just to make sure, are the skipped frames forward facing? Or are they looking more to the sides/up/down?

The face is tilted sideways looking down. However there are multiple frames like it and it detects a face just fine. Not too big of an issue. I am testing it out on a video that probably isn't the best for this as the subject isn't sitting still as in the examples.

hnudagger commented 2 years ago

@hnudagger This error is caused by the face detector failing to find a face in one of the frames. It might be a result of the video containing some extreme poses. You can try to solve it by replacing the face detector, by adding --use_fa to the command. However, in my experience, the generator also doesn't do well on poses where the alignment fails, So there's a good chance the results wouldn't look great.

Thanks. And I saw your new commit. If no face is in an image, it will raise Exception(f'Did not detect any faces in image: {filepath}'). How about this one? When no face in image, the code doesn't do anything but return the origin image. Does it work? Thank you.