Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Odd GPEN Error - 'mask_sharp' referenced before assignment #14

Closed
indianajson opened this issue Mar 19, 2023 · 11 comments
Closed

Odd GPEN Error - 'mask_sharp' referenced before assignment #14

indianajson opened this issue Mar 19, 2023 · 11 comments

Comments

@indianajson
Copy link

indianajson commented Mar 19, 2023

When running inference.py the following error occurs when Step 5 begins

  File "/inference.py", line 342, in <module>
    main()
  File "/inference.py", line 198, in main
    pred, _, _ = enhancer.process(img, img, face_enhance=True, possion_blending=False)
  File "/third_part/GPEN/gpen_face_enhancer.py", line 116, in process
    mask_sharp = cv2.GaussianBlur(mask_sharp, (0,0), sigmaX=1, sigmaY=1, borderType = cv2.BORDER_DEFAULT)
UnboundLocalError: local variable 'mask_sharp' referenced before assignment

What's likely the cause?

@kunncheng
Copy link
Collaborator

Sorry for the confusing error.
The reason seems to be that one frame in the video fails to detect a face.
The GPEN detection code is here.

@indianajson
Copy link
Author

indianajson commented Mar 19, 2023

Thanks for getting back to me, I bypassed that bit of code and ran into more errors. Eventually, I got an error telling me "a face wasn't detected". I didn't realize that was causing all the issues, thank you for telling me!

In situations like this, what's the best course of action? A different source video?

@kunncheng
Copy link
Collaborator

First you should check if there are any frames in your input video that don't have faces. You should cut out these clips.

In some cases, even though the input video contains full faces, the pre-trained detector still fails to detect them.
In my experience, when the face resolution is too large or the face area proportion is too large, it may not be detected. This may be related to the face detector's training set.

@indianajson
Copy link
Author

The source definitely has a face in every frame, but I think it may be face area proportion. I cropped the video quite a bit for my test and I'll bet that's why it's having trouble.

Thanks so much for your help and fast response. This project is super exciting and I'm anticipating being blown away by my own results... as soon as I get an actual render. 😅

@PanJinquan
Copy link

fix this bug:
mask_sharp = np.zeros((height, width), dtype=np.float32)

@blackjxxx
Copy link

fix this bug: mask_sharp = np.zeros((height, width), dtype=np.float32)

fix this bug: mask_sharp = np.zeros((height, width), dtype=np.float32)

Where to write this line of code

@Jeriousman
Copy link

@PanJinquan Can you specify where to insert that piece of code?

@caidewu
Copy link

caidewu commented Oct 29, 2023

@Jeriousman
微信图片_20231029091000

@Someonetoldme584
Copy link

I cant see the temps ?

@Fillllllllllll
Copy link

@Jeriousman 微信图片_20231029091000

Hi! If i'm using colab version - where should i put this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants