akuna-infer 0.1.0

Magika file-type detection with Burn
Documentation

License: MIT Crates.io Docs.rs Last Commit CI

akuna-infer

Intelligent file-type inference using the Google Magika ML model in native Rust using Burn.

Runs natively in Rust, supports hardware acceleration, and has zero runtime dependencies.

Features

  • Magika-compatible preprocessing and output post-processing
  • Generic Session<B> and MagikaModel<B> built on Burn's Backend abstraction
  • Vendored standard_v3_3 model from src/vendor/assets/models/standard_v3_3/model.onnx
  • Tested parity against the Rust magika crate on local test fixtures

Usage

use akuna_infer::Session;
use burn_wgpu::{Wgpu, WgpuDevice};
use std::path::Path;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let device = WgpuDevice::default();
    let mut session = Session::<Wgpu>::new(&device)?;

    let detected = session.identify_file_sync(Path::new("target/fixtures/text.pdf"))?;
    assert_eq!(detected.info().label, "pdf");
    assert_eq!(detected.info().mime_type, "application/pdf");

    Ok(())
}

Development

This project uses a Nix development shell.

If you use nix-direnv, it should activate automatically.

To enter it manually:

nix develop

Run all checks with:

./scripts/check.sh

Run tests only with:

cargo nextest run

Benchmarks

Run all benchmarks, results are written to target/criterion/.

cargo bench

Scripts

Refresh vendored upstream code and detection model:

./scripts/update_vendor.sh