【问题标题】:How to run lua ML model from Google Colab如何从 Google Colab 运行 lua ML 模型
【发布时间】:2020-04-16 02:06:04
【问题描述】:

我正在尝试从 Github 但在 Google Colab 上运行此 neural style transfer 模型,因为我的计算机没有足够的内存/CPU/任何东西。

我已将我的谷歌驱动器安装到我的笔记本上,按照this tutorial 将模型下载到我的驱动器文件夹将存储库克隆到我的驱动器上,为了测试它是否有效,我使用的是最基本的运行示例自述文件中的 Brad Pitt 示例使用:

th neural_style.lua -style_image examples/inputs/picasso_selfport1907.jpg -content_image examples/inputs/brad_pitt.jpg

但由于某种原因它不起作用。

  1. 使用subprocess.run()刚刚返回No such file or directory
  2. 使用!th neural_style.lua... 返回th: command not found

我尝试了其他四件事,它们都给了我上述两个错误消息的变体。有什么想法吗?

这是完整的笔记本代码,用于从头到尾重现我在 Colab 上的设置/错误:

# Mount the drive
from google.colab import drive
drive.mount('/content/drive')

# Clone the repo onto the drive
!git clone https://github.com/jcjohnson/neural-style

# Install Pytorch
!pip3 install http://download.pytorch.org/whl/cu80/torch-0.3.0.post4-cp36-cp36m-linux_x86_64.whl 
!pip3 install torchvision

# Download the models per the github repo instructions
!bash models/download_models.sh

!th neural_style.lua -style_image examples/inputs/picasso_selfport1907.jpg -content_image examples/inputs/brad_pitt.jpg

【问题讨论】:

    标签: lua pytorch google-colaboratory


    【解决方案1】:

    第一:

    %cd /content/
    !git clone https://github.com/nagadomi/distro.git torch --recursive
    import os
    os.chdir('./torch/')
    !bash install-deps
    !./install.sh
    !. ./install/bin/torch-activate
    

    现在它应该使用th的绝对路径:

    !/content/torch/install/bin/th neural_style.lua -style_image examples/inputs/picasso_selfport1907.jpg -content_image examples/inputs/brad_pitt.jpg
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-19
      • 2021-07-13
      • 1970-01-01
      • 2021-11-04
      • 1970-01-01
      • 1970-01-01
      • 2020-03-03
      • 2021-01-30
      相关资源
      最近更新 更多