{ "cells": [ { "cell_type": "code", "source": [ "# from google.colab import drive\n", "# drive.mount('/content/drive')" ], "metadata": { "id": "vNsOH9PHB4NW" }, "id": "vNsOH9PHB4NW", "execution_count": 10, "outputs": [] }, { "cell_type": "code", "source": [ "# %cd /content/drive/MyDrive/" ], "metadata": { "id": "OJ-Hk1OeB-96" }, "id": "OJ-Hk1OeB-96", "execution_count": 11, "outputs": [] }, { "cell_type": "code", "source": [ "# !unzip dataset.zip" ], "metadata": { "collapsed": true, "id": "tRv7gMLpCDx_" }, "id": "tRv7gMLpCDx_", "execution_count": 12, "outputs": [] }, { "cell_type": "markdown", "id": "title-cell", "metadata": { "id": "title-cell" }, "source": [ "# 📊 Phân Tích Dataset Nhận Dạng Ngôn Ngữ Ký Hiệu (Sign Language)\n", "\n", "> **Mục tiêu:** Phân tích toàn diện bộ dữ liệu video MP4 phân loại theo nhãn ngôn ngữ ký hiệu tiếng Việt.\n", "\n", "---\n", "| Mục | Nội dung |\n", "|-----|----------|\n", "| 📁 Định dạng | Video MP4 ngắn |\n", "| 🏷️ Bài toán | Phân loại đa nhãn (Multi-class Classification) |\n", "| 🗂️ Cấu trúc | Thư mục nhãn → video |\n", "| 📍 Đường dẫn | `/content/drive/MyDrive/train/` |" ] }, { "cell_type": "markdown", "id": "section-0", "metadata": { "id": "section-0" }, "source": [ "## 0️⃣ Cài đặt & Import thư viện" ] }, { "cell_type": "code", "execution_count": 13, "id": "install-libs", "metadata": { "id": "install-libs" }, "outputs": [], "source": [ "# Cài đặt thư viện cần thiết\n", "!pip install opencv-python-headless moviepy tqdm tabulate seaborn --quiet" ] }, { "cell_type": "code", "execution_count": 14, "id": "imports", "metadata": { "id": "imports", "colab": { "base_uri": "https://localhost:8080/" }, "outputId": "be22d4df-1251-4ddc-f35d-edd1a28cfa23" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "✅ Đã import đầy đủ thư viện!\n" ] } ], "source": [ "import os\n", "import glob\n", "import json\n", "import warnings\n", "import numpy as np\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "import matplotlib.patches as mpatches\n", "import matplotlib.gridspec as gridspec\n", "from matplotlib.colors import LinearSegmentedColormap\n", "import seaborn as sns\n", "from pathlib import Path\n", "from tqdm import tqdm\n", "from tabulate import tabulate\n", "import cv2\n", "\n", "warnings.filterwarnings('ignore')\n", "\n", "# ── Cấu hình matplotlib đẹp ──────────────────────────────────────────────────\n", "plt.rcParams.update({\n", " 'figure.dpi': 150,\n", " 'font.family': 'DejaVu Sans',\n", " 'axes.spines.top': False,\n", " 'axes.spines.right': False,\n", " 'axes.grid': True,\n", " 'grid.alpha': 0.3,\n", " 'grid.linestyle': '--',\n", "})\n", "\n", "# Bảng màu chủ đạo\n", "PALETTE_MAIN = '#4361EE'\n", "PALETTE_SEC = '#F72585'\n", "PALETTE_ACCENT = '#7209B7'\n", "PALETTE_OK = '#06D6A0'\n", "PALETTE_WARN = '#FFB703'\n", "GRADIENT = LinearSegmentedColormap.from_list(\n", " 'custom_gradient', ['#4361EE', '#7209B7', '#F72585'])\n", "\n", "print('✅ Đã import đầy đủ thư viện!')" ] }, { "cell_type": "markdown", "id": "section-mount", "metadata": { "id": "section-mount" }, "source": [ "## 1️⃣ Kết nối Google Drive & Khai báo đường dẫn" ] }, { "cell_type": "code", "execution_count": 15, "id": "mount-drive", "metadata": { "id": "mount-drive", "colab": { "base_uri": "https://localhost:8080/" }, "outputId": "fef7910f-8377-4d52-ff44-572ecb2d4ce5" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n", "📁 TRAIN : /content/drive/MyDrive/train → exists=True\n" ] } ], "source": [ "from google.colab import drive\n", "drive.mount('/content/drive')\n", "\n", "# ── Đường dẫn dataset ────────────────────────────────────────────────────────\n", "TRAIN_DIR = Path('/content/drive/MyDrive/train')\n", "\n", "print(f'📁 TRAIN : {TRAIN_DIR} → exists={TRAIN_DIR.exists()}')" ] }, { "cell_type": "markdown", "id": "section-scan", "metadata": { "id": "section-scan" }, "source": [ "## 2️⃣ Quét & Thu thập thông tin Dataset" ] }, { "cell_type": "code", "execution_count": 16, "id": "scan-dataset", "metadata": { "id": "scan-dataset", "colab": { "base_uri": "https://localhost:8080/", "height": 399 }, "outputId": "e13278cc-208b-4d6b-f283-b3019b254c53" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "\n", "🔍 Đang quét [train] — 100 nhãn ...\n" ] }, { "output_type": "stream", "name": "stderr", "text": [ "[train]: 100%|██████████| 100/100 [00:32<00:00, 3.04it/s]" ] }, { "output_type": "stream", "name": "stdout", "text": [ "\n", "✅ TRAIN: 3,875 video\n" ] }, { "output_type": "stream", "name": "stderr", "text": [ "\n" ] }, { "output_type": "execute_result", "data": { "text/plain": [ " split label filename \\\n", "0 train An ủi 334053.mp4 \n", "1 train An ủi 207473.mp4 \n", "2 train An ủi 343962.mp4 \n", "3 train An ủi 542417.mp4 \n", "4 train An ủi 127824_3.mp4 \n", "\n", " filepath size_mb fps \\\n", "0 /content/drive/MyDrive/train/An ủi/334053.mp4 0.052 18.73 \n", "1 /content/drive/MyDrive/train/An ủi/207473.mp4 0.088 20.01 \n", "2 /content/drive/MyDrive/train/An ủi/343962.mp4 0.095 19.16 \n", "3 /content/drive/MyDrive/train/An ủi/542417.mp4 0.086 20.01 \n", "4 /content/drive/MyDrive/train/An ủi/127824_3.mp4 0.068 12.50 \n", "\n", " total_frames width height duration_s \n", "0 30 224 224 1.602 \n", "1 30 224 224 1.499 \n", "2 30 224 224 1.566 \n", "3 30 224 224 1.499 \n", "4 30 224 224 2.400 " ], "text/html": [ "\n", "
| \n", " | split | \n", "label | \n", "filename | \n", "filepath | \n", "size_mb | \n", "fps | \n", "total_frames | \n", "width | \n", "height | \n", "duration_s | \n", "
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "train | \n", "An ủi | \n", "334053.mp4 | \n", "/content/drive/MyDrive/train/An ủi/334053.mp4 | \n", "0.052 | \n", "18.73 | \n", "30 | \n", "224 | \n", "224 | \n", "1.602 | \n", "
| 1 | \n", "train | \n", "An ủi | \n", "207473.mp4 | \n", "/content/drive/MyDrive/train/An ủi/207473.mp4 | \n", "0.088 | \n", "20.01 | \n", "30 | \n", "224 | \n", "224 | \n", "1.499 | \n", "
| 2 | \n", "train | \n", "An ủi | \n", "343962.mp4 | \n", "/content/drive/MyDrive/train/An ủi/343962.mp4 | \n", "0.095 | \n", "19.16 | \n", "30 | \n", "224 | \n", "224 | \n", "1.566 | \n", "
| 3 | \n", "train | \n", "An ủi | \n", "542417.mp4 | \n", "/content/drive/MyDrive/train/An ủi/542417.mp4 | \n", "0.086 | \n", "20.01 | \n", "30 | \n", "224 | \n", "224 | \n", "1.499 | \n", "
| 4 | \n", "train | \n", "An ủi | \n", "127824_3.mp4 | \n", "/content/drive/MyDrive/train/An ủi/127824_3.mp4 | \n", "0.068 | \n", "12.50 | \n", "30 | \n", "224 | \n", "224 | \n", "2.400 | \n", "