如何在Google Colab上运行lua ML模型

我正在尝试在Github上运行这个神经风格转移模型,但是因为我的计算机没有足够的内存/CPU/等等,所以我选择在Google Colab上运行。

我已经将我的Google Drive挂载到笔记本电脑上,按照这篇教程克隆了该存储库到我的驱动器上,将模型下载到我的驱动器文件夹中,并为了测试它是否可以工作,我正在使用最基本的运行Brad Pitt示例的方法,在readme中使用:

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上从开始到结束/错误进行重现:

# 挂载驱动器
from google.colab import drive
drive.mount('/content/drive')

# 在驱动器上克隆存储库
!git clone https://github.com/jcjohnson/neural-style

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

# 按照github存储库的说明下载模型
!bash models/download_models.sh

!th neural_style.lua -style_image examples/inputs/picasso_selfport1907.jpg -content_image examples/inputs/brad_pitt.jpg
点赞
用户14226511
用户14226511

第一个代码块:

%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
2020-09-05 15:02:22