help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • Blog
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
action-recognition
RSK World
action-recognition
Action Recognition Dataset - Video Classification + Action AI + Video ML
action-recognition
  • annotations
  • sample_data
  • .gitignore1.2 KB
  • LICENSE.txt3.3 KB
  • README.md13.1 KB
  • RELEASE_NOTES.md4 KB
  • action-recognition.png150.5 KB
  • api_server.py16.1 KB
  • augmentation.py15.9 KB
  • benchmark.py20.6 KB
  • config.json2.8 KB
  • convert_videos.py3.5 KB
  • create_logo.py5.5 KB
  • demo.html28.3 KB
  • download_real_human_videos.py12.6 KB
  • download_real_videos.py21.1 KB
  • download_ucf101.py19.6 KB
  • download_youtube_videos.py10.1 KB
  • favicon.png786 B
  • generate_browser_videos.py10.7 KB
  • generate_samples.py19.4 KB
  • get_real_videos.py8.2 KB
  • index.html38.8 KB
  • loader.py8.9 KB
  • logo.png8.5 KB
  • process_downloaded.py4.6 KB
  • real_running_preview.png195.6 KB
  • real_video_preview.png330.6 KB
  • realtime_predictor.py14.3 KB
  • requirements.txt1.9 KB
  • script.js13.8 KB
  • styles.css39.4 KB
  • train_model.py20.5 KB
  • video_preview.png61.3 KB
  • visualize_dataset.py18 KB
backtesting.pyscript.jsloader.py
script.js
Raw Download
Find: Go to:
/**
 * ==================================================================================
 *    Action Recognition Dataset - JavaScript
 * ==================================================================================
 *    Project: Action Recognition Dataset
 *    Category: Video Data / Data Science
 *    
 * ==================================================================================
 *    DEVELOPER INFORMATION
 * ==================================================================================
 *    Website: RSK World (https://rskworld.in)
 *    Founded by: Molla Samser
 *    Designer & Tester: Rima Khatun
 *    
 *    Contact Information:
 *    - Email: help@rskworld.in
 *    - Email: support@rskworld.in
 *    - Phone: +91 93305 39277
 *    
 * ==================================================================================
 *    COPYRIGHT
 * ==================================================================================
 *    © 2026 RSK World. All Rights Reserved.
 *    
 * ==================================================================================
 */

// Wait for DOM to be fully loaded
document.addEventListener('DOMContentLoaded', function() {
    initNavbar();
    initMobileMenu();
    initBackToTop();
    initCounterAnimation();
    initCodeTabs();
    initFolderToggle();
    initVideoPlayer();
    initSmoothScroll();
});

/**
 * Navbar scroll effect
 * Adds background blur and shadow when scrolled
 */
function initNavbar() {
    const navbar = document.getElementById('navbar');
    
    function handleScroll() {
        if (window.scrollY > 50) {
            navbar.classList.add('scrolled');
        } else {
            navbar.classList.remove('scrolled');
        }
    }
    
    window.addEventListener('scroll', handleScroll);
    handleScroll(); // Check initial state
}

/**
 * Mobile menu toggle
 */
function initMobileMenu() {
    const mobileMenuBtn = document.getElementById('mobileMenuBtn');
    const mobileMenu = document.getElementById('mobileMenu');
    
    if (!mobileMenuBtn || !mobileMenu) return;
    
    mobileMenuBtn.addEventListener('click', function() {
        mobileMenu.classList.toggle('active');
        this.classList.toggle('active');
    });
    
    // Close menu when clicking on a link
    const mobileLinks = mobileMenu.querySelectorAll('.mobile-link');
    mobileLinks.forEach(link => {
        link.addEventListener('click', function() {
            mobileMenu.classList.remove('active');
            mobileMenuBtn.classList.remove('active');
        });
    });
    
    // Close menu when clicking outside
    document.addEventListener('click', function(e) {
        if (!mobileMenu.contains(e.target) && !mobileMenuBtn.contains(e.target)) {
            mobileMenu.classList.remove('active');
            mobileMenuBtn.classList.remove('active');
        }
    });
}

/**
 * Back to top button
 */
function initBackToTop() {
    const backToTop = document.getElementById('backToTop');
    
    if (!backToTop) return;
    
    function handleScroll() {
        if (window.scrollY > 500) {
            backToTop.classList.add('visible');
        } else {
            backToTop.classList.remove('visible');
        }
    }
    
    window.addEventListener('scroll', handleScroll);
    
    backToTop.addEventListener('click', function() {
        window.scrollTo({
            top: 0,
            behavior: 'smooth'
        });
    });
}

/**
 * Counter animation for stats
 */
function initCounterAnimation() {
    const counters = document.querySelectorAll('.stat-number[data-count]');
    
    const observerOptions = {
        threshold: 0.5,
        rootMargin: '0px'
    };
    
    const observer = new IntersectionObserver((entries) => {
        entries.forEach(entry => {
            if (entry.isIntersecting) {
                animateCounter(entry.target);
                observer.unobserve(entry.target);
            }
        });
    }, observerOptions);
    
    counters.forEach(counter => {
        observer.observe(counter);
    });
}

/**
 * Animate a single counter
 */
function animateCounter(element) {
    const target = parseInt(element.getAttribute('data-count'));
    const duration = 2000;
    const step = target / (duration / 16);
    let current = 0;
    
    const timer = setInterval(() => {
        current += step;
        if (current >= target) {
            element.textContent = target.toLocaleString();
            clearInterval(timer);
        } else {
            element.textContent = Math.floor(current).toLocaleString();
        }
    }, 16);
}

/**
 * Code tabs functionality
 */
function initCodeTabs() {
    const tabs = document.querySelectorAll('.code-tab');
    const panels = document.querySelectorAll('.code-panel');
    
    tabs.forEach(tab => {
        tab.addEventListener('click', function() {
            const targetTab = this.getAttribute('data-tab');
            
            // Remove active class from all tabs and panels
            tabs.forEach(t => t.classList.remove('active'));
            panels.forEach(p => p.classList.remove('active'));
            
            // Add active class to clicked tab and corresponding panel
            this.classList.add('active');
            document.getElementById(targetTab).classList.add('active');
        });
    });
}

/**
 * Folder toggle in file tree
 */
function initFolderToggle() {
    // Toggle folder function is called inline in HTML
    // This function handles the visual feedback
}

function toggleFolder(element) {
    const parent = element.closest('.tree-item');
    const subTree = parent.querySelector('.sub-tree');
    
    if (subTree) {
        subTree.classList.toggle('collapsed');
        const icon = element.querySelector('i');
        if (icon) {
            icon.classList.toggle('fa-folder');
            icon.classList.toggle('fa-folder-open');
        }
    }
}

/**
 * Real Video Player for hero section
 * Displays actual sample videos from the dataset
 */
function initVideoPlayer() {
    const heroVideo = document.getElementById('heroVideo');
    const actionLabel = document.getElementById('actionLabel');
    const confidenceValue = document.getElementById('confidenceValue');
    const videoTitle = document.getElementById('videoTitle');
    const prevBtn = document.getElementById('prevVideo');
    const nextBtn = document.getElementById('nextVideo');
    const currentIndexEl = document.getElementById('currentVideoIndex');
    const totalVideosEl = document.getElementById('totalVideos');
    const thumbnails = document.querySelectorAll('.thumbnail');
    const timelineProgress = document.getElementById('timelineProgress');
    
    if (!heroVideo) return;
    
    // Video list with labels and confidence scores
    const videos = [
        { src: 'sample_data/train/dancing/dancing_001.mp4', label: 'Dancing', confidence: 98.5, file: 'dancing_001.mp4' },
        { src: 'sample_data/train/running/running_001.mp4', label: 'Running', confidence: 96.2, file: 'running_001.mp4' },
        { src: 'sample_data/train/walking/walking_001.mp4', label: 'Walking', confidence: 97.8, file: 'walking_001.mp4' },
        { src: 'sample_data/train/jumping/jumping_001.mp4', label: 'Jumping', confidence: 94.8, file: 'jumping_001.mp4' },
        { src: 'sample_data/train/yoga/yoga_001.mp4', label: 'Yoga', confidence: 95.3, file: 'yoga_001.mp4' },
        { src: 'sample_data/train/stretching/stretching_001.mp4', label: 'Stretching', confidence: 93.7, file: 'stretching_001.mp4' },
        { src: 'sample_data/train/exercising/exercising_001.mp4', label: 'Exercising', confidence: 92.5, file: 'exercising_001.mp4' }
    ];
    
    let currentIndex = 0;
    
    // Update total videos count
    if (totalVideosEl) {
        totalVideosEl.textContent = videos.length;
    }
    
    function loadVideo(index) {
        const video = videos[index];
        
        // Update video source
        heroVideo.src = video.src;
        heroVideo.load();
        heroVideo.play().catch(e => console.log('Auto-play prevented'));
        
        // Update labels with animation
        if (actionLabel) {
            actionLabel.style.opacity = '0';
            setTimeout(() => {
                actionLabel.textContent = video.label;
                if (confidenceValue) {
                    confidenceValue.textContent = video.confidence + '%';
                }
                actionLabel.style.opacity = '1';
            }, 200);
        }
        
        // Update video title
        if (videoTitle) {
            videoTitle.textContent = video.file;
        }
        
        // Update index display
        if (currentIndexEl) {
            currentIndexEl.textContent = index + 1;
        }
        
        // Update thumbnail active state
        thumbnails.forEach((thumb, i) => {
            if (i === index) {
                thumb.classList.add('active');
            } else {
                thumb.classList.remove('active');
            }
        });
    }
    
    // Navigation buttons
    if (prevBtn) {
        prevBtn.addEventListener('click', () => {
            currentIndex = (currentIndex - 1 + videos.length) % videos.length;
            loadVideo(currentIndex);
        });
    }
    
    if (nextBtn) {
        nextBtn.addEventListener('click', () => {
            currentIndex = (currentIndex + 1) % videos.length;
            loadVideo(currentIndex);
        });
    }
    
    // Thumbnail click handlers
    thumbnails.forEach((thumb, index) => {
        thumb.addEventListener('click', () => {
            currentIndex = index;
            loadVideo(currentIndex);
        });
    });
    
    // Video timeline progress
    if (heroVideo && timelineProgress) {
        heroVideo.addEventListener('timeupdate', () => {
            const progress = (heroVideo.currentTime / heroVideo.duration) * 100;
            timelineProgress.style.width = progress + '%';
        });
        
        // Loop to next video when current ends
        heroVideo.addEventListener('ended', () => {
            currentIndex = (currentIndex + 1) % videos.length;
            loadVideo(currentIndex);
        });
    }
    
    // Auto-cycle videos every 8 seconds
    let autoPlayInterval = setInterval(() => {
        currentIndex = (currentIndex + 1) % videos.length;
        loadVideo(currentIndex);
    }, 8000);
    
    // Pause auto-cycle on hover
    const videoShowcase = document.querySelector('.video-showcase');
    if (videoShowcase) {
        videoShowcase.addEventListener('mouseenter', () => {
            clearInterval(autoPlayInterval);
        });
        
        videoShowcase.addEventListener('mouseleave', () => {
            autoPlayInterval = setInterval(() => {
                currentIndex = (currentIndex + 1) % videos.length;
                loadVideo(currentIndex);
            }, 8000);
        });
    }
    
    // Initial setup
    if (actionLabel) {
        actionLabel.style.transition = 'opacity 0.2s ease';
    }
}

/**
 * Smooth scroll for navigation links
 */
function initSmoothScroll() {
    const links = document.querySelectorAll('a[href^="#"]');
    
    links.forEach(link => {
        link.addEventListener('click', function(e) {
            const href = this.getAttribute('href');
            
            if (href === '#') return;
            
            e.preventDefault();
            
            const target = document.querySelector(href);
            if (target) {
                const offsetTop = target.offsetTop - 80;
                
                window.scrollTo({
                    top: offsetTop,
                    behavior: 'smooth'
                });
            }
        });
    });
}

/**
 * Add scroll reveal animations
 */
function initScrollReveal() {
    const elements = document.querySelectorAll('.feature-card, .overview-card');
    
    const observerOptions = {
        threshold: 0.1,
        rootMargin: '0px 0px -50px 0px'
    };
    
    const observer = new IntersectionObserver((entries) => {
        entries.forEach(entry => {
            if (entry.isIntersecting) {
                entry.target.style.opacity = '1';
                entry.target.style.transform = 'translateY(0)';
                observer.unobserve(entry.target);
            }
        });
    }, observerOptions);
    
    elements.forEach((el, index) => {
        el.style.opacity = '0';
        el.style.transform = 'translateY(30px)';
        el.style.transition = `opacity 0.6s ease ${index * 0.1}s, transform 0.6s ease ${index * 0.1}s`;
        observer.observe(el);
    });
}

