Hi,
Working on integrating IP with Python in order to call a random forest model to do some classifications of images.
I start out in IP9 load image and calculate the gray level co-occurance matrix values, imageGLCM, and want to pass them to a python based random forest model.
I am on a Mac.
I have a python script file, RF_model.py, with the following
#!/usr/bin/env python
# coding: utf-8
# In[1]:
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
import joblib
# In[6]:
rf_classifier=joblib.load('/Users/andy.hegedus/Desktop/Image Ground Truth/IP2Py2IP/rf_model.joblib')
# In[7]:
val_data=pd.read_csv('/Users/andy.hegedus/Desktop/Image Ground Truth/IP2Py2IP/haralick.csv')
Xval=val_data.drop(['cluster','x','y'], axis=1)
yval_pred = rf_classifier.predict(Xval)
val_data['cluster']=yval_pred
val_data.to_csv('/Users/andy.hegedus/Desktop/Image Ground Truth/IP2Py2IP/cluster.csv',index=False)
And then I have a shell script, run_python.sh:
#!/bin/zsh
python3 '/Users/andy.hegedus/Desktop/Image Ground Truth/IP2Py2IP/RF_model.py'
If I prepopulate the necessary files and run the shell script it works as expected and creates an output file that I am going to load back into IP9.
Note I have done a chmod 755 on the shell script to be executable.
So all is working.
Within IP9.
I create a string variable with
string Run_Python = "do shell script \"'/Users/andy.hegedus/Desktop/Image Ground Truth/IP2Py2IP/run_python.sh'\""
And then do
executeScriptText run_python
I receive an error and the S_Value
Traceback (most recent call last):
File "/Users/andy.hegedus/Desktop/Image Ground Truth/IP2Py2IP/RF_model.py", line 7, in <module>
import pandas as pd
ModuleNotFoundError: No module named 'pandas'
The shell script and its associated python script work as intended from terminal, but from within IP9 it does not work, but it finds the shell script file and the associated python script.
What am I missing?
Andy