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

Can't convert extra models after git pull #432

Closed
FinecoFinit opened this issue Dec 13, 2023 · 6 comments
Closed

Can't convert extra models after git pull #432

FinecoFinit opened this issue Dec 13, 2023 · 6 comments
Assignees
Labels
scope/convert status/fixed issues that have been fixed and released type/bug broken features
Milestone

Comments

@FinecoFinit
Copy link

Traceback (most recent call last):
  File "D:\@home\fifi\Documents\onnx-web\api\onnx_web\convert\__main__.py", line 443, in convert_models
    convert_model_diffusion(conversion, model)
  File "D:\@home\fifi\Documents\onnx-web\api\onnx_web\convert\__main__.py", line 263, in convert_model_diffusion
    converted, dest = converter(
  File "D:\@home\fifi\Documents\onnx-web\api\onnx_env\lib\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "D:\@home\fifi\Documents\onnx-web\api\onnx_web\convert\diffusion\diffusion.py", line 406, in convert_diffusion_diffusers
    optimize_pipeline(conversion, pipeline)
UnboundLocalError: local variable 'pipeline' referenced before assignment

Rolling back to e91e084 fixed the thing

@FinecoFinit FinecoFinit changed the title Can't convert extra modeles after git pull Can't convert extra models after git pull Dec 14, 2023
@ssube ssube self-assigned this Dec 15, 2023
@ssube ssube added status/new issues that have not been confirmed yet type/bug broken features scope/convert labels Dec 15, 2023
@ssube
Copy link
Owner

ssube commented Dec 15, 2023

Do you mind sharing the extra model entry that caused this error? Was the source a file or a link of some kind?

I recently refactored some of this code, but I didn't change the logic around loading the pipeline. However, I do see one codepath with a missing else:

image

That should only happen if the path exists but is not a directory or file. If that code is not handling symlinks/hardlinks correctly, I should be able to fix that.

Edit: I adjusted the logic to load everything that is not a directory as a tensor/checkpoint file. That might be an issue if you have a link from a folder to a folder, I'll have to set up some tests for that.

@ssube ssube added status/progress issues that are in progress and have a branch and removed status/new issues that have not been confirmed yet labels Dec 15, 2023
@ssube ssube added this to the v0.11 milestone Dec 15, 2023
@FinecoFinit
Copy link
Author

FinecoFinit commented Dec 16, 2023

@ssube
Well, after latest git pull and huggingface-hub==0.19.4 install I can't download from civitai, even if I have files in .cache.
Relative paths also doesn't work on windows:
"source": "../models/.cache/diffusion-*.safetensors"

@ssube
Copy link
Owner

ssube commented Dec 16, 2023

Is diffusion-*.safetensors a specific filename or meant to be a wildcard? The source field doesn't have any support for wildcards, if the latter. I'm not sure if Python translates slashes, so for Windows that might also need to use backslashes, like "..\\models\\.cache\\diffusion-model.safetensors".

I tested downloading from civitai and converting, and that seems to work correctly:

Screenshot from 2023-12-16 06-27-26

Are you getting an error message in the logs, does the file not download, or what is happening? If you are getting an error, please include that here.

@FinecoFinit
Copy link
Author

@ssube

[2023-12-16 20:25:58,291] INFO: MainProcess MainThread onnx_web.convert.diffusion.diffusion: converting Stable Diffusion model diffusion-domesticated-v1-5: civitai://188101?type=Model&format=SafeTensor&size=pruned&fp=fp16 -> ..\models\diffusion-domesticated-v1-5/
[2023-12-16 20:25:58,523] ERROR: MainProcess MainThread __main__: error converting diffusion model diffusion-domesticated-v1-5
Traceback (most recent call last):
  File "D:\@home\fifi\Documents\onnx-web\api\onnx_web\convert\__main__.py", line 443, in convert_models
    convert_model_diffusion(conversion, model)
  File "D:\@home\fifi\Documents\onnx-web\api\onnx_web\convert\__main__.py", line 263, in convert_model_diffusion
    converted, dest = converter(
  File "D:\@home\fifi\Documents\onnx-web\api\onnx_env\lib\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "D:\@home\fifi\Documents\onnx-web\api\onnx_web\convert\diffusion\diffusion.py", line 372, in convert_diffusion_diffusers
    pipeline = download_from_original_stable_diffusion_ckpt(
  File "D:\@home\fifi\Documents\onnx-web\api\onnx_env\lib\site-packages\diffusers\pipelines\stable_diffusion\convert_from_ckpt.py", line 1252, in download_from_original_stable_diffusion_ckpt
    checkpoint = safe_load(checkpoint_path_or_dict, device="cpu")
  File "D:\@home\fifi\Documents\onnx-web\api\onnx_env\lib\site-packages\safetensors\torch.py", line 308, in load_file
    with safe_open(filename, framework="pt", device=device) as f:
FileNotFoundError: No such file or directory: "civitai://188101?type=Model&format=SafeTensor&size=pruned&fp=fp16"

@ssube
Copy link
Owner

ssube commented Dec 16, 2023

Excellent, thank you. I was able to reproduce the error using that stack trace and the right combination of params (it only happens when the options are set to extract torch models).

I pushed a change that fixes it on my machine, please try it again when you have a chance.

@FinecoFinit
Copy link
Author

@ssube tested, problem resolved

@ssube ssube added status/fixed issues that have been fixed and released and removed status/progress issues that are in progress and have a branch labels Dec 16, 2023
@ssube ssube closed this as completed Dec 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope/convert status/fixed issues that have been fixed and released type/bug broken features
Projects
None yet
Development

No branches or pull requests

2 participants