Starting the Server
Ensure Predictions Exist
The UI loads predictions from
artifacts/predictions.json. Run the full pipeline first:Open the Interface
Navigate to http://localhost:8000 in your browser.
Works best in Chrome/Edge. Safari may have video playback issues with certain codecs.
Interface Layout
The UI has three main sections:Left Sidebar: Folder Buttons
- Lists all category folders with video counts
- Click to assign current video to that folder
- Keyboard shortcuts: 1-8 for first 8 folders
- Predicted folder has blue border highlight
- Low-confidence predictions have orange border
Center: Video Player
- Full-screen video with auto-play
- Space: Play/pause
- Arrow keys: Skip forward/backward 5 seconds
- Auto-advances to next video after sorting
Right Panel: Predictions
- Top-3 predicted folders with confidence bars
- Current video filename
- Progress counter: “23 / 42 remaining”
- Progress bar visualization
- Retrain button (triggers full pipeline)
Labeling Workflow
Review Prediction
The interface auto-loads the first unsorted video and shows predictions:The predicted folder (soccer) is highlighted with a blue border in the left sidebar.
Accept or Override
If prediction is correct:
- Click the highlighted folder button or press its number key (e.g.,
5for soccer) - Video is moved to that folder and removed from unsorted queue
- Click the correct folder button (e.g., “travel”)
- Press the correct folder’s number key
The interface automatically advances to the next video after sorting.
Handle Uncertain Predictions
Low-confidence predictions (<70%) show an orange border:Options:
- Watch the full video to decide
- Assign to the most appropriate folder
- Skip with Ctrl+→ if you need to review later (manually refresh)
Keyboard Shortcuts
| Key | Action |
|---|---|
| 1-8 | Assign video to folder 1-8 |
| Space | Play/pause video |
| ←/→ | Skip backward/forward 5 seconds |
| M | Mute/unmute |
Number keys are assigned to folders in alphabetical order. Check the left sidebar for the mapping.
Active Learning: Retrain Workflow
After manually labeling videos, you can retrain the model directly from the UI:Click Retrain Button
Located in the right panel. Clicking triggers:
- Feature extraction (
extract_features.py) - Model training (
train.py) - Prediction generation (
predict.py)
Monitor Progress
The retrain process runs in the background (may take 5-30 minutes depending on dataset size).Check server logs for real-time progress:
API Endpoints
The server exposes these endpoints (used by the frontend):GET /api/videos
List all unsorted videos with predictions:GET /api/folders
List category folders with counts:POST /api/sort
Move a video to a folder:POST /api/retrain
Trigger full pipeline retrain:GET /api/retrain/status
Check retrain progress:Customizing the Interface
The UI is a single-file HTML application (index.html:1-450). Common customizations:
Changing Video Playback Speed
Editindex.html around line 140:
Auto-advance Delay
Add delay before loading next video:Keyboard Shortcut Changes
Edit key mappings around line 300:Security Considerations
The server is designed for local use only:- Listens on
0.0.0.0:8000(all interfaces) - No authentication
- No HTTPS
- Path traversal protection for filenames
Troubleshooting
Video won't play
Video won't play
Codec compatibility issues. Try re-encoding:Or use Chrome/Edge instead of Safari.
No videos shown (empty queue)
No videos shown (empty queue)
All videos are already sorted (in category folders). To test the interface:
Predictions don't update after retrain
Predictions don't update after retrain
The UI caches predictions on startup. After retraining completes:
- Check server logs confirm “success”
- Hard refresh your browser:
Ctrl+Shift+R(Windows) orCmd+Shift+R(Mac) - Or restart the server:
Retrain button shows 'already running'
Retrain button shows 'already running'
Port 8000 already in use
Port 8000 already in use
Another process is using port 8000. Options:
-
Kill the other process:
-
Use a different port:
Edit
server.py:182:Access viahttp://localhost:8080
Advanced: Batch Import from TikTok
If you have TikTok’s data export:-
Extract videos from the archive:
-
Rename files to numeric format (optional):
-
Run the pipeline:
Performance Optimization
Reduce Server Load
The server loads predictions into memory on startup. For 1000+ videos:Faster Video Serving
Enable FastAPI’sStaticFiles for video directory:
index.html to use /videos/{filename} instead of the custom endpoint.
Next Steps
You’ve completed the full pipeline! From here:Setup
Return to setup to add more categories or scale to larger datasets
Feature Extraction
Re-extract with larger models for better accuracy
Continuous Improvement Loop
- Label videos via UI
- Click Retrain
- Review new predictions
- Repeat until satisfied with accuracy