Skip to content

akleine/sdcpp-on-android

Repository files navigation

KEEP ANDROID OPEN


This is the sdcpp-on-android project

Purpose:

An interface for Stable Diffusion, with focus on image generation by entering text prompts. This project depends entirely on the excellent work of leejet and his contributors writing the stable-diffusion.cpp project ( https://github.com/leejet/stable-diffusion.cpp ). Many thanks for their efforts! Note that this implementation only uses a small subset (T2I) of sd.cpp's full feature set.

Installation Instructions:

See Build Instructions below. You may need to allow 'Install from unknown sources' when prompted.

Usage Guide:

  • Download at least one valid stable diffusion model file on your device. For details see: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/sd.md
    Download these safetensors or ckpt files using your favorite web browser and store them below 'Download', but you may want to create a dedicated folder (e.g., 'Download/Models') to stay organized.

  • Grant permissions: Confirm the required storage permissions (see Security & Privacy Note below).

  • Generate an image in three steps The generated image files (PNG) are saved in 'Download' folder, called outputXXXXXXXXXX.png, where XXXXXXXXXX is the Unix timestamp of when the generation started. Also a log file is written, called outputXXXXXXXXXX.log.txt.

Example: Generate an SDXS image (within seconds)

Step 1: first enter some input:
Step 2: wait some seconds:
Step 3: view your result:

Example: an SDXL style image (via SSD1B, needs much more time)

Step 1: first enter some input:
Step 2: wait some time:
Step 3: view your result:

Build Instructions:

Import the project to Android Studio and build it, then execute the built APK on your device by sideloading it via ADB. You also are free to build the native library part by yourself, see below.

License:

MIT, the same license as sd.cpp.

Security & Privacy Note:

This app requires extensive storage permissions to function. It needs to read access to load the model files you provide and write access to save the generated images. We value your privacy and no data is collected or transmitted by this app. You can verify this by reviewing the source code.

Native code:

IMPORTANT: this project contains compiled code forked from sd.cpp (stable-diffusion.cpp-JetsonNano), see here: https://github.com/akleine/stable-diffusion.cpp-JetsonNano/tree/1626d04 . You are encouraged to build the sd executable yourself using Android NDK, see the sd.cpp build documentation: https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/build.md . The binaries were built in Termux using the following commands:

cmake .. -G Ninja \
  -DCMAKE_TOOLCHAIN_FILE=/data/data/com.termux/files/home/android-ndk-r27b/build/cmake/android.toolchain.cmake \
  -DANDROID_PLATFORM=android-28 \
  -DANDROID_ABI=arm64-v8a  # for 32 bit use: armeabi-v7a \
  -DGGML_OPENMP=OFF \
  -DSD_OPENCL=OFF

ninja
cd bin
strip sd

After compiling rename the executables from 'sd' to 'libsd.so' and place it in app/src/main/jniLibs/arm64-v8a respectively app/src/main/jniLibs/armeabi-v7a folder. (This renaming is needed due android restrictions.)

About

Create images from text using sd.cpp on Android

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages