Skip to content

Commit 8b6e601

Browse files
authored
Feat: new backend: transformers-musicgen (#1387)
Transformers-MusicGen --------- Signed-off-by: Dave <[email protected]>
1 parent 6011911 commit 8b6e601

File tree

26 files changed

+868
-13
lines changed

26 files changed

+868
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
__pycache__/
44
*.a
55
get-sources
6+
prepare-sources
67
/backend/cpp/llama/grpc-server
78
/backend/cpp/llama/llama.cpp
89

Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ ARG TARGETARCH
1212
ARG TARGETVARIANT
1313

1414
ENV BUILD_TYPE=${BUILD_TYPE}
15-
ENV EXTERNAL_GRPC_BACKENDS="huggingface-embeddings:/build/backend/python/sentencetransformers/run.sh,petals:/build/backend/python/petals/run.sh,transformers:/build/backend/python/transformers/run.sh,sentencetransformers:/build/backend/python/sentencetransformers/run.sh,autogptq:/build/backend/python/autogptq/run.sh,bark:/build/backend/python/bark/run.sh,diffusers:/build/backend/python/diffusers/run.sh,exllama:/build/backend/python/exllama/run.sh,vall-e-x:/build/backend/python/vall-e-x/run.sh,vllm:/build/backend/python/vllm/run.sh,exllama2:/build/backend/python/exllama2/run.sh"
15+
16+
ENV EXTERNAL_GRPC_BACKENDS="huggingface-embeddings:/build/backend/python/sentencetransformers/run.sh,petals:/build/backend/python/petals/run.sh,transformers:/build/backend/python/transformers/run.sh,sentencetransformers:/build/backend/python/sentencetransformers/run.sh,autogptq:/build/backend/python/autogptq/run.sh,bark:/build/backend/python/bark/run.sh,diffusers:/build/backend/python/diffusers/run.sh,exllama:/build/backend/python/exllama/run.sh,vall-e-x:/build/backend/python/vall-e-x/run.sh,vllm:/build/backend/python/vllm/run.sh,exllama2:/build/backend/python/exllama2/run.sh,transformers-musicgen:/build/backend/python/transformers-musicgen/run.sh"
17+
1618
ENV GALLERIES='[{"name":"model-gallery", "url":"github:go-skynet/model-gallery/index.yaml"}, {"url": "github:go-skynet/model-gallery/huggingface.yaml","name":"huggingface"}]'
1719
ARG GO_TAGS="stablediffusion tts"
1820

@@ -187,6 +189,9 @@ RUN if [ "${IMAGE_TYPE}" = "extras" ]; then \
187189
RUN if [ "${IMAGE_TYPE}" = "extras" ]; then \
188190
PATH=$PATH:/opt/conda/bin make -C backend/python/petals \
189191
; fi
192+
RUN if [ "${IMAGE_TYPE}" = "extras" ]; then \
193+
PATH=$PATH:/opt/conda/bin make -C backend/python/transformers-musicgen \
194+
; fi
190195

191196
# Define the health check command
192197
HEALTHCHECK --interval=1m --timeout=10m --retries=10 \

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ protogen-go:
389389
protogen-python:
390390
python3 -m grpc_tools.protoc -Ibackend/ --python_out=backend/python/sentencetransformers/ --grpc_python_out=backend/python/sentencetransformers/ backend/backend.proto
391391
python3 -m grpc_tools.protoc -Ibackend/ --python_out=backend/python/transformers/ --grpc_python_out=backend/python/transformers/ backend/backend.proto
392+
python3 -m grpc_tools.protoc -Ibackend/ --python_out=backend/python/transformers-musicgen/ --grpc_python_out=backend/python/transformers-musicgen/ backend/backend.proto
392393
python3 -m grpc_tools.protoc -Ibackend/ --python_out=backend/python/autogptq/ --grpc_python_out=backend/python/autogptq/ backend/backend.proto
393394
python3 -m grpc_tools.protoc -Ibackend/ --python_out=backend/python/exllama/ --grpc_python_out=backend/python/exllama/ backend/backend.proto
394395
python3 -m grpc_tools.protoc -Ibackend/ --python_out=backend/python/bark/ --grpc_python_out=backend/python/bark/ backend/backend.proto
@@ -407,6 +408,7 @@ prepare-extra-conda-environments:
407408
$(MAKE) -C backend/python/vllm
408409
$(MAKE) -C backend/python/sentencetransformers
409410
$(MAKE) -C backend/python/transformers
411+
$(MAKE) -C backend/python/transformers-musicgen
410412
$(MAKE) -C backend/python/vall-e-x
411413
$(MAKE) -C backend/python/exllama
412414
$(MAKE) -C backend/python/petals

api/backend/tts.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,13 @@ func ModelTTS(backend, text, modelFile string, loader *model.ModelLoader, o *opt
5959
// If the model file is not empty, we pass it joined with the model path
6060
modelPath := ""
6161
if modelFile != "" {
62-
modelPath = filepath.Join(o.Loader.ModelPath, modelFile)
63-
if err := utils.VerifyPath(modelPath, o.Loader.ModelPath); err != nil {
64-
return "", nil, err
62+
if bb != model.TransformersMusicGen {
63+
modelPath = filepath.Join(o.Loader.ModelPath, modelFile)
64+
if err := utils.VerifyPath(modelPath, o.Loader.ModelPath); err != nil {
65+
return "", nil, err
66+
}
67+
} else {
68+
modelPath = modelFile
6569
}
6670
}
6771

backend/python/autogptq/backend_pb2.py

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/python/bark/backend_pb2.py

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/python/diffusers/backend_pb2.py

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/python/exllama/backend_pb2.py

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/python/petals/backend_pb2.py

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/python/sentencetransformers/backend_pb2.py

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
TRANSFORMERS_MUSICGEN_CONDA_PATH = "transformers-musicgen.yml"
3+
4+
ifeq ($(BUILD_TYPE), cublas)
5+
TRANSFORMERS_MUSICGEN_CONDA_PATH = "transformers-musicgen-nvidia.yml"
6+
endif
7+
8+
.PHONY: transformers-musicgen
9+
transformers-musicgen:
10+
@echo "Creating virtual environment..."
11+
@conda env create --name transformers-musicgen --file $(TRANSFORMERS_MUSICGEN_CONDA_PATH)
12+
@echo "Virtual environment created."
13+
14+
.PHONY: run
15+
run:
16+
@echo "Running transformers..."
17+
bash run.sh
18+
@echo "transformers run."
19+
20+
# It is not working well by using command line. It only6 works with IDE like VSCode.
21+
.PHONY: test
22+
test:
23+
@echo "Testing transformers..."
24+
bash test.sh
25+
@echo "transformers tested."
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Creating a separate environment for the transformers project
2+
3+
```
4+
make transformers-musicgen
5+
```

backend/python/transformers-musicgen/backend_pb2.py

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)