About this project
Magika is an AI-powered file type detection tool from Google that uses a compact deep learning model (only a few MB) to identify file content types. According to the README, it was trained and evaluated on roughly 100 million samples covering more than 200 content types, including both binary and textual formats, and reports about 99% average precision and recall on its test set. Inference takes roughly 5ms per file on a single CPU after the model is loaded, and the time is near-constant regardless of file size because only a limited portion of the content is used.
The project is distributed as a command line tool written in Rust, a Python API, and bindings for Rust, JavaScript/TypeScript (with an npm package powering a browser-based demo), and Go (described as work in progress). Installation options include pipx, Homebrew, an installer script for Unix and PowerShell, cargo, pip, and npm.
The CLI supports recursive scanning, reading from standard input, JSON and JSONL output, custom output formats, MIME type and label output, and score printing. It also offers prediction modes such as high-confidence, medium-confidence, and best-guess, plus a per-content-type threshold system that can return generic labels like "Generic text document" or "Unknown binary data" when the model is not confident.
The README states Magika is used at scale inside Google to route Gmail, Drive, and Safe Browsing files to appropriate security and content policy scanners, and that it has been integrated with VirusTotal and abuse.ch. A web demo runs locally in the browser. The project is licensed under Apache 2.0 and includes a disclaimer that it is not an official Google project.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.