4

我是一名野生动物博士研究员,按物种手动识别约 150 万张游戏相机照片。R 中的机器学习包最近来自一个研究项目,我一直试图让脚本在 R 中运行大约 12 个小时,但似乎无法正确完成(我经常使用 R 和 python ,但我不是专家,这是我在这里提出的第一个问题,如果我没有正确执行此操作,请原谅我)。

在 Github 上下载的软件包的自述文件(要了解我想要做什么,您可能必须阅读此内容,我深表歉意)位于:https://github.com/mikeyEcology/MLWIC/blob/master/README。 MD

对我来说不幸的是,该软件包是在 Macintosh 平台上开发的,而我有 Windows。我按照自述文件中的步骤如下:

1:使用代码安装MLWIC包:

devtools::install_github("mikeyEcology/MLWIC")
library(MLWIC)

2:按照https://www.tensorflow.org/install/pip上的说明安装“pip”、python 和“TensorFlow”

3:下载L1文件夹

4:我运行的代码与自述文件中概述的代码不同,如下所示: setup(python_loc = "I used this location I used from running "where python" in Anaconda")

在这个初始设置之后,我运行了“分类函数”的代码:library(MLWIC)

setup(python_loc = "C:/ProgramData/Anaconda3", conda_loc = "auto", r_reticulate = FALSE)

setwd("C:/Users/werdel/Desktop/MachineLearning")

help("classify")

