Stable Diffusion (AIã¯ã©ããã£ãŠçµµãæãã®ã§ãã)
AIã¯ãå
¥åãããããã¹ããããšã«ã¢ãŒããæãããšãã§ããŸãã
ããã¯ãStable Diffusion
ãšããæ©æ¢°åŠç¿ã¢ãã«ã䜿ãããšã§å¯èœã«ãªããŸããã
Stable Diffusion
ã¯ã2022幎ã«çºè¡šããã ãã£ãŒãã©ãŒãã³ã° (Deep Learning) ã«ãã
ããã¹ãããç»åãžã®å€æã¢ãã«ã§ãã
ãã®ã¢ãã«ã§äœ¿ããããŒã«ã¯Pythonã ãã§ããã
ãããŠéåžžãAppleãã©ãããã©ãŒã ã§å®è¡ããããã«æé©åãããŠããŸããã§ãã
ïŒäŸãã°ãApple Neural Engineã¯äœ¿çšããŸããïŒ
ç»è³ªã¯ãããã§ããïŒ
è¯ãå ŽåããããŸãã
ããã§ãªããšããããã
ãã£ã©ã¯ã¿ãŒããããèæ¯ç»ãç°å¢ãæãã®ã«åããŠãããšæããŸãã
è€æ°ã®ãªããžã§ã¯ããæããããšããã®ãã¡ã®äžã€ããæããªãããšããããŸãã
ãŸããæåã®å
¥åãäžéšç¡èŠããããšããããŸãã
ç 究çšãã¢ãŒãã£ã¹ãã®èæ¯ç»äœæçšãã¢ã€ãã¢åºãçšãªã©ã«åããŠãããšæããŸãã
ææããè¶
ããããšã¯ã§ããªããšæããŸãã
CoreMLããŒã«
2022幎12æãApple㯠Stable Diffusion
ã CoreML ã¢ãžã¥ãŒã«ã«å€æããããŒã«ãçºè¡šããŸããã
å€æåŸã®ã¢ãžã¥ãŒã«ã¯ãiOSãšMacOSã§çŽæ¥äœ¿çšããããšãã§ããŸãã
ç°å¢ã«ã€ããŠ
M1ãããæèŒã®iPad Proã§ãææ°ã®MacOSïŒmacOS Ventura 13.1ïŒãšææ°ããŒãžã§ã³ã®iOS (16.1) ã䜿çšããŠãã¢ãã«å€æãšç»åçæãå®è¡ããããšãæšå¥šããŠããŸãã
æ¢åã®ã¢ãã«ãCore MLã«å€æãã
Pythonã䜿ã£ãŠæ¢åã® Stable Diffusion
ã¢ãã«ã CoreMLããã±ãŒãžãžå€æããŸãã
ãããã®ã¢ãã«ãèªåã§å€æããããªãå Žåã¯ã
Appleãæ¢ã«å€æããŠãããã®ã䜿çšããããšãã§ããŸã
次ã®ã»ã¯ã·ã§ã³ Appleã®å€ææžã¿ã¢ãã«ããããŠã³ããŒããã
ããèªã¿ãã ããã
ç°å¢èšå®
ãŸããAnaConda
ãŸã㯠MiniConda
ãã€ã³ã¹ããŒã«ããŸãã
bashã¹ã¯ãªãããã¡ã€ã«ïŒã€ã³ã¹ããŒã©ã®ãã€ããªãå«ãïŒãããŠã³ããŒããããããå®è¡ããŸãã
ãŸããã€ã³ã¹ããŒã©ãããŠã³ããŒãããŸã:
MacOSã§ã¯
cd ~/Downloads
# M1
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh
# Intel
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
ãã®åŸãã€ã³ã¹ããŒã«ã¹ã¯ãªãããå®è¡ããŸãã
chmod +x Miniconda3-latest-MacOSX-arm64.sh
bash Miniconda3-latest-MacOSX-arm64.sh
äžæŠã¿ãŒããã«ãéããå床éããå€æŽãåæ ãããŸãã
ãã®åŸïŒCoreMLããŒã«ã®ç°å¢ãæ§ç¯ããŸãã
conda create -n coreml_stable_diffusion python=3.8 -y
conda activate coreml_stable_diffusion
CoreML ããŒã«ã䜿ããšãããããã¯ãã®ç°å¢ã«æ°ããããã±ãŒãžãã€ã³ã¹ããŒã«ãããšãã¯ã
å¿
ã conda activate coreml_stable_diffusion
ãå®è¡ããŠç°å¢ãåãæ¿ããŠãã ããã
ã¿ãŒããã«è¡ã®æåã«çŸåšã®ç°å¢ã衚瀺ãããŸãã
(base) test@MacBook-Pro ~ % conda activate coreml_stable_diffusion
(coreml_stable_diffusion) test@MacBook-Pro ~ %
(base)
--------> (coreml_stable_diffusion)
ãªããŸãã
Apple Core MLå€æããŒã«ã®ããã±ãŒãžã clone
ããŠæºåããŸãã
git clone https://github.com/apple/ml-stable-diffusion.git
cd ml-stable-diffusion
pip3 install -e .
äžèšã³ãã³ããå®è¡ããéãæ£ããç°å¢ã衚瀺ãããŠããããšã確èªããŠãã ãã `(coreml_stable_diffusion)`
(coreml_stable_diffusion) test@MacBook-Pro ~ % git clone https://github.com/apple/ml-stable-diffusion.git
(coreml_stable_diffusion) test@MacBook-Pro ~ % cd ml-stable-diffusion
(coreml_stable_diffusion) test@MacBook-Pro ~ % pip3 install -e .
ãã®ä»å¿
èŠãªå·¥å
· (git-lfs
, sentencepiece
, rust
) ãæºåããŸãã
brew install git-lfs
git lfs install
pip3 install sentencepiece
curl https://sh.rustup.rs -sSf | sh
pip3 install huggingface_hub
äžèšã³ãã³ããå®è¡ããéãæ£ããç°å¢ã衚瀺ãããŠããããšã確èªããŠãã ãã `(coreml_stable_diffusion)`
(coreml_stable_diffusion) test@MacBook-Pro ~ % pip3 install sentencepiece
(coreml_stable_diffusion) test@MacBook-Pro ~ % pip3 install huggingface_hub
Apple CoreMLããŒã«ã§ãµããŒãããã torch
ã®ææ°ããŒãžã§ã³ã¯2.0.0ã§ãã
Torch version 2.1.0.dev20230411 has not been tested with coremltools. You may run into unexpected errors. Torch 2.0.0 is the most recent version that has been tested.
pip3 install torch==2.0.0
äžèšã³ãã³ããå®è¡ããéãæ£ããç°å¢ã衚瀺ãããŠããããšã確èªããŠãã ãã `(coreml_stable_diffusion)`
(coreml_stable_diffusion) test@MacBook-Pro ~ % pip install torch==2.0.0
HuggingFace.co
Stable Diffusion
ã®ã¢ãã«ãã¡ã€ã«ã¯ Hugging Face
ã«æ ŒçŽãããŠããŸãã
ãŸããAppleã®CoreMLããŒã«ã¯ãHuggingFace.co
ããã¢ãã«ãååŸããŸãã
HuggingFace.co
ã«ã¢ã«ãŠã³ããç»é²ãã次ã®ãªã³ã¯ã䜿ã£ãŠã¢ã¯ã»ã¹ããŒã¯ã³ãçæããå¿
èŠããããŸã:
https://huggingface.co/settings/tokens
ãã®åŸã以äžã®ã³ãã³ããå®è¡ããŠãµã€ã³ã€ã³ããŠãã ããã
huggingface-cli login
æ¢åã®ã¢ãã«ãå€æãã
ç°å¢ã coreml_stable_diffusion
ã§ãããclone
ãã ml-stable-diffusion
ã®ãã£ã¬ã¯ããªã«ããããšã確èªããŠãã ããã
ã¢ãã«ID(hugging face websiteã®ãªããžããªID)ãæå®ããŠã以äžã®ã³ãã³ããå®è¡ããŸãã
python -m python_coreml_stable_diffusion.torch2coreml --convert-vae-decoder -o <output-mlpackages-directory> --bundle-resources-for-swift-cli --attention-implementation SPLIT_EINSUM --model-version CompVis/stable-diffusion-v1-4
python -m python_coreml_stable_diffusion.torch2coreml --convert-unet -o <output-mlpackages-directory> --bundle-resources-for-swift-cli --attention-implementation SPLIT_EINSUM --model-version CompVis/stable-diffusion-v1-4
python -m python_coreml_stable_diffusion.torch2coreml --convert-text-encoder -o <output-mlpackages-directory> --bundle-resources-for-swift-cli --attention-implementation SPLIT_EINSUM --model-version CompVis/stable-diffusion-v1-4
python -m python_coreml_stable_diffusion.torch2coreml --convert-safety-checker -o <output-mlpackages-directory> --bundle-resources-for-swift-cli --attention-implementation SPLIT_EINSUM --model-version CompVis/stable-diffusion-v1-4
äžèšã³ãã³ããå®è¡ããéãæ£ããç°å¢ã衚瀺ãããŠããããšã確èªããŠãã ãã `(coreml_stable_diffusion)`
(coreml_stable_diffusion) test@MacBook-Pro ~ % python -m python_coreml_stable_diffusion.torch2coreml --convert-vae-decoder -o <output-mlpackages-directory> --bundle-resources-for-swift-cli --attention-implementation SPLIT_EINSUM --model-version CompVis/stable-diffusion-v1-4
(coreml_stable_diffusion) test@MacBook-Pro ~ % python -m python_coreml_stable_diffusion.torch2coreml --convert-unet -o <output-mlpackages-directory> --bundle-resources-for-swift-cli --attention-implementation SPLIT_EINSUM --model-version CompVis/stable-diffusion-v1-4
(coreml_stable_diffusion) test@MacBook-Pro ~ % python -m python_coreml_stable_diffusion.torch2coreml --convert-text-encoder -o <output-mlpackages-directory> --bundle-resources-for-swift-cli --attention-implementation SPLIT_EINSUM --model-version CompVis/stable-diffusion-v1-4
(coreml_stable_diffusion) test@MacBook-Pro ~ % python -m python_coreml_stable_diffusion.torch2coreml --convert-safety-checker -o <output-mlpackages-directory> --bundle-resources-for-swift-cli --attention-implementation SPLIT_EINSUM --model-version CompVis/stable-diffusion-v1-4
-o <output-mlpackages-directory>
ã¯ã¢ãã«ã®åºåå
ãã£ã¬ã¯ããªã§ãïŒäŸãã° /User/<åå>/Downloads/ConvertedModel
--bundle-resources-for-swift-cli
ã¯ãMLããã±ãŒãžãã¡ã€ã«ãã³ã³ãã€ã«ããSwiftã¢ããªã±ãŒã·ã§ã³ã§äœ¿çšã§ããããã«ããããšãããŒã«ã«äŸé ŒããŸããå®è¡ãããšã.mlmodelc
ãã¡ã€ã«ãçæãããmerges.txt
ãã¡ã€ã«ãšèªåœã® JSON
ãã¡ã€ã«ãããŠã³ããŒããããŸãã
--attention-implementation SPLIT_EINSUM
ã¯ãCPUãšGPUã ãã§ãªããApple Neural Engineãã¢ãŒãçæåŠçã«äœ¿çšã§ããããã«ã¢ãŒããèšå®ããŸãã
--model-version CompVis/stable-diffusion-v1-4
ã¯ã䜿çšããã¢ãã«ãæå®ããŸãã
ãã䜿ããããªããžããª
--model-version runwayml/stable-diffusion-v1-5
:
--model-version stabilityai/stable-diffusion-2
:
--model-version CompVis/stable-diffusion-v1-4
:
--model-version stabilityai/stable-diffusion-2-1
:
äžèšã¢ãã«ã¯è±èªå ¥åã«ã®ã¿å¯Ÿå¿ããŠããŸãã
æ¥æ¬èªã¢ãã«ã«ã€ããŠ
æ¥æ¬ã®ã¢ãã«ããããŸãã
--model-version rinna/japanese-stable-diffusion
ã§ãã
ããããjapanese-stable-diffusion
ãCore MLããã±ãŒãžã«å€æããéã«ã
ããã¹ããšã³ã³ãŒããŒãµã€ãºã«é¢ãããšã©ãŒïŒtorch2coreml.py
ã®Pythonã³ãŒãå
㧠sample_text_encoder_inputs
ã®åæåé¢æ°ãå€æŽããæåã§æ倧ãµã€ãºã77ã«èšå®ããŸããïŒã
ãŸããã»ãŒããã£ãã§ãã«ãŒã®å
¥åç»åãµã€ãºã«é¢ããåé¡ïŒAppleã®ã³ã³ãã€ã«æžã¿ãªããžããªCompVis/stable-diffusion-v1-4ã®ã»ãŒããã£ãã§ãã«ãŒã«çœ®ãæããããŸããããŸããïŒãçºçããããã€ãã®åé¡ã«çŽé¢ããŸããã
ããããããç§ã®èšå®ã«åé¡ãããã®ãããããŸããããããã«èª¿ã¹ãŠåŸæ¥ãã®èšäºãæŽæ°ããããšæããŸãã
ã³ã³ãã€ã« (compile) æžã¿çµæ
ã¢ãã«ã®ã³ã³ãã€ã«ãæåãããšãåºåãã©ã«ãã«ä»¥äžã®ãããªæ§é ã衚瀺ãããã¯ãã§ãã
䜿çšãããã¡ã€ã«ã¯ /compiled
ãã©ã«ãå
ã«ãããŸãã
Appleã®å€ææžã¿ã¢ãã«ããããŠã³ããŒã
Appleã¯ãã§ã«ããã€ãã®ã¢ãã«ãCore MLã®ããã±ãŒãžåœ¢åŒã«å€æããŠããŸãã
cloneã³ãã³ãã§ããŠã³ããŒãããããšãã§ããŸãã
git clone https://huggingface.co/apple/coreml-stable-diffusion-v1-5
huggingface.coã¢ã«ãŠã³ãã®ãŠãŒã¶ãŒåãšããŒã¯ã³ãå
¥åããããèŠæ±ãããŸãã
Hugging Face
ã®ãŠã§ããµã€ãã«ã¢ã«ãŠã³ããç»é²ãã次ã®ãªã³ã¯ã䜿ã£ãŠã¢ã¯ã»ã¹ããŒã¯ã³ãçæããå¿
èŠããããŸã:
https://huggingface.co/settings/tokens
倧ããªãã¡ã€ã«ãããŠã³ããŒããããããå€å°æéãããããããããŸããã
å©çšå¯èœãªãªããžããª
git clone https://huggingface.co/apple/coreml-stable-diffusion-v1-4
https://huggingface.co/apple/coreml-stable-diffusion-v1-5
https://huggingface.co/apple/coreml-stable-diffusion-2-base
äžèšæ©çš®ã¯è±èªå ¥åã«ã®ã¿å¯Ÿå¿ããŠããŸãã
Git LFS (倧容éãã¡ã€ã«ã·ã¹ãã ) ã䜿ã£ãŠãã¹ãŠã®ãã¡ã€ã«ãããŠã³ããŒãããŸãïŒãµã€ãºã倧ããã§ãïŒã
git cloneããåŸãsplit_einsum/compiled
ãã©ã«ãã«ã䜿çšãããã¡ã€ã«ãé
眮ãããŸãã
åãã¡ã€ã«ãåå¥ã«ããŠã³ããŒã
ãŸããGIT_LFS_SKIP_SMUDGE=1
ãšãããã¬ãã£ãã¯ã¹ã䜿ã£ãŠã倧ããªãã¡ã€ã«ãžã®ãã€ã³ã¿ã ããã¯ããŒã³ããåãã¡ã€ã«ãåå¥ã«ããŠã³ããŒãããããšãã§ããŸãã
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/apple/coreml-stable-diffusion-v1-5
git lfs pull --include split_einsum/compiled/Unet.mlmodelc
git lfs pull --include split_einsum/compiled/VAEDecoder.mlmodelc
# ... çžå¯Ÿãã¹ãæå®ããŠä»ã®ãã¡ã€ã«ãããŠã³ããŒããã ...
ãã¡ã€ã«æ§æ
ã³ã³ãã€ã«ãã¡ã€ã« compiled
ãš ããã±ãŒãžãã¡ã€ã« packages
ã®æ¯èŒ
ããã±ãŒãžãã¡ã€ã«ã¯Pythonã«é©ããŠããŸããã
Swiftã®ã³ãŒãã«ã¯ã³ã³ãã€ã«çãå¿
èŠã§ãã
ãªãªãžãã« original
ãš split_einsum
ã®æ¯èŒ
split_einsum
ã¯Appleã«ãã£ãŠå°å
¥ããã
ãã¹ãŠã®ã³ã³ãã¥ãŒããŠãããïŒCPUãGPUãAppleã®Neural EngineïŒãšäºææ§ããããŸãã
original
ã¯ãCPUãšGPUã«ã®ã¿å¯Ÿå¿ããŠããŸãã
ãšã¯ãããããã€ã¹ã«ãã£ãŠã¯ split_einsum
ããã original
ã®æ¹ãé«éã«ãªãããšããããŸãã
Pythonã䜿ã£ãŠç»åãçæãã
python -m python_coreml_stable_diffusion.pipeline --prompt "beautiful night sky, a lot of stars, beautiful, fantancy, vivid, colorful, meteor" -i <output-mlpackages-directory> -o </path/to/output/image> --compute-unit CPU_AND_NE --seed 93 --model-version CompVis/stable-diffusion-v1-4
äžèšã³ãã³ããå®è¡ããéãæ£ããç°å¢ã衚瀺ãããŠããããšã確èªããŠãã ãã `(coreml_stable_diffusion)`
ãŸããã¯ããŒã³ããgitãã£ã¬ã¯ããªã®äžã«ããããšã確èªããŠãã ããã
(coreml_stable_diffusion) test@MacBook-Pro ~ % python -m python_coreml_stable_diffusion.pipeline --prompt "beautiful night sky, a lot of stars, beautiful, fantancy, vivid, colorful, meteor" -i <output-mlpackages-directory> -o </path/to/output/image> --compute-unit CPU_AND_NE --seed 93 --model-version CompVis/stable-diffusion-v1-4
--prompt "beautiful night sky, a lot of stars, beautiful, fantancy, vivid, colorful, meteor"
ã¯ãã¢ãŒãã®AIãæãããã®èª¬ææãšããŠã®ããã¹ãã§ãã
-i <output-mlpackages-directory>
㯠.mlpackage
ãã¡ã€ã«ãæ ŒçŽãããã£ã¬ã¯ããªã§ããAppleãããªããžããªãã¯ããŒã³ããå Žåã¯ã/original/packages
ãã©ã«ãã«ãªããŸãã
--seed 93
: ããã¯ã©ã³ãã ãªæŽæ°å€ã§ããåãä¹±æ°ã䜿ããšãAIã¯ïŒåãã¢ãã«ã«å¯ŸããŠïŒåãã¢ãŒããçæããå¯èœæ§ãé«ãã§ããç°ãªãç»åãçæãããå Žåã¯ãä¹±æ°ã䜿çšããŠãã ããã
--compute-unit
ã¯ãã³ã³ãã¥ãŒã¿ã«ååãªã¡ã¢ãªãããå Žåã¯ALLã«ããããšãã§ããŸããããã§ãªãå Žå㯠CPU_AND_NE
ã«èšå®ãããšCPUãšãã¥ãŒã©ã«ãšã³ãžã³ã®ã¿ã䜿çšããããšãã§ããŸãã
--model-version CompVis/stable-diffusion-v1-4
ã¯äœ¿çšããã¢ãã«ã®ãªããžããªIDã§ãã
Swiftã䜿ã£ãŠç»åãçæãã
ãŸãã空ã®Swift MacOSã¢ããªã±ãŒã·ã§ã³ãäœæããŸãã
ãŸãã¯MacOSã§ã¢ãã«çæåŠçãè©ŠããŠã¿ãŠãã ããã
Swiftããã±ãŒãžã®ã€ã³ããŒã
Xcodeå
ã§ãFile
ã¡ãã¥ãŒãã¯ãªãã¯ããAdd Packages
ãã¯ãªãã¯ããŸãã以äžã®ããã±ãŒãžãã€ã³ããŒãããŸãã
https://github.com/apple/ml-stable-diffusion.git
Swiftã®ã³ãŒãå
ã§ãStableDiffusion
ãã€ãã©ã€ã³ ãã¬ãŒã ã¯ãŒã¯ïŒSwiftããã±ãŒãžå
ïŒãšã
CoreML
ãã¬ãŒã ã¯ãŒã¯ãã€ã³ããŒãããŸãã
import CoreML
import StableDiffusion
èšç®è£ 眮ã®æ±ºå®
èšç®è£
眮㯠MLComputeUnits
ãšããŠå®çŸ©ãããŠããã®ã§ããããèšå®ããŸãã
.all
: ãã¹ãŠã®èšç®è³æºã䜿çšããŸãã
.cpuOnly
: CPUã®ã¿ã䜿çšãããã¯æãé
ããªãã·ã§ã³ã§ãã
.cpuAndGPU
ã¯CPUãšGPUã䜿çšãããã€ãšã³ãGPUæ§æã®MacBookã§ã¯é«éã«ãªããŸãã
.cpuAndNeuralEngine
ã¯ãCPUãšAppleã®Neural Engineãããã䜿çšããŸããiOSïŒiPhoneãiPadïŒã§äœ¿çšããå Žåã¯ãã®ãªãã·ã§ã³ã«ãªããŸãã
let config = MLModelConfiguration()
config.computeUnits = .cpuAndNeuralEngine
ãªãœãŒã¹ãã£ã¬ã¯ããª
次ã«ããªãœãŒã¹ãã©ã«ããžã®URLãå«ããã€ãã©ã€ã³ãªããžã§ã¯ããäœæããŸãããªãœãŒã¹ãã©ã«ãã«ã¯ã以äžã®ãã®ãå«ãŸããã¯ãã§ãã
- merges.txt
- SafetyChecker.mlmodelcïŒãªãã·ã§ã³ãåºåç»åã«NSFWã³ã³ãã³ãããã§ãã¯ããããå Žåã¯ããã®ãã¡ã€ã«ãå«ããŸã)
- TextEncoder.mlmodelcïŒããã¹ããšã³ã³ãŒããŒïŒã
- Unet.mlmodelc
- VAEDecoder.mlmodelc
- vocab.json
let pipeline = try StableDiffusionPipeline(resourcesAt: resourcesFolderURL,
configuration: config,
disableSafety: true)
disableSafety
ã¯ãåºåãå®å
šãã©ããããã§ãã¯ãããã©ãããèšå®ããŸãã
ãã®æ©èœãç¡å¹ã«ããã«ã¯ true
ã«ã
æå¹ã«ããã«ã¯false
ã«èšå®ããŸãã
å®å
šãã§ãã«ãŒãæå¹ã«ããå Žåã¯ãå®å
šãã§ãã«ãŒã®MLã¢ãã«ãã¡ã€ã« SafetyChecker.mlmodelc
ãæäŸããå¿
èŠããããŸãã
èšç®ã®éå§
æºåãã§ãããïŒããã¹ããã¬ãŒãºã§ç»åçæé¢æ°ãåŒã³åºããŸã
let resultingImages = try pipeline.generateImages(
prompt: "beautiful night sky, a lot of stars, beautiful, fantancy, vivid, colorful, meteor",
imageCount: 1,
stepCount: 60,
seed: 99
) { progress in
print(progress.currentImages)
}
// çµæãå©çšå¯èœ
print(resultingImages.first?.imageData)
ããã¯ãããããã³ã° blocking
é¢æ°åŒã³åºãã§ãã
ã³ãŒãã®å®è¡ã¯ãçµæãå©çšå¯èœã«ãªã£ãæç¹ã§åéãããŸãã
prompt
ã¯ãçæããå
容ãèšè¿°ããæç« ã§ããã
imageCount
ã¯ãçæããç»åçµæã®æ°ã§ããè€æ°ã®ç»åãçæããå Žåãçµæã®é
å resultingImages
ã«ã¯è€æ°ã®åºåãå«ãŸããŸãã
stepCount
ã¯ãæçµçãªçµæãçæããããŸã§ã«ãããã¹ãããæ°ã§ãã
seed
ã¯ãåäžä»£ã§ç°ãªãã¢ãŒããçæããããã®ä¹±æ°ã§ãã
ã¢ãã«ãš seed
ãåãã§ããã°ãç»åãåãã«ãªãå¯èœæ§ããããŸãã
progress.currentImages
ã¯ãé
åå
ã®ç»åããŒã¿ã®ããããã nil
ã§ããã°ããã®ç»åã¯ã»ãŒããã£ãã§ãã¯ãééããŠããªãããšãæå³ããŸãã
é²æç¶æ³ã®ç¢ºèª
ããã°ã¬ã¹ãã³ãã©å
ã§ã¯ãé²æç¶æ³ãã¢ãã¿ãŒããããšãã§ããŸãã
çæãããç»åã®ææ°ã確èªããããšãã§ããã
progress.step
ã¯çŸåšã®ã¹ããããè¡šããŸãã
progress.currentImages
ã¯ãçŸåšçæãããŠãã CGImage
ãåºåããŸãã
progress.stepCount
ã¯ç»åçæã«ãããç·ã¹ãããæ°
çµæç»å
äžèšã® generateImages
ã³ãã³ãã®å®è¡ãçµäºãããšã
ã³ãã³ãã®å®è¡çµæãé
åã«æ ŒçŽãã
é
åã§ãèŠæ±ãããç»åã®æ°ãå«ãã§ããŸãã
1æã®ç»åãèŠæ±ããå Žåã¯ã .first
ã䜿çšããŠçµæã®ç»åã«ã¢ã¯ã»ã¹ããããšãã§ããŸãã
guard let resultCGImageObject = resultingImages.first?.imageData else {
return
}
MacOSã§ã®çµæ
iOSã§ã®çµæ
iPhoneã§ã¯ãç»åçæã®å®è¡äžã«ã¢ããªãã¯ã©ãã·ã¥ããããšããããŸãããããã¯ããã®åŠçãå€ãã®ã¡ã¢ãªãæ¶è²»ããããã§ãã·ã¹ãã ãã¡ã¢ãªãæ¶è²»ããããŠããå Žåãã¢ããªãçµäºãããŸãã
M1ãããæèŒã®iPad Proã§ã¯ãã»ãšãã©ã®å ŽåãåŠçãæåããŸããã
ãŸããç¹å¥ãªãšã³ã¿ã€ãã«ã¡ã³ããè¿œå ããããšã§ãã¢ããªãããå€ãã®ã¡ã¢ãªé åã䜿çšã§ããããã«ããããšãã§ããŸãã
ã¢ãŒãAIã¢ããª
äžèšã®ã³ã³ã»ããã䜿ã£ãŠãããã¹ãå
¥åã§ç»åãçæããç°¡åãªMacOSãšiOSã®ã¢ããªãäœããŸããã
ç¡æã§ãç»åã¯ããŒã«ã«ã³ã³ãã¥ãŒã¿äžã§çæãããŸãã
ãèªã¿ããã ãããããšãããããŸããã
ð ãã¹ããã³ @me@mszpro.com
âºïž ãµã€ã https://MszPro.com
Written by MszPro~