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

Stop converting mlmodec files after converted mlpackage files #224

Open
JLCAIYE opened this issue Jul 31, 2023 · 1 comment
Open

Stop converting mlmodec files after converted mlpackage files #224

JLCAIYE opened this issue Jul 31, 2023 · 1 comment

Comments

@JLCAIYE
Copy link

JLCAIYE commented Jul 31, 2023

Hi,
I am using stabilityai/stable-diffusion-2 to test convert a v- prediction model. And I meet a problem that after converting files it stops converting and shows files not found. I did same way one week ago and get mlmodec file successfully. I tried sdv1.5, 2.0-base and 2.0, they have same problem, I am confused where I did wrong.

here is the command : python -m python_coreml_stable_diffusion.torch2coreml --convert-unet --convert-text-encoder --convert-vae-decoder --convert-safety-checker --model-version stabilityai/stable-diffusion-2 -o sd2 --bundle-resources-for-swift-cli --chunk-unet

here is the error:
INFO:main:Saved text_encoder into sd2/Stable_Diffusion_version_stabilityai_stable-diffusion-2_text_encoder.mlpackage
INFO:main:Converted text_encoder
INFO:main:Converting safety_checker
WARNING:main:diffusers pipeline for stabilityai/stable-diffusion-2 does not have a safety_checker module! --convert-safety-checker will be ignored.
INFO:main:Converted safety_checker
INFO:main:Bundling resources for the Swift CLI
INFO:main:Created sd2/Resources for Swift CLI assets
INFO:main:Compiling sd2/Stable_Diffusion_version_stabilityai_stable-diffusion-2_text_encoder.mlpackage
xcrun: error: unable to find utility "coremlcompiler", not a developer tool or in PATH
Traceback (most recent call last):
File "/Users/felix/anaconda3/envs/coreml_stable_diffusion/lib/python3.8/shutil.py", line 791, in move
os.rename(src, real_dst)
FileNotFoundError: [Errno 2] No such file or directory: 'sd2/Resources/Stable_Diffusion_version_stabilityai_stable-diffusion-2_text_encoder.mlmodelc' -> 'sd2/Resources/TextEncoder.mlmodelc'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/felix/anaconda3/envs/coreml_stable_diffusion/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/Users/felix/anaconda3/envs/coreml_stable_diffusion/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/Users/felix/ml-stable-diffusion/python_coreml_stable_diffusion/torch2coreml.py", line 1427, in
main(args)
File "/Users/felix/ml-stable-diffusion/python_coreml_stable_diffusion/torch2coreml.py", line 1294, in main
bundle_resources_for_swift_cli(args)
File "/Users/felix/ml-stable-diffusion/python_coreml_stable_diffusion/torch2coreml.py", line 243, in bundle_resources_for_swift_cli
target_path = _compile_coreml_model(source_path, resources_dir,
File "/Users/felix/ml-stable-diffusion/python_coreml_stable_diffusion/torch2coreml.py", line 214, in _compile_coreml_model
shutil.move(compiled_output, target_path)
File "/Users/felix/anaconda3/envs/coreml_stable_diffusion/lib/python3.8/shutil.py", line 811, in move
copy_function(src, real_dst)
File "/Users/felix/anaconda3/envs/coreml_stable_diffusion/lib/python3.8/shutil.py", line 435, in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "/Users/felix/anaconda3/envs/coreml_stable_diffusion/lib/python3.8/shutil.py", line 264, in copyfile
with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: 'sd2/Resources/Stable_Diffusion_version_stabilityai_stable-diffusion-2_text_encoder.mlmodelc'

@JLCAIYE JLCAIYE changed the title Stop converting mlmodec filesafter converted mlpackage files Stop converting mlmodec files after converted mlpackage files Jul 31, 2023
@jrittvo
Copy link

jrittvo commented Jul 31, 2023

You could try this, because of the xcrun: error: unable to find utility "coremlcompiler", not a developer tool or in PATH line in the above error mesage:

xcrun: error:  unable to find utility "coremlcompiler", not a developer tool or in PATH:
Open Xcode and go to "Settings..." → "Locations" then click on the "Command Line Tools" drop-down menu and reselect the Command Line Tools version

From: https://github.com/godly-devotion/MochiDiffusion/wiki/How-to-convert-Stable-Diffusion-models-to-Core-ML#terminal-errors

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

2 participants