/**
 * Utility: Debounce function
 */
function debounce(func, wait) {
    let timeout;
    return function executedFunction(...args) {
        const later = () => {
            clearTimeout(timeout);
            func(...args);
        };
        clearTimeout(timeout);
        timeout = setTimeout(later, wait);
    };
}

/**
 * Utility: Throttle function
 */
function throttle(func, limit) {
    let inThrottle;
    return function(...args) {
        if (!inThrottle) {
            func.apply(this, args);
            inThrottle = true;
            setTimeout(() => inThrottle = false, limit);
        }
    };
}

// Console greeting for developers
console.log('%c🎬 Action Recognition Dataset', 'font-size: 24px; font-weight: bold; color: #00d4ff;');
console.log('%cDeveloped by RSK World (rskworld.in)', 'font-size: 14px; color: #94a3b8;');
console.log('%cFounder: Molla Samser | Designer: Rima Khatun', 'font-size: 12px; color: #64748b;');
console.log('%cContact: help@rskworld.in | +91 93305 39277', 'font-size: 12px; color: #64748b;');

437 lines•13.8 KB
javascript
loader.py
Raw Download
Find: Go to:
"""
==================================================================================
    Action Recognition Dataset - Python Loader
==================================================================================
    Project: Action Recognition Dataset
    Category: Video Data / Data Science
    
==================================================================================
    DEVELOPER INFORMATION
==================================================================================
    Website: RSK World (https://rskworld.in)
    Founded by: Molla Samser
    Designer & Tester: Rima Khatun
    
    Contact Information:
    - Email: help@rskworld.in
    - Email: support@rskworld.in
    - Phone: +91 93305 39277
    
==================================================================================
    COPYRIGHT
==================================================================================
    © 2026 RSK World. All Rights Reserved.
    
==================================================================================
"""

import cv2
import os
import json
import numpy as np
from pathlib import Path
from typing import List, Tuple, Dict, Optional


class ActionRecognitionDataset:
    """
    Action Recognition Dataset Loader
    
    A comprehensive video dataset loader for action recognition tasks.
    Supports loading videos, extracting frames, and preprocessing for
    various deep learning frameworks.
    
    Author: Molla Samser (RSK World)
    Website: https://rskworld.in
    Contact: help@rskworld.in
    """
    
    def __init__(
        self,
        root_dir: str,
        split: str = 'train',
        num_frames: int = 16,
        frame_size: Tuple[int, int] = (224, 224),
        normalize: bool = True
    ):
        """
        Initialize the Action Recognition Dataset loader.
        
        Args:
            root_dir: Path to the dataset root directory
            split: Dataset split ('train', 'val', or 'test')
            num_frames: Number of frames to sample from each video
            frame_size: Target frame size (height, width)
            normalize: Whether to normalize pixel values to [0, 1]
        """
        self.root_dir = Path(root_dir)
        self.split = split
        self.num_frames = num_frames
        self.frame_size = frame_size
        self.normalize = normalize
        
        # Load class labels
        self.class_labels = self._load_class_labels()
        self.num_classes = len(self.class_labels)
        
        # Build sample index
        self.samples = self._build_sample_index()
        
        print(f"[RSK World] Loaded {len(self.samples)} samples from {split} split")
        print(f"[RSK World] Number of classes: {self.num_classes}")
    
    def _load_class_labels(self) -> Dict[int, str]:
        """Load class labels from annotation file."""
        label_file = self.root_dir / 'annotations' / 'class_labels.json'
        
        if label_file.exists():
            with open(label_file, 'r') as f:
                data = json.load(f)
                return {int(k): v for k, v in data['classes'].items()}
        else:
            # Infer from directory structure
            split_dir = self.root_dir / self.split
            if split_dir.exists():
                classes = sorted([d.name for d in split_dir.iterdir() if d.is_dir()])
                return {i: c for i, c in enumerate(classes)}
            return {}
    
    def _build_sample_index(self) -> List[Tuple[str, int]]:
        """Build index of all video samples with labels."""
        samples = []
        split_dir = self.root_dir / self.split
        
        if not split_dir.exists():
            print(f"[RSK World] Warning: Split directory not found: {split_dir}")
            return samples
        
        for class_idx, class_name in self.class_labels.items():
            class_dir = split_dir / class_name
            
            if not class_dir.exists():
                continue
            
            for video_file in class_dir.iterdir():
                if video_file.suffix.lower() in ['.mp4', '.avi', '.mov', '.mkv']:
                    samples.append((str(video_file), class_idx))
        
        return samples
    
    def load_video(self, video_path: str) -> np.ndarray:
        """
        Load and preprocess a video file.
        
        Args:
            video_path: Path to the video file
            
        Returns:
            numpy array of shape (num_frames, height, width, channels)
        """
        cap = cv2.VideoCapture(video_path)
        frames = []
        
        while True:
            ret, frame = cap.read()
            if not ret:
                break
            
            # Resize frame
            frame = cv2.resize(frame, self.frame_size)
            
            # Convert BGR to RGB
            frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
            
            frames.append(frame)
        
        cap.release()
        
        if len(frames) == 0:
            # Return zeros if video is empty
            return np.zeros(
                (self.num_frames, self.frame_size[0], self.frame_size[1], 3),
                dtype=np.float32 if self.normalize else np.uint8
            )
        
        # Sample frames uniformly
        indices = np.linspace(0, len(frames) - 1, self.num_frames).astype(int)
        sampled_frames = np.array([frames[i] for i in indices])
        
        # Normalize if required
        if self.normalize:
            sampled_frames = sampled_frames.astype(np.float32) / 255.0
        
        return sampled_frames
    
    def __len__(self) -> int:
        """Return the total number of samples."""
        return len(self.samples)
    
    def __getitem__(self, idx: int) -> Tuple[np.ndarray, int]:
        """
        Get a sample by index.
        
        Args:
            idx: Sample index
            
        Returns:
            Tuple of (frames, label)
        """
        video_path, label = self.samples[idx]
        frames = self.load_video(video_path)
        return frames, label
    
    def get_class_name(self, class_idx: int) -> str:
        """Get class name by index."""
        return self.class_labels.get(class_idx, f"unknown_{class_idx}")
    
    def get_class_distribution(self) -> Dict[str, int]:
        """Get distribution of samples across classes."""
        distribution = {name: 0 for name in self.class_labels.values()}
        
        for _, label in self.samples:
            class_name = self.class_labels[label]
            distribution[class_name] += 1
        
        return distribution


