运行 Google Colab 上的 .EXE 或 Perl 文件

Running .EXE or Perl file on Google Colab

我想在 google colab 上处理一组带有可执行文件(例如 falsecolor2.exe)的 HDR 文件。

源文件在这里:https://github.com/mostaphaRoudsari/honeybee/blob/master/resources/falsecolor2.exe?raw=true 示例 HDR 文件: http://www.anyhere.com/gward/hdrenc/pages/originals.html

可执行文件采用带有一些参数的 HDR 文件并生成一个新的 HDR 文件。 在我的本地机器和驱动器上,以下代码工作正常:

import os
os.system(r'D:\falsecolor2.exe -i D:\test.hdr -s 250.0 -n 10 -mask 0.1 -l lux -m 179 -lp EN -z > D:\test@fc.hdr')

我不确定如何在 colab 中创建类似的进程;安装 gdrive 后,以下代码在我的 gdrive 中生成一个 0 字节不工作的 HDR 和 returns 错误代码 32256。

import os
os.system('/content/drive/My\ Drive/falsecolor2.exe -i /content/drive/My\ Drive/MOSELEY\ IMAGES/test.hdr -s 250.0 -n 10 -mask 0.1 -l lux -m 179 -lp EN -z > /content/drive/My\ Drive/test@fc.hdr')

我阅读了一些关于 shell 和 linux 可执行文件的线程,但无法成功复制其中任何一个。

您可以像这样在 Google Colab 中安装 Radiance:

# Download the Linux compiled version of radiance from Github (e.g. 5.3, latest official release at the moment):
!wget -O radiance.zip https://github.com/LBNL-ETA/Radiance/releases/download/012cb178/Radiance_012cb178_Linux.zip

# Unzip it
!unzip radiance.zip

# Extract the tar.gz to /usr/local/radiance
!tar -xvf radiance-5.3.012cb17835-Linux.tar.gz --strip-components=1 -C /

# Add /usr/local/radiance/bin to the PATH environment variable
path = %env PATH
%env PATH=/usr/local/radiance/bin:$path

# Set the RAYPATH environment variable to /usr/local/radiance/lib
%env RAYPATH=/usr/local/radiance/lib

我运行!lsb_release -a在GoogleColab中找出Linux分布,它说是Ubuntu18.04。不幸的是,Radiance 似乎不适用于该版本,但仅适用于 16.04。这就是为什么从 Github 获取它似乎是下一个最简单的解决方案。见 radiance in Ubuntu Packages:

Exact hits

Package radiance

  • xenial (16.04LTS) (graphics): Lighting Simulation and Rendering System [universe] 4R1+20120125-1.1: amd64 arm64 armhf i386 powerpc ppc64el s390x

然后我尝试使用您链接的其中一张示例图像 运行 您的 falsecolor 命令,发现 -lp-z 选项不可用:

# Get a sample HDR file
!wget -O input.hdr http://www.anyhere.com/gward/hdrenc/pages/img/Apartment_float_o15C.hdr

# Try original command
!falsecolor -i input.hdr -s 250.0 -n 10 -mask 0.1 -l lux -m 179 -lp EN -z > output.hdr

# Output:
# bad option "-lp"

# Remove option -lp
!falsecolor -i input.hdr -s 250.0 -n 10 -mask 0.1 -l lux -m 179 -z > output.hdr

# Output:
# bad option "-z"

如果删除这些选项,命令 运行s 成功:

# Remove option -z
!falsecolor -i input.hdr -s 250.0 -n 10 -mask 0.1 -l lux -m 179 > output.hdr

# List output file
!ls -lh output.hdr

# Output:
# -rw-r--r-- 1 root root 4.8M Mar 31 02:57 output.hdr

查看 this colab 中的演示。