How kkogggokk/fancam_inyourarea works
Project type and purpose
• This is a full-stack AI video-processing pipeline with four major phases: data collection, model training/inference, video cropping, and a FastAPI-based web front-end.
• Purpose: ingest raw concert footage, detect and track individual Blackpink members’ faces via YOLOv5, crop personalized “fancam” videos per member, and serve them through a web UI.
Main components
a. Data-Collecting Module
• .py (Selenium + OpenCV): scrapes images & samples frames every 15 frames from input videos.
b. Modeling Module
• modeling/yolov5 (PyTorch-based YOLOv5 code) for training & inference.
• detect.py: runs inference per frame, writes normalized xywh + class to CSV (loc_test.csv).
c. Video-Cropping Module
• Jupyter notebooks in video-crop/:
• blackpick_csv_seperate.ipynb (fills missing coords, smoothing)
• blackpink_videocrop.ipynb (reads CSV, crops frames to fixed WxH, writes per-member MP4s via OpenCV VideoWriter)
d. Web Service Module
• web/app: FastAPI app (main3.py + helpers.py + Markdown pages)
• web/static: CSS, JS (Popcorn.js), images, cropped videos
• web/templates: Jinja2 HTML (base.html, include/sidebar/topnav, page.html)
• web/requirements.txt lists dependencies
e. Infrastructure & Deployment
• Docker (Dockerfile not shown but implied)
• AWS (EC2 hosting), Nginx (reverse proxy), H.264 video transcoding codec
Relationships and data flow
• Raw video files → Data-Collecting Module → sampled frame images → labeling (manual) → Training in Modeling Module → trained YOLOv5 model
• New input videos + trained model → detect.py → per-frame CSV of face coordinates → video-crop notebooks → cropped member videos
• Cropped videos + FastAPI back-end → served to user’s browser (UI syncs multiple video players via Popcorn.js)
• All services containerized and deployed behind Nginx on AWS
Architectural patterns & design principles
• Modular batch pipeline: each phase (collect → train → infer → crop) is a standalone component with clear I/O (files, CSVs).
• Microservice-like separation: the web front-end is distinct from heavy compute modules.
• Separation of concerns: static assets vs. dynamic API vs. compute jobs.
Relevant technologies & frameworks
• Python ecosystem: OpenCV, Pandas, NumPy for data prep; PyTorch YOLOv5 for detection; FastAPI for REST/web layers.
• Front-end: HTML templates (Jinja2), CSS, JS (Popcorn.js for video sync).
• Deployment: Docker containers, AWS EC2, Nginx proxy, H.264 video codec for browser compatibility.