Skip to main content

Overview

The TikTok Auto Collection Sorter stores video embeddings and predictions in three main artifact files:
  • labeled_embeddings.pt - Features and labels for training videos
  • unlabeled_embeddings.pt - Features for unsorted videos awaiting classification
  • predictions.json - Model predictions with confidence scores
All .pt files are PyTorch tensors saved with torch.save() and loaded with torch.load().

labeled_embeddings.pt

Generated by extract_features.py:198-205. Contains extracted features from videos already sorted into folders.

File Structure

labeled_embeddings.pt
dict
PyTorch dictionary containing training data.

Loading Example

import torch

# Load labeled embeddings
data = torch.load("artifacts/labeled_embeddings.pt", weights_only=False)

# Access components
features = data["features"]        # torch.Tensor (N, 1024)
labels = data["labels"]            # torch.Tensor (N,)
label_names = data["label_names"]  # list[str]
video_paths = data["video_paths"]  # list[str]

print(f"Loaded {len(features)} videos")
print(f"Categories: {label_names}")
print(f"Feature shape: {features.shape}")  # (150, 1024)

unlabeled_embeddings.pt

Generated by extract_features.py:235-241. Contains extracted features from videos in the root folder (not yet sorted).

File Structure

unlabeled_embeddings.pt
dict
PyTorch dictionary containing features for unsorted videos.Note: No labels or label_names keys since these videos are unlabeled.

Loading Example

import torch

# Load unlabeled embeddings
data = torch.load("artifacts/unlabeled_embeddings.pt", weights_only=False)

features = data["features"]        # torch.Tensor (M, 1024)
video_paths = data["video_paths"]  # list[str]

print(f"Found {len(features)} unsorted videos to classify")

predictions.json

Generated by predict.py:158-173. Contains model predictions for all unsorted videos.

File Structure

predictions.json
list[dict]
JSON array of prediction objects, one per unsorted video.

Complete Example

[
  {
    "video": "tiktok_12345.mp4",
    "predicted_folder": "soccer",
    "confidence": 0.87,
    "top_predictions": [
      {"folder": "soccer", "confidence": 0.87},
      {"folder": "fitness", "confidence": 0.09},
      {"folder": "funny", "confidence": 0.04}
    ]
  },
  {
    "video": "tiktok_67890.mp4",
    "predicted_folder": "music",
    "confidence": 0.62,
    "top_predictions": [
      {"folder": "music", "confidence": 0.62},
      {"folder": "art", "confidence": 0.31},
      {"folder": "funny", "confidence": 0.07}
    ]
  }
]

Loading Example

import json

# Load predictions
with open("artifacts/predictions.json") as f:
    predictions = json.load(f)

for pred in predictions:
    video = pred["video"]
    folder = pred["predicted_folder"]
    conf = pred["confidence"]
    print(f"{video}{folder} ({conf:.0%})")

model_config.json

Generated by train.py:220-225. Stores model metadata and configuration.

File Structure

model_config.json
dict
JSON object containing model configuration and metadata.

Example

{
  "model_type": "mlp",
  "input_dim": 1024,
  "num_classes": 5,
  "hidden_dim": 256,
  "label_names": ["art", "fitness", "funny", "music", "soccer"],
  "feature_dim": 1024,
  "best_cv_accuracy": 0.89
}

Data Flow Summary

  1. Feature Extraction (extract_features.py)
    • Input: Raw .mp4 video files
    • Output: labeled_embeddings.pt + unlabeled_embeddings.pt
  2. Model Training (train.py)
    • Input: labeled_embeddings.pt
    • Output: model.pt + model_config.json
  3. Prediction (predict.py)
    • Input: unlabeled_embeddings.pt + model.pt + model_config.json
    • Output: predictions.json

Build docs developers (and LLMs) love