File size: 6,233 Bytes
5ac2b1b | 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 | #!/bin/bash
#
# Download MuseTalk models from HuggingFace
#
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
MODELS_DIR="${PROJECT_DIR}/models"
GREEN='\033[0;32m'
CYAN='\033[0;36m'
YELLOW='\033[1;33m'
NC='\033[0m'
success() { echo -e "${GREEN}β${NC} $1"; }
header() { echo -e "\n${CYAN}$1${NC}"; }
warn() { echo -e "${YELLOW}!${NC} $1"; }
echo ""
echo "ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo "β MUSETALK - MODEL DOWNLOAD β"
echo "ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo ""
# Check for huggingface-cli
if ! command -v huggingface-cli &> /dev/null; then
echo "Installing huggingface_hub..."
pip install huggingface_hub -q
fi
# Create directories
mkdir -p "${MODELS_DIR}/avatar/musetalk"
mkdir -p "${MODELS_DIR}/avatar/vae"
mkdir -p "${MODELS_DIR}/whisper"
mkdir -p "${MODELS_DIR}/dwpose"
mkdir -p "${MODELS_DIR}/face_parse"
# ============================================================
# 1. MUSETALK MODELS
# ============================================================
header "[1/5] Downloading MuseTalk UNet..."
if [ -f "${MODELS_DIR}/avatar/musetalk/pytorch_model.bin" ]; then
success "MuseTalk UNet already exists"
else
huggingface-cli download TMElyralab/MuseTalk \
--include "models/musetalk/*" \
--local-dir "${MODELS_DIR}/temp_musetalk" \
--local-dir-use-symlinks False
# Move files to correct location
if [ -d "${MODELS_DIR}/temp_musetalk/models/musetalk" ]; then
cp -r "${MODELS_DIR}/temp_musetalk/models/musetalk/"* "${MODELS_DIR}/avatar/musetalk/"
rm -rf "${MODELS_DIR}/temp_musetalk"
success "MuseTalk UNet downloaded"
else
warn "MuseTalk download may have failed"
fi
fi
# ============================================================
# 2. VAE (SD-VAE-FT-MSE)
# ============================================================
header "[2/5] Downloading VAE..."
if [ -f "${MODELS_DIR}/avatar/vae/config.json" ]; then
success "VAE already exists"
else
huggingface-cli download stabilityai/sd-vae-ft-mse \
--local-dir "${MODELS_DIR}/avatar/vae" \
--local-dir-use-symlinks False
success "VAE downloaded"
fi
# ============================================================
# 3. WHISPER
# ============================================================
header "[3/5] Downloading Whisper..."
if [ -f "${MODELS_DIR}/whisper/tiny.pt" ]; then
success "Whisper already exists"
else
# Download from OpenAI
wget -q -O "${MODELS_DIR}/whisper/tiny.pt" \
"https://openaipublic.azureedge.net/main/whisper/models/65147644a518d12f04e32d6f3b26facc3f8dd46e5390956a9424a650c0ce22b9/tiny.pt" \
|| curl -s -o "${MODELS_DIR}/whisper/tiny.pt" \
"https://openaipublic.azureedge.net/main/whisper/models/65147644a518d12f04e32d6f3b26facc3f8dd46e5390956a9424a650c0ce22b9/tiny.pt"
if [ -f "${MODELS_DIR}/whisper/tiny.pt" ]; then
success "Whisper downloaded"
else
warn "Whisper download failed"
fi
fi
# ============================================================
# 4. DWPOSE
# ============================================================
header "[4/5] Downloading DWPose..."
if [ -f "${MODELS_DIR}/dwpose/dw-ll_ucoco_384.pth" ]; then
success "DWPose already exists"
else
huggingface-cli download yzd-v/DWPose \
--include "dw-ll_ucoco_384.pth" \
--local-dir "${MODELS_DIR}/dwpose" \
--local-dir-use-symlinks False
success "DWPose downloaded"
fi
# ============================================================
# 5. FACE PARSING
# ============================================================
header "[5/5] Downloading Face Parsing models..."
if [ -f "${MODELS_DIR}/face_parse/79999_iter.pth" ]; then
success "Face parsing already exists"
else
# Download from MuseTalk repo
huggingface-cli download TMElyralab/MuseTalk \
--include "models/face-parse-bisenet/*" \
--local-dir "${MODELS_DIR}/temp_fp" \
--local-dir-use-symlinks False
if [ -d "${MODELS_DIR}/temp_fp/models/face-parse-bisenet" ]; then
cp -r "${MODELS_DIR}/temp_fp/models/face-parse-bisenet/"* "${MODELS_DIR}/face_parse/"
rm -rf "${MODELS_DIR}/temp_fp"
success "Face parsing downloaded"
fi
# Also need resnet18
if [ ! -f "${MODELS_DIR}/face_parse/resnet18-5c106cde.pth" ]; then
wget -q -O "${MODELS_DIR}/face_parse/resnet18-5c106cde.pth" \
"https://download.pytorch.org/models/resnet18-5c106cde.pth" \
|| curl -s -o "${MODELS_DIR}/face_parse/resnet18-5c106cde.pth" \
"https://download.pytorch.org/models/resnet18-5c106cde.pth"
fi
fi
# ============================================================
# SUMMARY
# ============================================================
echo ""
echo "ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo "β DOWNLOAD COMPLETE β"
echo "ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo ""
echo "Models directory: ${MODELS_DIR}"
echo ""
# Check all models
check_model() {
if [ -f "$1" ] || [ -d "$1" ]; then
echo -e " ${GREEN}β${NC} $2"
else
echo -e " β $2 (missing)"
fi
}
echo "Installed models:"
check_model "${MODELS_DIR}/avatar/musetalk/pytorch_model.bin" "MuseTalk UNet"
check_model "${MODELS_DIR}/avatar/vae/config.json" "VAE"
check_model "${MODELS_DIR}/whisper/tiny.pt" "Whisper Tiny"
check_model "${MODELS_DIR}/dwpose/dw-ll_ucoco_384.pth" "DWPose"
check_model "${MODELS_DIR}/face_parse/79999_iter.pth" "Face Parsing"
echo ""
|