Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyGRT: Python bindings for GRT via SWIG #151

Merged
merged 15 commits into from Jun 5, 2019
Merged

Conversation

@royshil
Copy link
Contributor

@royshil royshil commented Jul 11, 2018

This implements a Python API for GRT.

Enables writing Python code like this:

    print("Loading dataset...")
    training_data = GRT.ClassificationData()
    training_data.load(filename)
    print("Data Loaded")
    
    # Print out some stats about the training data
    training_data.printStats()
    
    print("Splitting data into training/test split...")
    test_data = training_data.split(80)
    
    # Create a new Gesture Recognition Pipeline
    pipeline = GRT.GestureRecognitionPipeline()
    
    # Add a KNN classifier to the pipeline with a K value of 10
    knn = GRT.KNN(10)
    pipeline.setClassifier(knn)

    print("Training model...")
    pipeline.train(training_data)

I started with the examples to get a good API coverage.

The Travis build fails because the MLPRegressor unit test fail, i.e. the problem is not with this code, but GRT itself.

@royshil royshil changed the title PyGRT: initial commit. pygrt build pipeline. barebones examples PyGRT: Python bindings for GRT via SWIG Jul 19, 2018
@alexszameitat
Copy link

@alexszameitat alexszameitat commented May 29, 2019

Hey there Roy,

I was trying to use your PyGRT, but got stuck trying to build up everything properly. I kindly wanted to ask whether you could help me out. After I build the binaries with CMake into the tmp folder (just like described in the README from Nick ... I'm on Windows), I then open the ALL_BUILD.vcxproj (in that tmp folder) in Visual Studio and build/compile ALL_BUILD.

This doesn't build correctly, but it does build the python package. In the python package I can also find the GRT.py, but not the GRT_.so. When I create a new project in that build/tmp/python directory it works out to import the GRT but if I compile the hello_world_example.py... I'll get the following error:


"C:\Program Files\Python37\python.exe" "D:/szameitat/Documents/Programming Projects/8_Python/GRT/tmp/try2/grt-roy.pygrt/build/tmp/python/hello_world_example.py"
Traceback (most recent call last):
File "D:\szameitat\Documents\Programming Projects\8_Python\GRT\tmp\try2\grt-roy.pygrt\build\tmp\python\GRT.py", line 14, in swig_import_helper
return importlib.import_module(mname)
File "C:\Program Files\Python37\lib\importlib_init_.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named '_GRT'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:/szameitat/Documents/Programming Projects/8_Python/GRT/tmp/try2/grt-roy.pygrt/build/tmp/python/hello_world_example.py", line 1, in
import GRT
File "D:\szameitat\Documents\Programming Projects\8_Python\GRT\tmp\try2\grt-roy.pygrt\build\tmp\python\GRT.py", line 17, in
_GRT = swig_import_helper()
File "D:\szameitat\Documents\Programming Projects\8_Python\GRT\tmp\try2\grt-roy.pygrt\build\tmp\python\GRT.py", line 16, in swig_import_helper
return importlib.import_module('GRT')
File "C:\Program Files\Python37\lib\importlib_init
.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_GRT'

Process finished with exit code 1

Also the Error List from Visual Studio after trying to build "ALL_BUILD":
ErrorList_VS_ALLBUILD.xlsx

I'd be glad if you or anyone else could help!

@royshil
Copy link
Contributor Author

@royshil royshil commented May 29, 2019

I won't be able to help with a Windows build. One thing I'd expect is that there will not be a GRT.so output file rather a GRT.dll (using MSVS). Anyway I'd start with fixing the build of the library itself, and see that it completes without errors. The Python package is almost just garnish.

@nickgillian
Copy link
Owner

@nickgillian nickgillian commented Jun 5, 2019

This is great, thanks for the contribution. Apologies that this took so long to merge.

@nickgillian nickgillian merged commit ffa7690 into nickgillian:master Jun 5, 2019
1 check failed
1 check failed
continuous-integration/travis-ci/pr The Travis CI build failed
Details
@anadi198

This comment has been minimized.

Copy link

@anadi198 anadi198 commented on GRT/CoreModules/MLBase.h in 9f6d585 Nov 3, 2019

This ended up giving me cmake errors from getMinChange() inside MLBase.cpp.

@anadi198

This comment has been minimized.

Copy link

@anadi198 anadi198 commented on GRT/CoreModules/MLBase.h in 9f6d585 Nov 3, 2019

This one as well, this declaration is necessary for getRandomiseTrainingOrder() inside MLBase.cpp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants