@@ -30,6 +30,10 @@ TINYDREAM_VERSION?=c04fa463ace9d9a6464313aa5f9cd0f953b6c057
3030BARKCPP_REPO? =https://github.com/PABannier/bark.cpp.git
3131BARKCPP_VERSION? =v1.0.0
3232
33+ # bark.cpp
34+ STABLEDIFFUSION_GGML_REPO? =https://github.com/leejet/stable-diffusion.cpp
35+ STABLEDIFFUSION_GGML_VERSION? =4570715727f35e5a07a76796d823824c8f42206c
36+
3337ONNX_VERSION? =1.20.0
3438ONNX_ARCH? =x64
3539ONNX_OS? =linux
@@ -209,6 +213,7 @@ ALL_GRPC_BACKENDS+=backend-assets/grpc/whisper
209213ifeq ($(ONNX_OS ) ,linux)
210214ifeq ($(ONNX_ARCH ) ,x64)
211215 ALL_GRPC_BACKENDS+=backend-assets/grpc/bark-cpp
216+ ALL_GRPC_BACKENDS+=backend-assets/grpc/stablediffusion-ggml
212217endif
213218endif
214219
@@ -244,25 +249,26 @@ sources/go-llama.cpp:
244249 git checkout $(GOLLAMA_VERSION ) && \
245250 git submodule update --init --recursive --depth 1 --single-branch
246251
252+ sources/go-llama.cpp/libbinding.a : sources/go-llama.cpp
253+ $(MAKE ) -C sources/go-llama.cpp BUILD_TYPE=$(STABLE_BUILD_TYPE ) libbinding.a
254+
255+ # # bark.cpp
247256sources/bark.cpp :
248- git clone --recursive https://github.com/PABannier/bark.cpp.git sources/bark.cpp && \
257+ git clone --recursive $( BARKCPP_REPO ) sources/bark.cpp && \
249258 cd sources/bark.cpp && \
250259 git checkout $(BARKCPP_VERSION ) && \
251260 git submodule update --init --recursive --depth 1 --single-branch
252261
253262sources/bark.cpp/build/libbark.a : sources/bark.cpp
254263 cd sources/bark.cpp && \
255- mkdir build && \
264+ mkdir -p build && \
256265 cd build && \
257266 cmake $(CMAKE_ARGS ) .. && \
258267 cmake --build . --config Release
259268
260269backend/go/bark/libbark.a : sources/bark.cpp/build/libbark.a
261270 $(MAKE ) -C backend/go/bark libbark.a
262271
263- sources/go-llama.cpp/libbinding.a : sources/go-llama.cpp
264- $(MAKE ) -C sources/go-llama.cpp BUILD_TYPE=$(STABLE_BUILD_TYPE ) libbinding.a
265-
266272# # go-piper
267273sources/go-piper :
268274 mkdir -p sources/go-piper
@@ -276,7 +282,7 @@ sources/go-piper:
276282sources/go-piper/libpiper_binding.a : sources/go-piper
277283 $(MAKE ) -C sources/go-piper libpiper_binding.a example/main piper.o
278284
279- # # stable diffusion
285+ # # stable diffusion (onnx)
280286sources/go-stable-diffusion :
281287 mkdir -p sources/go-stable-diffusion
282288 cd sources/go-stable-diffusion && \
@@ -289,6 +295,30 @@ sources/go-stable-diffusion:
289295sources/go-stable-diffusion/libstablediffusion.a : sources/go-stable-diffusion
290296 CPATH=" $( CPATH) :/usr/include/opencv4" $(MAKE ) -C sources/go-stable-diffusion libstablediffusion.a
291297
298+ # # stablediffusion (ggml)
299+ sources/stablediffusion-ggml.cpp :
300+ git clone --recursive $(STABLEDIFFUSION_GGML_REPO ) sources/stablediffusion-ggml.cpp && \
301+ cd sources/stablediffusion-ggml.cpp && \
302+ git checkout $(STABLEDIFFUSION_GGML_VERSION ) && \
303+ git submodule update --init --recursive --depth 1 --single-branch
304+
305+ sources/stablediffusion-ggml.cpp/build/libstable-diffusion.a : sources/stablediffusion-ggml.cpp
306+ cd sources/stablediffusion-ggml.cpp && \
307+ mkdir -p build && \
308+ cd build && \
309+ cmake $(CMAKE_ARGS ) .. && \
310+ cmake --build . --config Release
311+
312+ backend/go/image/stablediffusion-ggml/libsd.a : sources/stablediffusion-ggml.cpp/build/libstable-diffusion.a
313+ $(MAKE ) -C backend/go/image/stablediffusion-ggml libsd.a
314+
315+ backend-assets/grpc/stablediffusion-ggml : backend/go/image/stablediffusion-ggml/libsd.a backend-assets/grpc
316+ CGO_LDFLAGS=" $( CGO_LDFLAGS) " C_INCLUDE_PATH=$(CURDIR ) /backend/go/image/stablediffusion-ggml/ LIBRARY_PATH=$(CURDIR ) /backend/go/image/stablediffusion-ggml/ \
317+ $(GOCMD ) build -ldflags " $( LD_FLAGS) " -tags " $( GO_TAGS) " -o backend-assets/grpc/stablediffusion-ggml ./backend/go/image/stablediffusion-ggml/
318+ ifneq ($(UPX ) ,)
319+ $(UPX) backend-assets/grpc/stablediffusion-ggml
320+ endif
321+
292322sources/onnxruntime :
293323 mkdir -p sources/onnxruntime
294324 curl -L https://github.com/microsoft/onnxruntime/releases/download/v$(ONNX_VERSION ) /onnxruntime-$(ONNX_OS ) -$(ONNX_ARCH ) -$(ONNX_VERSION ) .tgz -o sources/onnxruntime/onnxruntime-$(ONNX_OS ) -$(ONNX_ARCH ) -$(ONNX_VERSION ) .tgz
@@ -329,7 +359,7 @@ sources/whisper.cpp:
329359sources/whisper.cpp/libwhisper.a : sources/whisper.cpp
330360 cd sources/whisper.cpp && $(MAKE ) libwhisper.a libggml.a
331361
332- get-sources : sources/go-llama.cpp sources/go-piper sources/bark.cpp sources/whisper.cpp sources/go-stable-diffusion sources/go-tiny-dream backend/cpp/llama/llama.cpp
362+ get-sources : sources/go-llama.cpp sources/go-piper sources/stablediffusion-ggml.cpp sources/ bark.cpp sources/whisper.cpp sources/go-stable-diffusion sources/go-tiny-dream backend/cpp/llama/llama.cpp
333363
334364replace :
335365 $(GOCMD ) mod edit -replace github.com/ggerganov/whisper.cpp=$(CURDIR ) /sources/whisper.cpp
@@ -372,6 +402,7 @@ clean: ## Remove build related file
372402 $(MAKE ) -C backend/cpp/grpc clean
373403 $(MAKE ) -C backend/go/bark clean
374404 $(MAKE ) -C backend/cpp/llama clean
405+ $(MAKE ) -C backend/go/image/stablediffusion-ggml clean
375406 rm -rf backend/cpp/llama-* || true
376407 $(MAKE ) dropreplace
377408 $(MAKE ) protogen-clean
0 commit comments