3

When Trying to open tesnorflow I just get a plank page: enter image description here

This is how it looks like in firefox:

enter image description here

I get the error message in the chrome console:

Refused to execute script from 'http://localhost:6006/index.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.

In the firefox console I get the error message:

The resource from “http://localhost:6006/index.js” was blocked due to MIME type (“text/plain”) mismatch (X-Content-Type-Options: nosniff)

and

Loading failed for the <script> with source “http://localhost:6006/index.js”.

I tried:
Unable to open Tensorboard in browser
Tensorboard get blank page

I typed in the console:

tensorboard --logdir=runs --bind_all
tensorboard --logdir=./runs --bind_all
tensorboard --logdir=./runs/ --bind_all
tensorboard --logdir=./runs --host localhost --port 6006  
tensorboard --logdir=./runs --host localhost 
tensorboard --logdir=./runs --port 6006 --bind_all

I have tensorboard version: 2.1.0 I generated my data like that:

 train_set = torchvision.datasets.FashionMNIST(
        root="./data/FashionMNIST",
        train=True,
        download=True,
        transform=transforms.Compose([
            transforms.ToTensor()
        ])
    )
train_loader = torch.utils.data.DataLoader(train_set, batch_size=1000)
tb = SummaryWriter()

network = Network()
images, labels = next(iter(train_loader))
grid = torchvision.utils.make_grid(images)

tb.add_image("image", grid)
tb.add_graph(network, images)
tb.close()

I followed this tutorial: TensorBoard with PyTorch - Visualize Deep Learning Metrics

Lupos
  • 896
  • 12
  • 40
  • 1
    There's a proposed solution [here](https://github.com/tensorflow/tensorboard/issues/2771#issuecomment-570285749) specifically about getting a "strict MINE type checking is enabled" error. If you're using Windows it looks like it may be something to do with a bad registry entry. – jodag Feb 09 '20 at 13:11
  • 1
    Thank you so much, that fixed it. If you post it as answer I'll accept it. I wonder how you found that. – Lupos Feb 09 '20 at 14:47
  • Thanks @Lupos I stumbled across this solution using various google search terms related to the errors shown here. I don't remember exactly which search term I used to find this post. – jodag Feb 10 '20 at 01:47

2 Answers2

6

There's a similar error and resolution reported here.

Apparently this has to do with some issue in the windows registry. Based on the comments this seems to be the solution

In my case following procedure solved the problem:

  1. windows + r and regedit
  2. [your computer]\HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.js
  3. Change content type from 'text/plain' to 'application/javascript'
jodag
  • 19,885
  • 5
  • 47
  • 66
2

If you can't or don't want to change your windows registry to fix it (since it requires some privileges you might not have), your only other option is to patch it directly at the mimetypes lib module.

It is usually found at C:\python38\Lib\mimetypes.py, but you can find where it is by running the following at the command line:

python -c "import mimetypes; print(mimetypes.__file__)"

Open the file printed (you might need admin privileges if it's not a local python installation) and find the def guess_type(...): line, which in my version is at line 97 and add the following lines at the start of the function (in my case it was at L116 and L117):

if (isinstance(url, str) and url[-3:] == '.js'):
    return 'application/javascript', None

After saving it, return to the command line check if it worked:

python -c "import mimetypes; print(mimetypes.guess_type('index.js'))"

Note that this 'hard-coding' is not always the best option since when you update your python version the mimetypes.py will be removed with this 'fix' but it is useful when using a local python installation on a school computer, for example.

There's a discussion about this issue at the tensorboard repository, if you wish to learn more about it.