python - MLWIC : Machine Learning for Wildlife Image Classification in R Issues with Python

标签 python r tensorflow github anaconda

我是一名野生动物博士研究员,按物种手动识别约 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:按照说明安装“pip”、python 和“TensorFlow” https://www.tensorflow.org/install/pip

3:下载了L1文件夹

4:我运行的代码与自述文件中概述的不同,如下所示: setup(python_loc = "我使用了在 Anaconda 中运行 "where python"得到的位置")

完成这个初始设置后,我运行了“分类函数”的代码: 库(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 时似乎设置了错误吗,是不是我编码的方式有问题等等?

最佳答案

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

关于python - MLWIC : Machine Learning for Wildlife Image Classification in R Issues with Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53565437/

相关文章:

python - 如何计算字典中的值并打印与最大金额关联的键和值

python - 是否可以在 Hadoop 上运行 Python 的 scikit-learn 算法?

r - 使用 formatC 将 0 添加到 arg 中的序列中,在 R 中返回错误

r - 在 R 中的行首添加字符

tensorflow - LSTM 的精度非常低

python - 检查python下是否存在postgresql表(可能还有Psycopg2)

python - 如何让 matplotlib 的 imshow 每秒刷新一次?

r - 函数导致自动生成的 RcppExports.R 检查错误

python - 卷积自动编码器的 Keras valueerror

tensorflow - 如果 Keras 模型中样本大小不能被batch_size整除怎么办