|
2 | 2 |
|
3 | 3 | This module contains the business logic specifically designed for the **Whole-Video Classification** task. |
4 | 4 |
|
5 | | -In this mode, the goal is to assign global attributes (labels) to an entire video clip (e.g., "Weather: Sunny", "Action: Goal"). These controllers bridge the gap between the Classification UI (`ui/classification/`) and the central data model (`models.py`). |
| 5 | +In this mode, the goal is to assign global attributes (labels) to an entire video clip (e.g., "Weather: Sunny", "Action: Goal"). With the latest updates, these controllers now bridge the gap between the Classification UI, the central data model (`models.py`), and the **AI-powered `soccernetpro` framework** for smart inference and model training. |
6 | 6 |
|
7 | 7 | ## 📂 Module Contents |
8 | 8 |
|
9 | 9 | ```text |
10 | 10 | controllers/classification/ |
11 | | -├── annotation_manager.py # Labeling logic & Dynamic Schema handling |
12 | | -├── class_file_manager.py # I/O operations (Save/Load/Create) |
13 | | -└── navigation_manager.py # Video list navigation & Playback flow |
14 | | -
|
| 11 | +├── class_annotation_manager.py # Labeling logic, Dynamic Schema & Smart Annotations |
| 12 | +├── class_file_manager.py # I/O operations (Save/Load/Create + Smart Labels) |
| 13 | +├── class_navigation_manager.py # Video list navigation, Filtering & Playback flow |
| 14 | +├── inference_manager.py # [NEW] AI Inference (Single & Batch Prediction) |
| 15 | +└── train_manager.py # [NEW] AI Model Training & Checkpoint logic |
15 | 16 | ``` |
16 | 17 |
|
17 | 18 | --- |
18 | 19 |
|
19 | 20 | ## 📝 File Descriptions |
20 | 21 |
|
21 | | -### 1. `annotation_manager.py` |
22 | | - |
23 | | -**Responsibility:** Manages the labeling process and schema modifications. |
| 22 | +### 1. `class_annotation_manager.py` |
| 23 | +**Responsibility:** Manages the labeling process, schema modifications, and AI prediction confirmations. |
24 | 24 |
|
| 25 | +* **Manual Annotation Management**: Captures the user's selection from the UI (Right Panel), validates it, and commits it to the central State Model. |
| 26 | +* **Smart Annotation Confirmation**: **[NEW]** Handles the logic for confirming AI-generated single and batch predictions, safely migrating them into the application's core memory. |
25 | 27 | * **Dynamic Schema Management**: Handles adding, renaming, or deleting Categories ("Heads") and Labels directly from the UI. |
26 | | -* **Annotation Saving**: Captures the user's selection from the UI (Right Panel), validates it, and commits it to the `AppStateModel`. |
27 | | -* **Undo/Redo Integration**: Pushes commands to the `HistoryManager` when annotations are changed or when the schema structure is modified. |
| 28 | +* **Universal Undo/Redo Integration**: Pushes precise commands to the `HistoryManager` when annotations (manual or smart) are changed, or when the schema structure is modified. |
28 | 29 |
|
29 | 30 | ### 2. `class_file_manager.py` |
| 31 | +**Responsibility:** Handles file input/output, JSON parsing, and project lifecycles. |
30 | 32 |
|
31 | | -**Responsibility:** Handles file input/output and project lifecycle for Classification projects. |
| 33 | +* **Project Creation**: Orchestrates the "New Project" wizard dialog and initializes the model with default or blank schemas. |
| 34 | +* **Robust JSON Handling**: Parses and strictly validates existing Classification JSON files to ensure they match expected dataset structures. |
| 35 | +* **Smart Label I/O**: **[NEW]** Seamlessly reads and exports `smart_labels` alongside traditional manual labels, preserving AI-generated confidence scores. |
| 36 | +* **Relative Pathing**: Converts absolute file paths to relative paths during export to ensure project portability across different machines. |
32 | 37 |
|
33 | | -* **Project Creation**: Orchestrates the "New Project" wizard dialog and initializes the model with the chosen schema. |
34 | | -* **JSON Loading**: Parses existing Classification JSON files, validating that they match the expected format. |
35 | | -* **JSON Saving**: Writes the current state to disk. It handles the critical logic of converting absolute file paths to **relative paths** to ensure portability between different computers. |
36 | | -* **Workspace Management**: Handles clearing the current data when closing a project. |
| 38 | +### 3. `class_navigation_manager.py` |
| 39 | +**Responsibility:** Manages the dataset list (Left Panel), complex filtering, and playback synchronization. |
37 | 40 |
|
38 | | -### 3. `navigation_manager.py` |
| 41 | +* **Model/View Navigation**: Connects the custom `ProjectTreeModel` to the unified `MediaController`, ensuring robust, ghost-frame-free video loading when items are clicked. |
| 42 | +* **Advanced 4-State Filtering**: **[NEW]** Implements sophisticated visibility logic to filter clips by status: *Show All*, *Hand Labelled*, *Smart Labelled*, or *No Labelled*. |
| 43 | +* **Smart Navigation**: Implements logic for "Next Action" (jump to next parent item) and "Next Clip" (jump to next child view), automatically skipping hidden items based on the active filter. |
39 | 44 |
|
40 | | -**Responsibility:** Manages the list of video clips and the user's movement through them. |
| 45 | +### 4. `inference_manager.py` (⭐ NEW) |
| 46 | +**Responsibility:** Orchestrates AI-powered video predictions via the `soccernetpro` inference engine. |
41 | 47 |
|
42 | | -* **Tree Interaction**: Connects the `QTreeWidget` (Left Panel) to the media player, ensuring the correct video loads when clicked. |
43 | | -* **Smart Navigation**: Implements logic for "Next Action" (jump to next parent item) and "Next Clip" (jump to next file), skipping items based on filters. |
44 | | -* **Filtering**: Applies logic to show only "Done", "Not Done", or "All" videos in the list. |
45 | | -* **Media Control**: Triggers video playback and synchronizes the player state with the selected item. |
| 48 | +* **Dynamic Configurations**: Parses `config.yaml` on-the-fly to automatically map AI output indices to human-readable UI labels (eliminating hardcoded sports classes). |
| 49 | +* **Asynchronous Execution**: Uses `QThread` workers (`InferenceWorker` and `BatchInferenceWorker`) to run heavy PyTorch inference without freezing the UI. |
| 50 | +* **Single & Batch Processing**: Allows users to infer the current active video or run sweeping batch predictions across a specified range of clips. |
| 51 | +* **Temporary Workspaces**: Safely handles the creation and cleanup of isolated hidden workspaces (`~/.soccernet_workspace`) to prevent pipeline conflicts. |
46 | 52 |
|
| 53 | +### 5. `train_manager.py` (⭐ NEW) |
| 54 | +**Responsibility:** Handles the background training loop for fine-tuning models on user-annotated data. |
| 55 | + |
| 56 | +* **Hyperparameter Injection**: Collects variables (Epochs, LR, Batch Size, Device, Workers) from the UI and forcefully injects them into a runtime YAML configuration. |
| 57 | +* **Background Training**: Executes the `myModel.train()` process inside a background `QThread` to ensure the application remains responsive. |
| 58 | +* **Console Log Interception**: Uses a custom `io.TextIOBase` stream to intercept PyTorch stdout/stderr, parsing progress steps to drive the UI progress bar and displaying human-readable logs in the application console. |
| 59 | +* **Checkpointing**: Auto-saves model weights into a dynamically generated `checkpoints/` directory alongside the dataset. |
| 60 | +``` |
0 commit comments