classify(path_prefix = "C:/Users/werdel/Desktop/MachineLearning/images",# this is the absolute path to the images. 

     data_info = "C:/Users/werdel/Desktop/MachineLearning/image_labels.csv", # this is the location of the csv containing image information. It has Unix linebreaks and no headers.

     model_dir = "C:/Users/werdel/Desktop/MachineLearning", # assuming this is where you stored the L1 folder in Step 3 of the instructions: github.com/mikeyEcology/MLWIC/blob/master/README

     python_loc = "C:/ProgramData/Anaconda3/python.exe", # the location of Python on your computer. 

     save_predictions = "model_predictions.txt" # this is the default and you should use it unless you have reason otherwise.)

这就是问题似乎出现的地方。它似乎运行良好,输出显示在我的工作目录中创建的文件,但是当我检查时,没有文件。我尝试更改 python 位置,下载新旧版本的 anaconda,弄乱环境,但没有任何改变我的工作目录中没有创建文件的事实:

> library(MLWIC)
> setup(python_loc = "C:/ProgramData/Anaconda3", conda_loc = "auto", r_reticulate = FALSE)

Remove all packages in environment C:\PROGRA~3\ANACON~1\envs\r-reticulate:


## Package Plan ##

  environment location: C:\PROGRA~3\ANACON~1\envs\r-reticulate


The following packages will be REMOVED:

ca-certificates: 2018.03.07-0          
certifi:         2018.10.15-py37_0     
openssl:         1.1.1a-he774522_0     
pip:             18.1-py37_0           
python:          3.7.1-he44a216_5      
setuptools:      40.6.2-py37_0         
vc:              14.1-h0510ff6_4       
vs2015_runtime:  14.15.26706-h3a45250_0
wheel:           0.32.3-py37_0         
wincertstore:    0.2-py37_0            

Solving environment: ...working... done

## Package Plan ##

  environment location: C:\PROGRA~3\ANACON~1\envs\r-reticulate

  added / updated specs: 
    - python


The following NEW packages will be INSTALLED:

ca-certificates: 2018.03.07-0          
certifi:         2018.10.15-py37_0     
openssl:         1.1.1a-he774522_0     
pip:             18.1-py37_0           
python:          3.7.1-he44a216_5      
setuptools:      40.6.2-py37_0         
vc:              14.1-h0510ff6_4       
vs2015_runtime:  14.15.26706-h3a45250_0
wheel:           0.32.3-py37_0         
wincertstore:    0.2-py37_0            

Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
#
# To activate this environment, use:
# > activate r-reticulate
#
# To deactivate an active environment, use:
# > deactivate
#
# * for power-users using bash, you must source
#

Solving environment: ...working... failed

UnsatisfiableError: The following specifications were found to be in conflict:
  - argparse
  - tensorflow
Use "conda info <package>" to see the dependencies for each package.

Error: Error 1 occurred installing packages into conda environment r-reticulate
> classify(path_prefix = "C:/Users/werdel/Desktop/MachineLearning/images", # this is 
the absolute path to the images. 
+          data_info = "C:/Users/werdel/Desktop/MachineLearning/image_labels.csv", # 
this is the location of the csv containing image information. It has Unix linebreaks 
and no headers.
+          model_dir = "C:/Users/werdel/Desktop/MachineLearning", # assuming this is 
where you stored the L1 folder in Step 3 of the instructions: 
github.com/mikeyEcology/MLWIC/blob/master/README
+          python_loc = "C:/ProgramData/Anaconda3/python.exe", # the location of Python 
on your computer. 
+          save_predictions = "model_predictions.txt" # this is the default and you 
should use it unless you have reason otherwise.
+ )
[1] "evaluation of images took 0.000504970550537109 secs. The results are stored in 
C:/Users/werdel/Desktop/MachineLearning/L1/model_predictions.txt. To view the results 
in a viewer-friendly format, please use the function make_output"

所以我的最后一个问题是,在下载 pip、tensorflow、anaconda 和 python 时,我是否设置了一些错误,是否与我的编码方式等有关?

4

3 回答 3

1

我真的很难MLWIC在我的 Windows 计算机上工作,并在MLWICgithub 页面上关注了一些问题,直到我想出了一个适合我的解决方案。

我为 Windows 用户编写了一个指南,它已被添加到MLWIC_examplesrepo 中。你可以在这里找到它。这是一个分步指南。

顺便说一句,我找到了一种在不离开 R 环境的情况下使用 Unix 类型换行符的方法:

# Write to UNIX type doc (required)
output.file <- file("L1\\data_info.csv", "wb")
write.table(data_info,
            row.names = FALSE,
            col.names = FALSE,
            file = output.file,
            quote = FALSE,
            append = TRUE,
            sep = ",")
close(output.file)
rm(output.file) 
于 2019-03-13T18:29:06.287 回答
1

如果我没记错的话,他们的代码中有一个小错误会忽略“data_info”路径。尝试将“image_labels.csv”重命名为“data_info.csv”并将文件放入 model_dir。这为我解决了这个问题。另外,使用“C:/ProgramData/Anaconda3/”而不是“C:/ProgramData/Anaconda3/python.exe”

于 2019-01-08T19:20:39.203 回答
1

我能够让 MLWIC 在 Mac 上相对轻松地运行。让它在 Windows 上运行有点令人沮丧。我在 MLWIC github 页面上关注了问题线程 # 6和 # 13 。在运行 Windows 10 的机器上,我下载了Anaconda 3 5.2.0,其中包括 python 3.6.5。经过几个小时的故障排除后,我让它工作了。

安装 Anaconda 后,我使用 Anaconda Navigator 安装 tensorflow 1.11.0、cuddn 6.0、setuptools 40.6.2。请注意,这是我安装 tensorflow 的唯一地方。我没有打扰 tensorflow 网页上提到的 pip 安装。

从那里第一次打开 RI 时安装了以下软件包 MLWIC、keras、cloudml、Rcpp 和 reticulate。然后使用库函数运行它们。同样如上述 Faisal Ahmed 所述,将 image_labels.csv 重命名为 data_info.csv,并将该文件移动到 L1 文件夹。从这里我能够获得 MLWIC 提供的代码以在 Windows 上运行。当我第一次运行设置功能时,它看起来像这样setup(python_loc = "C:/Users/kvanatta/Anaconda3/python")

注意:我最初试图让 MLWIC 与保存在我办公室(S:驱动器)服务器上的文件一起运行,但无法让它工作。将文件传输到 1tb 外部硬盘驱动器(F:驱动器)后,从新位置一切正常。

我还下载了程序notepad ++,以便能够将 data_info.csv 文件转换为 unix(lf) 换行符。我相信由于 windows 不使用这些换行符,在 excel 中打开 .csv 文件会更改换行符。您可以使用记事本++ 将它们改回来。

希望这有助于缓解一些挫败感。

干杯

于 2019-02-18T19:56:57.053 回答