-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add support of RealESRGAN for Apple M1 #424
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
Conversation
|
I'll be updating this comment with several tests After the fix, the test works
Test 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ldm/gfpgan/gfpgan_tools.py
Outdated
| '-s', str(upsampler_scale) | ||
| ] | ||
|
|
||
| if upsampler_scale > 2: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be upsampler_scale >= 4 or upsampler_scale > 3 to let 3x upscale without -n realesrgan-x4plus kicking in.
|
Thank you for the review, I appreciate the quick feedback. |
|
The face fixing is supposed to work independently of upscaling. Is this not the case with M1? I won't merge until you give the thumbs up. You might want to convert to a draft to indicate you are still making changes, though! |
@lstein Yes, I agree. Ideally it should be separate, but at least as a last resort we could always use face restoration after upscaling on M1. It's probably a bug somewhere what doesn't let face restoration work on its own, but haven't looked very deeply since @glonlas is on it already. I'm working on doggettx-optimizations for M1 in the meantime. |
That being said I will check and ensure it works (or get fixed). for r in image_list:
image, seed = r
try:
if upscale is not None:
if len(upscale) < 2:
upscale.append(0.75)
image = real_esrgan_upscale(
image,
upscale[1],
int(upscale[0]),
seed,
)
if strength > 0:
image = run_gfpgan(
image, strength, seed, 1
) |
483fb86 to
3a27efe
Compare
UpdateThe last commits fixe:
Test:Test 1: no face restoration, no upscale Test 3: no face restoration, 2x upscale: Test 3: no face restoration, 3x upscale: Test 4: no face restoration, 4x upscale: Test 5: face restoration, no upscale: Test 6: face restoration, 2x upscale: Test 7: face restoration, 3x upscale: Test 8: face restoration, 4x upscale |
|
Okay, finally got it to work. The error I was getting when running GFPGAN was the following MKL? Tried And sure enough, I had the bad architecture. How/when/why, I do not know. I decided to set up my environment to use osx-arm64, but I couldn't get away with setting So I re-create the environment from scratch: Now, on to setting up GFPGAN. The environment is set up, but because So I had to revert to 1.12.1 |
Any-Winter-4079
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a note on architecture and GFPGAN, I seemingly had to switch to arm64 to run it successfully (while this repo can run with x86 or arm64).
Maybe it was just that my computer that was messed up, but if more people experience the same (can't run GFPGAN, need to switch to arm64), we could potentially update the instructions in the future.
For now, I've tested it and it works. I think it can be merged, although it would be good if @lstein could run it to make sure it still works on CUDA (it should, no change was made).
Awesome job!
|
just followed your instructions from above and face resto works!, what doesn't for me is still when trying to upscale the image. I get the following error: Real-ESRGAN Upscaling seed:25490825 : scale:2x
|
|
@Vrk3ds Do you have a With that and the 2 files modified in this PR, using the development branch, it should work. Let me know! |
I don’t have realesgran in a separate directory just in the stable-diffusion one. I’ll move it and test and let you know |
hmmm I am still getting the same error? this is my folder setup now?Does that look correct? |
|
with the model/s inside and I assume with the arm64 environment activated (e.g. If you have all of this let me know. |
|
not sure what was borked but I manually cut and pasted that code into those two files and now everyone is working! Thank You! |
Yep, that's what I did. Glad it worked! |
|
Just want to confirm that this pull request works for me on Macbook Air M1. I checked out the branch from @Vrk3ds @Any-Winter-4079 Problem might have been that you checked out the |
|
Will test this later today. |
|
I will also catchup on the thread today. |
|
If no other concerns, I recommend to +1 and merge so we can move forward and have upscale working on M1 as well :) |
|
Confirmed working on M1, thanks! |
a7b95d0 to
342ffa0
Compare
|
@lstein shall we merge it? |
342ffa0 to
a5d51bc
Compare
|
@lstein @Any-Winter-4079 I am closing this PR as the implementation is too complex while a simpler solution is possible. This PR propose a better implementation, but need a better refactoring. |







This PR:
README-Mac-MPS.mdto add commands to install Real ESRGAN for M1 users.gfpgan/in.gitignoreto avoid pushing GFPGAN model weightsTest
This PR has been manually tested to generate x2 and x4 upscaling via Real ESRGAN, with and without GFPGAN.