def create_data_generator(
    root_dir: str,
    split: str = 'train',
    batch_size: int = 8,
    num_frames: int = 16,
    shuffle: bool = True
):
    """
    Create a data generator for batch processing.
    
    Author: Molla Samser (RSK World)
    Website: https://rskworld.in
    
    Args:
        root_dir: Path to the dataset root directory
        split: Dataset split ('train', 'val', or 'test')
        batch_size: Number of samples per batch
        num_frames: Number of frames to sample from each video
        shuffle: Whether to shuffle samples
        
    Yields:
        Tuple of (batch_frames, batch_labels)
    """
    dataset = ActionRecognitionDataset(
        root_dir=root_dir,
        split=split,
        num_frames=num_frames
    )
    
    indices = np.arange(len(dataset))
    
    while True:
        if shuffle:
            np.random.shuffle(indices)
        
        for start_idx in range(0, len(indices), batch_size):
            batch_indices = indices[start_idx:start_idx + batch_size]
            
            batch_frames = []
            batch_labels = []
            
            for idx in batch_indices:
                frames, label = dataset[idx]
                batch_frames.append(frames)
                batch_labels.append(label)
            
            yield np.array(batch_frames), np.array(batch_labels)


# Example usage
if __name__ == '__main__':
    print("=" * 60)
    print("Action Recognition Dataset Loader")
    print("RSK World (https://rskworld.in)")
    print("Founder: Molla Samser | Designer: Rima Khatun")
    print("Contact: help@rskworld.in | +91 93305 39277")
    print("=" * 60)
    
    # Example: Load training dataset
    # dataset = ActionRecognitionDataset(
    #     root_dir='./action-recognition',
    #     split='train',
    #     num_frames=16
    # )
    
    # # Get a sample
    # frames, label = dataset[0]
    # print(f"Frames shape: {frames.shape}")
    # print(f"Label: {label} ({dataset.get_class_name(label)})")
    
    # # Get class distribution
    # distribution = dataset.get_class_distribution()
    # print(f"Class distribution: {distribution}")
    
    print("\nDataset loader ready!")
    print("For usage examples, see README.md")

275 lines•8.9 KB
python

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer