【问题标题】:Tensorboard is showing a blank page (Refused to execute script from 'http://localhost:6006/index.js' because its MIME type)Tensorboard 显示空白页(拒绝从“http://localhost:6006/index.js”执行脚本,因为它的 MIME 类型)
【发布时间】:2020-05-24 22:15:48
【问题描述】:

当尝试打开 tesnorflow 时,我只得到一个木板页面:

这是它在 Firefox 中的样子:

我在 chrome 控制台中收到错误消息:

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.

在 Firefox 控制台中,我收到错误消息:

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

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

我试过了:
Unable to open Tensorboard in browser
Tensorboard get blank page

我在控制台输入:

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

我有张量板版本:2.1.0 我像这样生成了我的数据:

 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()

我遵循了这个教程:TensorBoard with PyTorch - Visualize Deep Learning Metrics

【问题讨论】:

  • 有一个建议的解决方案here 特别是关于“启用严格的 MINE 类型检查”错误。如果您使用的是 Windows,它看起来可能与错误的注册表项有关。
  • 非常感谢,已经解决了。如果您将其发布为答案,我会接受。不知道你是怎么发现的。
  • 感谢@Lupos 我使用与此处显示的错误相关的各种谷歌搜索词偶然发现了这个解决方案。我不记得我用哪个搜索词找到这篇文章了。

标签: python-3.x tensorflow pytorch tensorboard


【解决方案1】:

here 报告了类似的错误和解决方案。

显然这与 Windows 注册表中的某些问题有关。根据 cmets,这似乎是解决方案

在我的情况下,以下程序解决了问题:

  1. windows + r 和注册表编辑器
  2. [您的计算机]\HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.js
  3. 将内容类型从“text/plain”更改为“application/javascript”

【讨论】:

  • 斜线丢失:[your computer]\HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.js
  • @A.Najafi 谢谢,我添加了缺失的\
【解决方案2】:

如果您不能或不想更改 Windows 注册表来修复它(因为它需要一些您可能没有的权限),您唯一的其他选择是直接在 mimetypes lib 模块中修补它。

它通常位于C:\python38\Lib\mimetypes.py,但您可以通过在命令行中运行以下命令来找到它:

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

打开打印的文件(如果不是本地 python 安装,您可能需要管理员权限)并找到 def guess_type(...): 行,在我的版本中位于行 97 并在函数开头添加以下行(就我而言,它位于L116L117):

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

保存后,返回命令行查看是否生效:

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

请注意,这种“硬编码”并不总是最好的选择,因为当你更新你的 python 版本时,mimetypes.py 将被这个“修复”删除,但在学校计算机上使用本地 python 安装时它很有用,例如。

如果您想了解更多信息,有一个关于此issue at the tensorboard repository 的讨论。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-12
    • 2022-10-25
    • 2018-10-13
    • 2014-12-31
    • 1970-01-01
    • 1970-01-01
    • 2015-06-28
    • 2018-01-02
    相关资源
    最近更新 更多