Known issues - C0untFloyd/roop-unleashed GitHub Wiki

draft. smh for formating

Fixes for Known issues

Many errors are due to versions mismatch, sudden lack of dependencies, or names/paths issues.

Model not found "FileNotFoundError: [Errno 2] No such file or directory:

Sometimes with post-processors, the dynamic path inside the code isn't resolved like it was intended.

Each post-processor has its accordingly-named .py file, which inside has the path to the model file that we change to fix the eventual bug:

For exemple, if its a FileNotFoundError: [Errno 2] No such file or directory: 'models/CLIP/rd64-uni-refined.pth'

Try changing at line 30 in Mask_Clip2Seg.py (in the /roop/processors folder): 'models/CLIP/rd64-uni-refined.pth'

to,

'~/roop-unleashed-main/models/CLIP/rd64-uni-refined.pth'

Or whichever real path according to where you installed. You can copy pathname of a file on MacOS by opt-right-clicking the file and choosing "copy as pathname".

Updating a faceset fails due to permission error.

PermissionError while extracting files from a ZIP archive using the unzip function in our Python application.
The issue was traced back to the mkdir_with_umask function in the roop/utilities.py module.

Inside the roop folder of roop-unleashed, modify utilities.py with this code snippet:

def mkdir_with_umask(directory):
    oldmask = os.umask(000)
    os.makedirs(directory, mode=0o777, exist_ok=True)
    os.umask(oldmask) 

Clip2Seg text masking - MPS Device not supported CPU Fallback

    Error
The operator 'aten::upsample_bicubic2d.out' is not currently implemented for the MPS device. 
If you want this op to be added in priority during the prototype phase of this feature, 
please comment on https://github.com/pytorch/pytorch/issues/77764. 
As a temporary fix, you can set the environment variable `PYTORCH_ENABLE_MPS_FALLBACK=1` 
to use the CPU as a fallback for this op.
    WARNING: this will be slower than running natively on MPS.

On metal accelerated Mac, attempting to run Clip2Seg quickly returns the above error indicating to use CPU as a fallback.
We can use this workaround to fallback to CPU, or tweak the enhancer to make it work on MPS device.

In the terminal, run the command with the environment variable PYTORCH_ENABLE_MPS_FALLBACK=1 before python's roop Unleashed's path, or alternatively export it as a one-off variable:

PYTORCH_ENABLE_MPS_FALLBACK=1 ~/roop-unleashed-main/run.py

or in two commands, the variable affecting current session only:

export PYTORCH_ENABLE_MPS_FALLBACK=1

~/roop-unleashed-main/run.py

Clip2Seg with full MPS metal acceleration

This Pytorch not implemented error can be traced to a year old issue and that's where it stayed, while slowly but steadily, more and more functions are implemented.

Pytorch has a matrix to show what works now https://qqaatw.dev/pytorch-mps-ops-coverage/

Clip2Seg the bicubic upsample is the only function that MPS doesn't understand.

What is bicubic upsample?

Bicubic interpolation is a 2D system of using cubic splines or other polynomial technique that can be used for sharpening and enlarging digital images. 

I say it's a way to resize an image. There other interpolations possible, and not only with Pytorch, Python itself and OpenCV, for exemple, also have tools.

Various other interpolations are implemented in Pytorch: nearest, bilinear, linear, resize.

Replacing everything bicubic in the Clip files worked immediately.

In the clip folder, in clipseg, vitseg and clip files, replace all mentions of bicubic by bilinear.

~/roop-unleashed-main/clip
clipseg.py	vitseg.py	clip.py