The Magika object.
Example usage:
const data = await readFile('some file');
const magika = new Magika();
await magika.load();
const prediction = await magika.identifyBytes(data);
console.log(prediction);
For a Node implementation, see <MAGIKA_REPO>/js/index.js
, which you can run with yarn run bin -h
.
For a web version, see <MAGIKA_REPO>/docs/src/components/FileClassifierDemo.vue
,
Loads the Magika model and config from URLs.
-
$0
Object$0.modelURL
$0.configURL
-
modelURL
string The URL where the model is stored. -
configURL
string The URL where the config is stored.Both parameters are optional. If not provided, the model will be loaded from Github.
Identifies the content type of a byte stream.
fileBytes
any a Buffer object (a fixed-length sequence of bytes)
Returns any A dictionary containing the top label and its score,
Identifies the content type of a byte stream, returning all probabilities instead of just the top one.
fileBytes
any a Buffer object (a fixed-length sequence of bytes)
Returns any A dictionary containing the top label, its score, and a list of content types and their scores.