-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat:init] first version of stable diffusion.
- Loading branch information
0 parents
commit 143e001
Showing
44 changed files
with
28,641 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
project(stable-diffusion-mnn) | ||
|
||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | ||
|
||
# include dir | ||
include_directories(${CMAKE_CURRENT_LIST_DIR}/include/) | ||
|
||
# libs dir | ||
link_directories(${CMAKE_CURRENT_LIST_DIR}/libs) | ||
|
||
# source files | ||
FILE(GLOB SRCS ${CMAKE_CURRENT_LIST_DIR}/src/*) | ||
|
||
# target | ||
add_executable(main ${SRCS}) | ||
|
||
target_link_libraries(main MNN MNN_Express MNNOpenCV) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Stable Diffusion MNN | ||
|
||
## Usage | ||
|
||
### 1. Compile MNN library | ||
```bash | ||
git clone https://github.com/alibaba/MNN.git | ||
cd MNN | ||
mkdir build | ||
cmake -DMNN_BUILD_OPENCV=ON MNN_IMGCODECS=ON .. | ||
make -j8 | ||
cp libMNN.so express/libMNN_Express.so tools/cv/libMNNOpenCV.so /path/to/stable-diffusion-mnn/libs | ||
``` | ||
|
||
### 2. Build and Run | ||
```bash | ||
mkdir build | ||
cd build | ||
cmake .. | ||
make -j4 | ||
./main "飞流直下三千尺,油画" f.jpg | ||
``` | ||
|
||
# Ref | ||
https://huggingface.co/IDEA-CCNL/Taiyi-Stable-Diffusion-1B-Chinese-v0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// | ||
// AutoTime.hpp | ||
// MNN | ||
// | ||
// Created by MNN on 2018/07/27. | ||
// Copyright © 2018, Alibaba Group Holding Limited | ||
// | ||
|
||
#ifndef MNN_AutoTime_hpp | ||
#define MNN_AutoTime_hpp | ||
|
||
#include <stdint.h> | ||
#include <stdio.h> | ||
#include <MNN/MNNDefine.h> | ||
|
||
namespace MNN { | ||
|
||
class MNN_PUBLIC Timer { | ||
public: | ||
Timer(); | ||
~Timer(); | ||
Timer(const Timer&) = delete; | ||
Timer(const Timer&&) = delete; | ||
Timer& operator=(const Timer&) = delete; | ||
Timer& operator=(const Timer&&) = delete; | ||
|
||
// reset timer | ||
void reset(); | ||
// get duration (us) from init or latest reset. | ||
uint64_t durationInUs(); | ||
|
||
// Get Current Time | ||
uint64_t current() const { | ||
return mLastResetTime; | ||
} | ||
protected: | ||
uint64_t mLastResetTime; | ||
}; | ||
|
||
/** time tracing util. prints duration between init and deinit. */ | ||
class MNN_PUBLIC AutoTime : Timer { | ||
public: | ||
AutoTime(int line, const char* func); | ||
~AutoTime(); | ||
AutoTime(const AutoTime&) = delete; | ||
AutoTime(const AutoTime&&) = delete; | ||
AutoTime& operator=(const AutoTime&) = delete; | ||
AutoTime& operator=(const AutoTime&&) = delete; | ||
|
||
private: | ||
int mLine; | ||
char* mName; | ||
}; | ||
} // namespace MNN | ||
|
||
#ifdef MNN_OPEN_TIME_TRACE | ||
#define AUTOTIME MNN::AutoTime ___t(__LINE__, __func__) | ||
#else | ||
#define AUTOTIME | ||
#endif | ||
|
||
#endif /* AutoTime_hpp */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// ErrorCode.hpp | ||
// MNN | ||
// | ||
// Created by MNN on 2018/09/18. | ||
// Copyright © 2018, Alibaba Group Holding Limited | ||
// | ||
|
||
#ifndef MNN_ErrorCode_h | ||
#define MNN_ErrorCode_h | ||
|
||
namespace MNN { | ||
enum ErrorCode { | ||
#ifdef NO_ERROR | ||
#undef NO_ERROR | ||
#endif // NO_ERROR | ||
NO_ERROR = 0, | ||
OUT_OF_MEMORY = 1, | ||
NOT_SUPPORT = 2, | ||
COMPUTE_SIZE_ERROR = 3, | ||
NO_EXECUTION = 4, | ||
INVALID_VALUE = 5, | ||
|
||
// User error | ||
INPUT_DATA_ERROR = 10, | ||
CALL_BACK_STOP = 11, | ||
|
||
// Op Resize Error | ||
TENSOR_NOT_SUPPORT = 20, | ||
TENSOR_NEED_DIVIDE = 21, | ||
}; | ||
} // namespace MNN | ||
|
||
#endif /* ErrorCode_h */ |
Oops, something went wrong.