source.md 1.2 KB

源码分析

项目结构

tree

├─3rd_party         # 第三方依赖
├─backupcode
├─benchmark
├─ciscripts
├─cmake
├─codegen
├─demo
├─doc
├─docs
├─express
├─include
├─package_scripts
├─project
├─pymnn
├─resource
├─schema
├─source
├─test
├─tools
├─docker_run.sh

源码构建,

git clone https://github.com/alibaba/MNN.git
cd MNN
mkdir build
cmake -DMNN_BUILD_OPENCV=ON -DMNN_IMGCODECS=ON ..

# 编译生成 libMNN.so 文件
make -j8
git clone https://github.com/wangzhaode/stable-diffusion-mnn.git
cp libMNN.so express/libMNN_Express.so tools/cv/libMNNOpenCV.so /path/to/stable-diffusion-mnn/libs

# 下载权重
cd resource
wget https://github.com/wangzhaode/stable-diffusion-mnn/releases/download/v0.1/text_encoder.mnn
wget https://github.com/wangzhaode/stable-diffusion-mnn/releases/download/v0.1/vae_decoder.mnn
wget https://github.com/wangzhaode/stable-diffusion-mnn/releases/download/v0.1/unet.mnn

# 执行
mkdir build
cd build
cmake ..
make -j4
./main "飞流直下三千尺,疑是银河落九天,唐诗,水墨,国画。" demo.jpg
[##################################################]  [100%] [iter time: 411.441000 ms]
SUCCESS! write to demo.jpg