{ "info": { "author": "Oliver Nagy", "author_email": "olitheolix@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Programming Language :: Python :: 3.6" ], "description": "# DS2Sim\n\nA simple Space Sim to experiment with machine learning.\n\nIt wraps [Horde3D](http://www.horde3d.org/) with Cython and uses it to render\nscenes like these.\n\n\n\n\nYou can use it to create your own training data, but it is easier\nto use the data set from the [DS2Data](https://github.com/olitheolix/ds2data)\nproject. Not only does that project have a representative training set of the\nrelevant objects, it also comes with a pre-rendered flight path to test your\nmodel.\n\nOnce you have your model you can plug it into the viewer application (see\n[View The Space Simulation](#View-The-Space-Simulation) section for details),\nand fly through the scene while it identifies the objects. You may also replace\nthe manual controls with another AI to make it fly autonomously.\n\n\n## Installation\nFirst, this will only work with an NVidia GPU, because the project uses\n[headless rendering](https://devblogs.nvidia.com/parallelforall/egl-eye-opengl-visualization-without-x-server/).\nIf you do not have an NVidia card, you may still train and test ML models with\nthe data from the [DS2Data](https://github.com/olitheolix/ds2data) set.\n\nNext, since this is a Cython wrapper for Horde3D, you will need - you guessed\nit - Cython and Horde3D. To compile and install Horde3D, activate the virtual\nenvironment of your choice, install Cython, and then clone/compile/install\nHorde3D like so:\n\n```bash\ngit clone https://github.com/olitheolix/Horde3D\nmkdir -p Horde3D/build\ncd Horde3D/build\ngit checkout ds2sim\ncmake .. -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=`python -c 'import sys; print(sys.prefix)'`\nmake install\n```\n\nAfterwards, install *DS2Sim* via PIP:\n```bash\npip install ds2sim\n```\n\n## View the Space Simulation\nThis consists of two parts: a web server to supply the rendered images, and a\nQt application to display them.\n\nStart the web server and load the default scene:\n```bash\nds2server --default-scene\n```\n\nThen put the following code into a file. Note that almost the entire file is\nboilerplate for Qt.\n```python\nimport sys\nimport ds2sim.viewer\nimport numpy as np\n\nimport PyQt5.QtGui as QtGui\nimport PyQt5.QtCore as QtCore\nimport PyQt5.QtWidgets as QtWidgets\n\n\n# For convenience.\nQPen, QColor, QRectF = QtGui.QPen, QtGui.QColor, QtCore.QRectF\nDS2Text = ds2sim.viewer.DS2Text\n\nclass MyClassifier(ds2sim.viewer.ClassifierCamera):\n def classifyImage(self, img):\n pass\n\n# Qt boilerplate to start the application.\napp = QtWidgets.QApplication(sys.argv)\nwidget = MyClassifier('Camera', host='127.0.0.1', port=9095)\nwidget.show()\napp.exec_()\n```\n\nThe only part here that is not boilerplate is `MyClassifier`, and even that\ndoes nothing right now.\n\nWhen you run this program you should see the scene. Click in it, and use the\nESDF keys, as well as the mouse, to fly through the scene. \n\n\n## Plug Your ML Model Into The Simulation\nThe real fun is, of course, to use ML to find and identify all the cubes while\nyou fly around. To do so, overload the `classifyImage` method in the previous\ndemo like so:\n\n```python\n# For convenience.\nQPen, QColor, QRectF = QtGui.QPen, QtGui.QColor, QtCore.QRectF\nDS2Text = ds2server.viewer.DS2Text\n\nclass MyClassifier(ds2sim.viewer.ClassifierCamera):\n def classifyImage(self, img):\n # `img` is always a NumPy image.\n assert img.dtype == np.uint8\n\n # Pass the image to your ML model.\n # myAwesomeClassifier(img)\n\n # Define a red bounding box.\n x, y, width, height = 0.3, 0.4, 0.3, 0.3\n bbox = [QPen(QColor(255, 0, 0)), QRectF(x, y, width, height)]\n\n # Define a green text label.\n x, y = 0.3, 0.4\n text = [QPen(QColor(100, 200, 0)), DS2Text(x, y, 'Found Something')]\n\n # Install the overlays.\n self.setMLOverlays([bbox, text])\n```\n\nThe `classifyImage` method will be called for each frame. It always receives\none RGB image as a NumPy array. Pass that image to your classifier to identify\nthe objects in the scene.\n\nWhen you have found out which objects are where, you can add overlays to\nhighlight them. Every overlay is a 2-tuple: a `QPen` to define the colour, and\na primitive to draw. Currently, `QRect` and `DS2Textures` are the only\nsupported primitives. Pass all overlays to `setMLOverlays` and it will show up\nin the scene.\n\nThe example code from above will produce an output like this.\n\nSingle Frame | Spaceflight\n:-------------------------:|:-------------------------:\n|\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/olitheolix/ds2sim", "keywords": "ds2sim", "license": "Apache Software License 2.0", "maintainer": "", "maintainer_email": "", "name": "ds2sim", "package_url": "https://pypi.org/project/ds2sim/", "platform": "", "project_url": "https://pypi.org/project/ds2sim/", "project_urls": { "Homepage": "https://github.com/olitheolix/ds2sim" }, "release_url": "https://pypi.org/project/ds2sim/0.5.0/", "requires_dist": null, "requires_python": "", "summary": "Fun with Machine Learning and Space Ships", "version": "0.5.0" }, "last_serial": 3099925, "releases": { "0.3.1": [ { "comment_text": "", "digests": { "md5": "f86164b846fe200acf56a065eb8c1675", "sha256": "d6d4684a4cd1aaf220e10a8ddb6c17fa65c01f123807d1807f241b357ea0b45c" }, "downloads": -1, "filename": "ds2sim-0.3.1.tar.gz", "has_sig": false, "md5_digest": "f86164b846fe200acf56a065eb8c1675", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6037445, "upload_time": "2017-06-17T09:43:53", "url": "https://files.pythonhosted.org/packages/3a/85/1b51de37f70239de9c63e004620fb9762532383a6c1d2550a152c8c019c9/ds2sim-0.3.1.tar.gz" } ], "0.5.0": [ { "comment_text": "", "digests": { "md5": "9016a7b2b6bcf3774080b0da212816d8", "sha256": "830deeeb777fa614d8ceae69fd8eb4fa41797339a0363760fa0438f734384e50" }, "downloads": -1, "filename": "ds2sim-0.5.0.tar.gz", "has_sig": false, "md5_digest": "9016a7b2b6bcf3774080b0da212816d8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6039321, "upload_time": "2017-08-16T07:03:55", "url": "https://files.pythonhosted.org/packages/29/b5/30dd2c03264b012ab7f97828e99a4d3ec1c4c4dc9d326634acdc9568a57a/ds2sim-0.5.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9016a7b2b6bcf3774080b0da212816d8", "sha256": "830deeeb777fa614d8ceae69fd8eb4fa41797339a0363760fa0438f734384e50" }, "downloads": -1, "filename": "ds2sim-0.5.0.tar.gz", "has_sig": false, "md5_digest": "9016a7b2b6bcf3774080b0da212816d8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6039321, "upload_time": "2017-08-16T07:03:55", "url": "https://files.pythonhosted.org/packages/29/b5/30dd2c03264b012ab7f97828e99a4d3ec1c4c4dc9d326634acdc9568a57a/ds2sim-0.5.0.tar.gz" } ] }