Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
273 lines (242 loc) · 9.62 KB
/
Copy pathMakefile
File metadata and controls
273 lines (242 loc) · 9.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# Makefile for HY-Motion-1.0
#
# Usage:
# make help - Show this help
# make setup - Install Python dependencies
# make install - Install package in development mode
# make download-models - Download all required models
# make download-t2m - Download text-to-motion models
# make download-encoders - Download text encoder models
# make download-rewriter - Download prompt rewriter model
# make run-cli - Run CLI inference
# make run-gradio - Run Gradio web interface
# make clean - Clean up temporary files
# make docker-build - Build Docker image
# make docker-run - Run Docker container
.PHONY: help setup install download-models download-t2m download-encoders download-rewriter run-cli run-gradio clean docker-build docker-run quantize-prompter
# Default target
all: help
# Show help
help:
@echo "HY-Motion-1.0 Makefile Usage:"
@echo ""
@echo "Setup and Installation:"
@echo " make setup - Install Python dependencies"
@echo " make install - Install package in development mode"
@echo " make setup-streaming - Setup streaming environment"
@echo " make fix-checkpoint-paths - Fix checkpoint paths for streaming"
@echo " make streaming-setup - Complete streaming setup (download + fix paths)"
@echo ""
@echo "Model Downloads:"
@echo " make download-models - Download all required models"
@echo " make download-t2m - Download text-to-motion models"
@echo " make download-encoders - Download text encoder models"
@echo " make download-rewriter - Download prompt rewriter model"
@echo ""
@echo "Model Optimization:"
@echo " make quantize-prompter - Quantize prompter model to 4-bit (faster loading)"
@echo ""
@echo "Running the Application:"
@echo " make run-cli - Run CLI inference (default: HY-Motion-1.0)"
@echo " make run-gradio - Run Gradio web interface"
@echo " make run-gradio-streaming - Run Streaming Gradio web interface"
@echo " make run-gradio-streaming-docker - Run Streaming Gradio with Docker"
@echo ""
@echo "Docker:"
@echo " make docker-build - Build Docker image"
@echo " make docker-run - Run Docker container with bash"
@echo " make docker-python - Run Docker container with Python shell"
@echo " make docker-python3 - Run Docker container with Python3 shell"
@echo ""
@echo "Testing:"
@echo " make test-docker-deps - Test Docker dependencies locally"
@echo " make test-docker-deps-in-container - Test dependencies in Docker container"
@echo ""
@echo "Cleanup:"
@echo " make clean - Clean up temporary files"
# Install Python dependencies
setup:
@echo "Installing Python dependencies..."
pip install --upgrade pip
pip install -r requirements.txt
# Install package in development mode
install:
@echo "Installing HY-Motion-1.0 in development mode..."
pip install -e .
# Download all models
download-models: download-t2m download-encoders download-rewriter
# Download text-to-motion models
download-t2m:
@echo "Downloading text-to-motion models..."
mkdir -p ckpts/tencent
huggingface-cli download tencent/HY-Motion-1.0 --local-dir ckpts/tencent/HY-Motion-1.0 || echo "Failed to download HY-Motion-1.0"
# Download text encoder models
download-encoders:
@echo "Downloading text encoder models..."
mkdir -p ckpts
huggingface-cli download openai/clip-vit-large-patch14 --local-dir ckpts/clip-vit-large-patch14 || echo "Failed to download CLIP encoder"
huggingface-cli download Qwen/Qwen3-8B --local-dir ckpts/Qwen3-8B || echo "Failed to download Qwen encoder"
# Download prompt rewriter model
download-rewriter:
@echo "Downloading prompt rewriter model..."
mkdir -p ckpts
huggingface-cli download Text2MotionPrompter/Text2MotionPrompter --local-dir ckpts/Text2MotionPrompter || echo "Failed to download prompt rewriter"
# Quantize prompter model to 4-bit for faster loading
quantize-prompter:
@echo "Quantizing prompter model to 4-bit..."
@echo "This will create a quantized version at ckpts/Text2MotionPrompter_4bit"
@echo "This process may take several minutes but only needs to be done once."
@echo ""
python3 scripts/quantize_prompter_model.py
# Run CLI inference
run-cli:
@echo "Running CLI inference with HY-Motion-1.0..."
USE_HF_MODELS=0 python3 local_infer.py --model_path ckpts/tencent/HY-Motion-1.0
# Run CLI inference with Lite model
run-cli-lite:
@echo "Running CLI inference with HY-Motion-1.0-Lite..."
USE_HF_MODELS=0 python3 local_infer.py --model_path ckpts/tencent/HY-Motion-1.0-Lite
# Run Gradio web interface
run-gradio:
@echo "Running Gradio web interface..."
USE_HF_MODELS=0 python3 gradio_app.py
# Run Streaming Gradio web interface
run-gradio-streaming:
@echo "Running Streaming Gradio web interface..."
USE_HF_MODELS=0 python3 gradio_app_streaming.py
# Run Streaming Gradio web interface with Docker
run-gradio-docker:
@echo "Running Streaming Gradio web interface with Docker..."
mkdir -p $(PWD)/output/gradio
docker run -it --rm \
--gpus all \
-p 7860:7860 -p 7861:7861 \
-v $(PWD):/app \
-v $(PWD)/ckpts:/app/ckpts \
-v $(PWD)/output:/app/output \
-e USE_HF_MODELS=0 \
-e PYTHONPATH=/app \
-e PROMPT_MODEL_PATH=/app/ckpts/Text2MotionPrompter \
hymotion:latest python gradio_app.py
run-gradio-streaming-docker:
@echo "Running Streaming Gradio web interface with Docker..."
mkdir -p $(PWD)/output/gradio
docker run -it --rm \
--gpus all \
-p 7860:7860 -p 7861:7861 \
-v $(PWD):/app \
-v $(PWD)/ckpts:/app/ckpts \
-v $(PWD)/output:/app/output \
-e USE_HF_MODELS=0 \
-e PYTHONPATH=/app \
-e PROMPT_MODEL_PATH=/app/ckpts/Text2MotionPrompter \
hymotion:latest python gradio_app_streaming.py
run-server:
@echo "Running Streaming Gradio web interface with Docker..."
mkdir -p $(PWD)/output/gradio
docker run -it --rm \
--gpus all \
-p 7860:7860 \
-v $(PWD):/app \
-v $(PWD)/ckpts:/app/ckpts \
-v $(PWD)/output:/app/output \
-e USE_HF_MODELS=0 \
-e PYTHONPATH=/app \
-e PROMPT_MODEL_PATH=/app/ckpts/Text2MotionPrompter \
hymotion:latest python streaming_server.py
# Download and setup streaming-specific models
setup-streaming:
@echo "Setting up streaming environment..."
mkdir -p ckpts/tencent/HY-Motion-1.0
mkdir -p downloaded_models/HY-Motion-1.0-Lite
@echo "Checkpoint directories created"
# Fix checkpoint paths for streaming
fix-checkpoint-paths:
@echo "Fixing checkpoint paths for streaming..."
# Create symlink if Lite model exists in downloaded_models
if [ -d "downloaded_models/HY-Motion-1.0-Lite" ]; then \
ln -sf ../downloaded_models/HY-Motion-1.0-Lite ckpts/tencent/HY-Motion-1.0 || true; \
fi
# Create symlink if full model exists in downloaded_models
if [ -d "downloaded_models/HY-Motion-1.0" ]; then \
ln -sf ../downloaded_models/HY-Motion-1.0 ckpts/tencent/HY-Motion-1.0 || true; \
fi
@echo "Checkpoint path fixes applied"
# Complete streaming setup (download + fix paths)
streaming-setup: download-t2m fix-checkpoint-paths
# Test Docker dependencies
test-docker-deps:
@echo "Testing Docker dependencies..."
python test_docker_dependencies.py
# Test Docker dependencies in container
test-docker-deps-in-container:
@echo "Testing dependencies in Docker container..."
docker run -it --rm \\
--gpus all \\
-v $(pwd):/app \\
hymotion:latest \\
python test_docker_dependencies.py
# Clean up temporary files
clean:
@echo "Cleaning up temporary files..."
rm -rf __pycache__ */__pycache__ */*/__pycache__
rm -rf .pytest_cache .mypy_cache
rm -rf downloaded_models
find . -name "*.pyc" -delete
find . -name "*.pyo" -delete
find . -name "*.pyd" -delete
find . -name "*.pyo" -delete
find . -name "*.pyd" -delete
# Build Docker image
docker-build:
@echo "Building Docker image..."
docker build -t hymotion:latest .
# Run Docker container
docker-run:
@echo "Running Docker container..."
mkdir -p $(PWD)/output/gradio
docker run -it --rm \
--gpus all \
-p 7860:7860 \
-v $(PWD):/app \
-v $(PWD)/ckpts:/app/ckpts \
-v $(PWD)/downloaded_models:/app/downloaded_models \
-v $(PWD)/output:/app/output \
-e USE_HF_MODELS=0 \
-e PYTHONPATH=/app \
hymotion:latest bash -c "python --version && python3 --version && bash"
# Run Docker container with Python shell
docker-python:
@echo "Running Docker container with Python shell..."
mkdir -p $(PWD)/output/gradio
docker run -it --rm \
--gpus all \
-p 7860:7860 \
-v $(PWD):/app \
-v $(PWD)/ckpts:/app/ckpts \
-v $(PWD)/downloaded_models:/app/downloaded_models \
-v $(PWD)/output:/app/output \
-e USE_HF_MODELS=0 \
-e PYTHONPATH=/app \
hymotion:latest python
# Run Docker container with Python3 shell
docker-python3:
@echo "Running Docker container with Python3 shell..."
mkdir -p $(PWD)/output/gradio
docker run -it --rm \
--gpus all \
-p 7860:7860 \
-v $(PWD):/app \
-v $(PWD)/ckpts:/app/ckpts \
-v $(PWD)/downloaded_models:/app/downloaded_models \
-v $(PWD)/output:/app/output \
-e USE_HF_MODELS=0 \
-e PYTHONPATH=/app \
hymotion:latest python3
# Additional convenience targets
run-cli-with-rewrite:
@echo "Running CLI inference with prompt rewriting enabled..."
USE_HF_MODELS=0 python3 local_infer.py --model_path ckpts/tencent/HY-Motion-1.0 --disable_duration_est false --disable_rewrite false
run-cli-no-rewrite:
@echo "Running CLI inference with prompt rewriting disabled..."
USE_HF_MODELS=0 python3 local_infer.py --model_path ckpts/tencent/HY-Motion-1.0 --disable_duration_est true --disable_rewrite true