FaceAutoVN is a Python-based automation framework combining ADB control and AI-driven image processing (YOLOv10) for seamless Facebook account creation on Android devices. App code is organized under src/faceautovn/; launchers remain in the project root for easy running.
-
Objective: Achieve end-to-end Facebook signup automation—UI detection, form filling, email verification—reducing manual interaction to zero.
-
End-to-end Pipeline:
- Initialize ADBController & scrcpy screen streaming.
- Acquire and preprocess frames (360×800 pixels) for YOLOv10.
- Perform real-time inference (200ms/frame) to detect UI elements.
- Execute taps and text inputs via ADB commands.
- Automate temporary email creation, code polling, and submission.
+-----------------+ +---------------+ +-------------+
| src/faceautovn/ | ----> | ADBController| ----> | Android |
| main.py | | adb.py | | Device |
| YOLO Model) | +---------------+ +-------------+
| | |
| | v
| | +---------------+
| | ----> | Email Service|
+-----------------+ | tempmail API |
+---------------+
- src/faceautovn/main.py orchestrates threads for screen capture, YOLO inference, and action handling.
- src/faceautovn/adb.py provides atomic ADB operations:
tap(),long_press(),input_text(),capture_screenshot(). - Email Service: REST API integration to
tempmail.id.vnfor disposable mailbox operations.
-
Model Performance: YOLOv10 fine-tuned on ~1,000 annotated Facebook UI frames. Achieves mAP@0.5 = 0.87, Precision = 0.92, Recall = 0.89.
-
Inference Metrics: Average latency 200ms per frame on Intel i7 CPU, throughput >5 FPS.
-
Complexity Analysis:
- Inference: O(n·d²) where n=boxes, d=image size downsample factor.
- ADB I/O: network-bound shell commands with average round-trip 50–100ms.
-
Concurrency: Event-driven multithreading using Python
threading.Eventto coordinate capture and processing pipelines, ensuring <10% CPU overhead on a quad-core system.
git clone https://github.com/TranDangKhoaAutomation/FaceAutoVN.git
cd FaceAutoVN
pip install -r requirements.txtFaceAutoVN/
├─ src/faceautovn/ # code Python chính
│ ├─ main.py # app automation chính
│ ├─ adb.py # ADBController
│ ├─ test_model.py # test model bằng console
│ ├─ test_model_gui.py # GUI Qt6 test model
│ └─ legacy/ # script cũ/thử nghiệm, chưa dùng trong flow chính
├─ data/ # model local, ví dụ best.pt
├─ assets/images/ # ảnh input/test tĩnh
├─ assets/templates/ # template ảnh cho script legacy nếu cần
├─ outputs/ # ảnh/log sinh ra khi chạy
├─ run_app.bat # launcher app chính
├─ test_model_gui.bat # launcher GUI test model
└─ test_model_cli.bat # launcher test model console
- Python 3.8+
- ADB & scrcpy (v1.16+) in PATH
- Internet connection for REST API and optional remote inference fallback
- Optional: Android emulator
run_app.bat hỏi Họ và Tên ở đầu mỗi lần chạy. Nhấn Enter ở từng ô để app chọn ngẫu nhiên tên tiếng Việt cho ô đó. Ngày sinh hợp lệ được chọn ngẫu nhiên trong khoảng 1990–2003. Có thể nhập trực tiếp chữ có dấu, ví dụ Nguyễn; app dùng Android UI Automator để điền Unicode. Chuỗi Telex như nguyenex không cần thiết khi nhập vào điện thoại.
App ưu tiên model local data/best.pt. Có thể đặt biến môi trường MODEL_PATH để dùng file khác. Đặt SAFE_DRY_RUN=1 để chỉ nhận diện và ghi log mà không thao tác trên điện thoại. Mặc định, app gửi thao tác thật.
Để dùng API email, đặt biến môi trường TEMPMAIL_TOKEN hoặc tạo file local_settings.json ở thư mục gốc với nội dung {"TEMPMAIL_TOKEN":"token-cua-ban"}. File này được Git bỏ qua. Không đưa token thật vào mã nguồn.
run_app.batHoặc chạy trực tiếp:
python src/faceautovn/main.py- Nếu
data/best.pttồn tại, app tự ưu tiên dùng model local đó qua Ultralytics YOLO. - Có thể override đường dẫn model bằng biến môi trường
MODEL_PATH. - Auto-launches scrcpy, opens OpenCV display buffer.
- Orchestrates detection → action → email polling → confirmation cycle.
test_model_gui.batHoặc chạy trực tiếp:
python src/faceautovn/test_model_gui.pyGiao diện Qt6/PySide6 cho phép chọn data/best.pt, chọn ảnh test, chỉnh confidence, chạy detect nền, xem box trực tiếp, xem bảng kết quả và lưu ảnh output.
Có thể tự click kiểm thử GUI + model bằng:
test_model_gui.bat --self-testHoặc:
python src/faceautovn/test_model_gui.py --self-testNếu chỉ muốn test nhanh bằng console:
test_model_cli.batHoặc:
python src/faceautovn/test_model.py --image assets/images/imgkiemtra.pngScript console sẽ load data/best.pt, chạy predict trên ảnh test, in danh sách object phát hiện và lưu ảnh đã vẽ box tại outputs/test_model_output.jpg.
from src.faceautovn.adb import ADBController
# Initialize controller
device = ADBController(id_device=None, debug=True)
# Screen capture
screenshot = device.capture_screenshot("frame.png")
# UI interactions
device.tap(150, 300)
device.long_press(150, 300, duration_ms=2000)
# Text input
device.input_text("Hello FB", delete=True)
device.delete_left(5)
# Swipe and navigation
device.swipe(100, 500, 100, 100, duration=800)
device.press_back()
device.press_home()- All methods are thread-safe and managed via internal locks.
- Frame Acquisition:
capture_screenshot()→ BGR NumPy array. - Preprocessing: Resize to 360×800, convert to RGB PIL.
- Inference:
predictions = model.infer(pil_img)[0].predictions. - Postprocessing: Iterate predictions to draw bounding boxes and store metadata.
- Event Coordination:
detect_event.set()signals UI thread for next iteration.
Kết quả test model hiện lưu tại:
outputs/test_model_output.jpg
outputs/test_model_gui_output.jpg
Bounding boxes on Facebook UI.
Nếu có video demo, đặt trong thư mục video/ và cập nhật link tại đây.
Full-cycle automation demo depends on connected Android device/emulator.
adb shell "i=0; while [ $i -lt 3000 ]; do cmd statusbar collapse >/dev/null 2>&1; am force-stop com.android.settings >/dev/null 2>&1; input keyevent KEYCODE_HOME >/dev/null 2>&1; svc wifi enable >/dev/null 2>&1; svc data enable >/dev/null 2>&1; settings put global airplane_mode_on 0 >/dev/null 2>&1; i=$((i+1)); sleep 0.1; done"© 2025 FaceAutoVN by Tran Dang Khoa. All rights reserved.
- License: MIT (see LICENSE).
- Acknowledgements: YOLOv10, OpenCV, scrcpy, tempmail.id.vn