apple / ml-stable-diffusion

Stable Diffusion with Core ML on Apple Silicon
MIT License
16.46k stars 886 forks source link

Stop converting mlmodec files after converted mlpackage files #224

Open JLCAIYE opened 11 months ago

JLCAIYE commented 11 months ago

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'

jrittvo commented 11 months ago

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