<story><title>Magika: AI powered fast and efficient file type identification</title><url>https://opensource.googleblog.com/2024/02/magika-ai-powered-fast-and-efficient-file-type-identification.html</url></story><parent_chain><item><author>stevepike</author><text>Oh man, this brings me back! Almost 10 years ago I was working on a rails app trying to detect the file type of uploaded spreadsheets (xlsx files were being detected as application&amp;#x2F;zip, which is technically true but useless).&lt;p&gt;I found &amp;quot;magic&amp;quot; that could detect these and submitted a patch at &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;bugs.freedesktop.org&amp;#x2F;show_bug.cgi?id=78797&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;bugs.freedesktop.org&amp;#x2F;show_bug.cgi?id=78797&lt;/a&gt;. My patch got rejected for needing to look at the first 3KB bytes of the file to figure out the type. They had a hard limit that they wouldn&amp;#x27;t see past the first 256 bytes. Now in 2024 we&amp;#x27;re doing this with deep learning! It&amp;#x27;d be cool if google released some speed performance benchmarks here against the old-fashioned implementations. Obviously it&amp;#x27;d be slower, but is it 1000x or 10^6x?</text></item></parent_chain><comment><author>ebursztein</author><text>Co-author of Magika here (Elie) so we didn&amp;#x27;t include the measurements in the blog post to avoid making it too long but we did those measurements.&lt;p&gt;Overall file takes about 6ms (single file) 2.26ms per files when scanning multiples. Magika is at 65ms single file and 5.3ms when scanning multiples.&lt;p&gt;So Magika is for the worst case scenario about 10x slower due to the time it takes to load the model and 2x slower on repeated detection. This is why we said it is not that much slower.&lt;p&gt;We will have more performance measurements in the upcoming research paper. Hope that answer the question</text></comment>
<story><title>Magika: AI powered fast and efficient file type identification</title><url>https://opensource.googleblog.com/2024/02/magika-ai-powered-fast-and-efficient-file-type-identification.html</url></story><parent_chain><item><author>stevepike</author><text>Oh man, this brings me back! Almost 10 years ago I was working on a rails app trying to detect the file type of uploaded spreadsheets (xlsx files were being detected as application&amp;#x2F;zip, which is technically true but useless).&lt;p&gt;I found &amp;quot;magic&amp;quot; that could detect these and submitted a patch at &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;bugs.freedesktop.org&amp;#x2F;show_bug.cgi?id=78797&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;bugs.freedesktop.org&amp;#x2F;show_bug.cgi?id=78797&lt;/a&gt;. My patch got rejected for needing to look at the first 3KB bytes of the file to figure out the type. They had a hard limit that they wouldn&amp;#x27;t see past the first 256 bytes. Now in 2024 we&amp;#x27;re doing this with deep learning! It&amp;#x27;d be cool if google released some speed performance benchmarks here against the old-fashioned implementations. Obviously it&amp;#x27;d be slower, but is it 1000x or 10^6x?</text></item></parent_chain><comment><author>metafunctor</author><text>I&amp;#x27;ve ended up implementing a layer on top of &amp;quot;magic&amp;quot; which, if magic detects application&amp;#x2F;zip, reads the zip file manifest and checks for telltale file names to reliably detect Office files.&lt;p&gt;The &amp;quot;magic&amp;quot; library does not seem to be equipped with the capabilities needed to be robust against the zip manifest being ordered in a different way than expected.&lt;p&gt;But this deep learning approach... I don&amp;#x27;t know.  It might be hard to shoehorn in to many applications where the traditional methods have negligible memory and compute costs and the accuracy is basically 100% for cases that matter (detecting particular file types of interest).   But when looking at a large random collection of unknown blobs, yeah, I can see how this could be great.</text></comment>