Face transformation

Copyright © Quectel Wireless Solutions Co., Ltd. 2026. All rights reserved.


This document introduces the face transformation function based on a USB camera and its usage method. This function implements face effect processing through cloud interfaces and provides a graphical interactive interface to help you quickly deploy and verify effects. After completing environment preparation, dependency installation, and parameter configuration, you can run the project on the Quectel Pi H1 smart single-board computer to reproduce the face transformation effect and output the results.

Core supported functions:

  • Face age transformation: Generates face effects of different age stages and synthesize videos for playback.

  • Portrait anime stylization: Converts portraits into anime-style images.

  • Facial gender transformation: Uploads a facial image and leverages face-editing and generative algorithms to generate a gender-swapped output image.

In addition, the project supports automatic identification and activation of camera devices, and outputs running status and log information, making it easy for you to monitor task progress and troubleshoot problems.

../../../_images/image_VdaWbUV7bonCfBxnktmcvjD7nw8.webp

Development resource summary

Development component list

Accessory

Quantity

Specifications

Quectel Pi H1 smart single-board computer


1

Quectel Pi H1 smart single-board computer

OV5693 USB camera module


1

OV5693 USB camera module

2-pin PH1.25 connector speaker


1

2030 cavity speaker; 8 Ω, 2 W; rectangular speaker; compact high-fidelity speaker; 2-pin PH1.25 connector

USB-C power adapter


1

Official 45W USB Type-C Power Supply for Raspberry Pi 5, White Color, US Plug

CPU cooling fan (optional)


1

Raspberry Pi 5 Official Active Cooler with Thermal Pad

Micro HDMI cable


1

Micro HDMI 2.0; cable length: 1 m; interface: HDMI-A (male) to HDMI-D (male)

Ethernet cable


1

Cable length: 1 m; transmission rate: gigabit

Display


1

HDMI monitor

Hardware accessories reference

../../../_images/image_ZB4ebBtKgoa1rvx11F3cfHAxnA5.webp

Quick start

Development preparation

The Quectel Pi H1 comes pre-installed with Debian 13, so reflashing the OS image is typically not required. Follow the steps below to get started:

Hardware connections

Complete all hardware connections by following the steps below (the step numbers correspond to the labels in the interface diagram):

../../../_images/image_UBE2bhzBuoYqb9xNOwWc5ouNnEb.webp
  1. Display connection: Connect one end of the Micro HDMI cable to the Micro HDMI interface of the board, and the other end to the HDMI interface of the monitor.

  2. Network connection: Ensure that the router is connected to the Internet. Then, connect one end of the Ethernet cable to the gigabit Ethernet port of the board, and the other end to the Ethernet port of the router.

  3. Input device connection: Connect input devices such as a USB keyboard, mouse, and OV5693 camera module to the USB interfaces of the board. If you use wireless input devices, connect the wireless receiver to the USB interface of the docking station.

  4. Power supply connection: Connect the USB-A end of the USB-A power cable to the output of the power adapter, and the USB-C end to the power input interface of the board (usually labeled POWER IN).

  5. Cooling fan connection: First, insert the cable of the cooling fan into the FAN slot of the board. Then fix both ends of the cooler into the reserved mounting holes on the board.

Reference for completed connection

After all hardware connections are completed, refer to the following diagram:

../../../_images/image_DJaxbhVzVoBE7MxoRT3cioJYnjb.webp

Project implementation

Update package list

Run the following command to update the package list:

sudo apt update

Install system dependencies

Install basic dependency packages:

sudo apt install -y python3 python3-venv python3-pip ffmpeg git

Install dependencies related to the graphical interface:

sudo apt install -y libxcb-cursor0 libxkbcommon-x11-0 \
  libxcb-xinerama0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0

Create a virtual environment

Create a new project directory:

mkdir -p ~/project

Enter the project directory and create a Python virtual environment:

cd ~/project
python3 -m venv .venv

Activate virtual environment

source ~/project/.venv/bin/activate

Download sample code

cd ~/project
git clone https://github.com/Quectel-Pi/demo-face-transform.git
cd demo-face-transform

Upgrade pip

pip install --upgrade pip

Install project dependencies

pip install -r requirements.txt

Note

Ensure that the virtual environment is activated and execute this command in the demo-face-transform directory (if the path does not match, adjust requirements.txt path ).

Configure secret keys

Before using the face transformation service, activate the relevant Tencent Cloud services and obtain the API keys (SecretId and SecretKey) from the Tencent Cloud Access Management console. For details, see Tencent Cloud portrait transformation API documentation.

Method 1: Read the secret keys from environment variables (example):

export TENCENTCLOUD_SECRET_ID="SecretId"
export TENCENTCLOUD_SECRET_KEY="SecretKey"

Method 2: Configure through the startup script:

Edit the start.sh script and fill in SecretId and SecretKey.

Run program

After activating the Python virtual environment and configuring the API credentials, navigate to the script directory, grant executable permissions, and launch the application:

cd demo-face-transform/src
chmod +x start.sh
./start.sh

Configure remote graphical interface access

To run graphical interface programs in an SSH remote session, complete the following configuration:

  1. Execute the permission configuration command in the local desktop terminal of the device:

xhost +SI:localuser:pi

This command allows the local pi user to access the current X11 display service.

  1. Set the graphical display environment variables in the remote SSH session (taking login as the pi user as an example):

export DISPLAY=:0
export XAUTHORITY=/home/pi/.Xauthority

After the configuration is complete, you can run graphical interface programs in the SSH session.

Application demo

face_transform

Technical support and contributions

If you encounter any issues during use, submit a technical inquiry to the Quectel official forum. Our technical support team will respond promptly.

Project open-source repository: https://github.com/Quectel-Pi/demo-face-transform

Welcome to submit an issue to report a problem or a pull request to improve the code.