Looking up the MIME of a file fails on Linux
Krutonium opened this issue · 3 comments
On my system, I have nVidia Drivers installed, but no nVidia GPU at the moment. It crashes when it finds the driver but not apparently some magic files.
2022-05-27 22:50:07.900705: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcudart.so.10.1'; dlerror: libcudart.so.10.1: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /nix/store/gka59hya7l7qp26s0rydcgq8hj0d7v7k-gcc-11.3.0-lib/lib:/nix/store/p9d5i8nhx5g77h6mjfs8rqfl2cq33jrr-libsecret-0.20.5/lib:/nix/store/9757vpby0rqzlbm2p02dm812h28djrg5-e2fsprogs-1.46.5/lib:/nix/store/l55cmvhfrqyxhdvgcfxgq0jpizcdp7ld-libnotify-0.7.12/lib:/nix/store/m7d2jrrwprb4n48ddccsyg2ffqr6yj0m-pipewire-0.3.51-jack/lib
2022-05-27 22:50:07.900735: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
2022-05-27 22:50:08.072930: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations: AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-05-27 22:50:08.091265: I tensorflow/core/platform/profile_utils/cpu_utils.cc:104] CPU Frequency: 3593110000 Hz
2022-05-27 22:50:08.091881: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x7f92340093e0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2022-05-27 22:50:08.091913: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
2022-05-27 22:50:08.093389: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /nix/store/gka59hya7l7qp26s0rydcgq8hj0d7v7k-gcc-11.3.0-lib/lib:/nix/store/p9d5i8nhx5g77h6mjfs8rqfl2cq33jrr-libsecret-0.20.5/lib:/nix/store/9757vpby0rqzlbm2p02dm812h28djrg5-e2fsprogs-1.46.5/lib:/nix/store/l55cmvhfrqyxhdvgcfxgq0jpizcdp7ld-libnotify-0.7.12/lib:/nix/store/m7d2jrrwprb4n48ddccsyg2ffqr6yj0m-pipewire-0.3.51-jack/lib
2022-05-27 22:50:08.093408: W tensorflow/stream_executor/cuda/cuda_driver.cc:312] failed call to cuInit: UNKNOWN ERROR (303)
2022-05-27 22:50:08.093431: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (uGamingPC): /proc/driver/nvidia/version does not exist
Unhandled exception. HeyRed.Mime.MagicException: Could not find any valid magic files!
at HeyRed.Mime.Magic..ctor(MagicOpenFlags flags, String dbPath)
at HeyRed.Mime.MimeGuesser.GuessMimeType(Byte[] buffer)
at HeyRed.Mime.MimeGuesser.GuessFileType(Byte[] buffer)
at NsfwSpyNS.NsfwSpy.ClassifyImage(Byte[] imageData)
at NsfwSpyNS.NsfwSpy.ClassifyImage(Uri uri, WebClient webClient)
at IsItYiff.Program.Main(String[] args) in /home/krutonium/RiderProjects/IsItYiff/IsItYiff/Program.cs:line 11
From a quick look, I think this exception is getting thrown by the HeyRed.Mime package we use to help identify what image format we are classifying. ML.NET doesn't support the increasingly popular .webp image format, so to support it in NsfwSpy we convert that to a .png:
var fileType = MimeGuesser.GuessFileType(imageData);
if (fileType.Extension == "webp")
{
using (MagickImage image = new MagickImage(imageData))
{
imageData = image.ToByteArray(MagickFormat.Png);
}
}
I've just tried using this on a fresh Ubuntu virtual machine and see the same error message as you so I've just created an issue on their GitHub page to ask for clarification on whether an extra dependency is needed for Linux installs:
hey-red/Mime#44
Will update you when I hear back.
This issue should now be resolved in NsfwSpy v3.4.3.
@Krutonium are you happy to test the issue is now resolved for you when using the new version please?
Will do when I'm at my PC 👍