lua - 如何从 Google Colab 运行 lua ML 模型
问题描述
我正在尝试从 Github 但在 Google Colab 上运行这种神经风格迁移模型,因为我的计算机没有足够的内存/CPU/任何东西。
我已经将我的谷歌驱动器安装到我的笔记本上,按照本教程将模型下载到我的驱动器文件夹中,将存储库克隆到我的驱动器上,为了测试它是否有效,我正在使用运行 Brad Pitt 示例的最基本示例在自述文件中使用:
th neural_style.lua -style_image examples/inputs/picasso_selfport1907.jpg -content_image examples/inputs/brad_pitt.jpg
但由于某种原因,它不起作用。
- 使用
subprocess.run()
刚刚返回No such file or directory
- 使用
!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
解决方案
第一的:
%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
推荐阅读
- c++ - 使用 sysroot 进行 cmake 交叉编译返回错误的包含路径
- terraform - 获取 Terraform 资源已存在错误与 Terraform 刚刚创建的资源
- python - 有没有办法在 tkinter 中为此设置一个重置按钮?
- r - 如何向量化函数
- java - JPA 直接与软 (ID) 参考 - 什么是最好的?
- python - 如何将表添加到数据库?
- sql-server - 访问链接到 SQL:为新创建的记录显示错误的数据,自动编号主键
- c++ - 我不能用 sfml Vector2f 的数据类型声明二维数组
- javascript - 在 axios 调用期间,在挂载时反应未正确加载状态
- snowflake-cloud-data-platform - 数据湖中带时间戳的 csv 外部表的临时缓慢变化的维度具体化