Skip to content

Commit 1f2391f

Browse files
Rizbeclaude
andcommitted
fix(install): Fix face-swap dependency installation issues
- Add python3-dev package check/install for insightface Cython compilation - Fixes "Python.h: No such file or directory" error on Ubuntu/Debian - Provides helpful hint if auto-install fails - Add Python 3.13+ compatibility for GFPGAN/basicsr - Detects Python version and uses Disty0's BasicSR fork for 3.13+ - The upstream basicsr uses exec()/locals() pattern that breaks in Python 3.13 - See: TencentARC/GFPGAN#619 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 0fae724 commit 1f2391f

1 file changed

Lines changed: 32 additions & 3 deletions

File tree

install.sh

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,17 @@ echo -e "${GREEN} ✓ Python environment ready${NC}"
373373
# =============================================================================
374374
echo -e "\n${YELLOW}[6.5/7] Installing face-swap dependencies...${NC}"
375375

376+
# Install Python development headers (required for insightface Cython compilation)
377+
# This provides Python.h which is needed to build insightface's C extensions
378+
if command -v dpkg &> /dev/null; then
379+
if ! dpkg -s python3-dev >/dev/null 2>&1; then
380+
echo " Installing python3-dev (required for insightface)..."
381+
if command -v apt-get &> /dev/null; then
382+
sudo apt-get install -y python3-dev >/dev/null 2>&1 || echo " [Could not auto-install python3-dev]"
383+
fi
384+
fi
385+
fi
386+
376387
source "$INSTALL_DIR/venv/bin/activate"
377388

378389
# Core dependencies (required)
@@ -381,6 +392,7 @@ if pip install insightface==0.7.3 opencv-python-headless requests imageio imagei
381392
echo -e " ${GREEN}${NC} Core packages installed"
382393
else
383394
echo -e " ${YELLOW}!${NC} Core packages failed - face-swap may not work"
395+
echo " Hint: If you see 'Python.h not found', run: sudo apt-get install python3-dev"
384396
fi
385397

386398
# ONNX runtime (try GPU first, fallback to CPU)
@@ -395,10 +407,27 @@ fi
395407

396408
# GFPGAN for face enhancement (optional, may fail due to complex deps)
397409
echo " Installing GFPGAN (face enhancement)..."
398-
if pip install gfpgan --quiet 2>&1; then
399-
echo -e " ${GREEN}${NC} GFPGAN installed"
410+
411+
# Check Python version - 3.13+ has exec() compatibility issue with basicsr
412+
# See: https://github.com/TencentARC/GFPGAN/pull/619
413+
PYTHON_MINOR=$(python3 -c 'import sys; print(sys.version_info.minor)')
414+
if [ "$PYTHON_MINOR" -ge 13 ]; then
415+
echo " [Python 3.13+ detected - using compatible basicsr fork]"
416+
# Install basicsr from Disty0's fork with Python 3.13 fix (master branch)
417+
# Then install gfpgan without deps since basicsr is already installed
418+
if pip install git+https://github.com/Disty0/BasicSR.git --quiet 2>&1 && \
419+
pip install gfpgan --no-deps --quiet 2>&1; then
420+
echo -e " ${GREEN}${NC} GFPGAN installed (Python 3.13 compatible)"
421+
else
422+
echo -e " ${YELLOW}!${NC} GFPGAN failed - enhancement disabled (swap still works)"
423+
fi
400424
else
401-
echo -e " ${YELLOW}!${NC} GFPGAN failed - enhancement disabled (swap still works)"
425+
# Python 3.12 and earlier - normal install works fine
426+
if pip install gfpgan --quiet 2>&1; then
427+
echo -e " ${GREEN}${NC} GFPGAN installed"
428+
else
429+
echo -e " ${YELLOW}!${NC} GFPGAN failed - enhancement disabled (swap still works)"
430+
fi
402431
fi
403432

404433
deactivate

0 commit comments

Comments
 (0)