{ "info": { "author": "Jonathan Raiman", "author_email": "raiman@openai.com", "bugtrack_url": null, "classifiers": [], "description": "# TF Mesh Renderer\n\nThis is a differentiable, 3D mesh renderer using TensorFlow.\n[Original repository](https://github.com/google/tf_mesh_renderer).\n\nThis for sends it to Pypi, and removes bazel as a dependency for installation\n(e.g. just use `python3 setup.py install`).\n\n### Installation\n```\npip install mesh_renderer\n```\n\n### Usage\n\n```\n# load your geometry (this is a cube):\nobject_vertices = np.array([[-1, -1, 1], [-1, -1, -1], [-1, 1, -1], [-1, 1, 1], [1, -1, 1],\n [1, -1, -1], [1, 1, -1], [1, 1, 1]])\nobject_triangles = np.array([[0, 1, 2], [2, 3, 0], [3, 2, 6], [6, 7, 3], [7, 6, 5], [5, 4, 7],\n [4, 5, 1], [1, 0, 4], [5, 6, 2], [2, 1, 5], [7, 4, 0], [0, 3, 7]], dtype=np.int32)\nobject_vertices = tf.constant(object_vertices, dtype=tf.float32)\nobject_triangles = tf.constant(object_triangles, dtype=tf.int32)\nobject_normals = tf.nn.l2_normalize(object_vertices, dim=1)\n\n# rotate the geometry:\nangles = [[-1.16, 0.00, 3.48]]\n\nmodel_rotation = camera_utils.euler_matrices(angles)[0, :3, :3]\n# camera position:\neye = tf.constant([[0.0, 0.0, 6.0]], dtype=tf.float32)\nlightbulb = tf.constant([[0.0, 0.0, 6.0]], dtype=tf.float32)\ncenter = tf.constant([[0.0, 0.0, 0.0]], dtype=tf.float32)\nworld_up = tf.constant([[0.0, 1.0, 0.0]], dtype=tf.float32)\nvertex_diffuse_colors = tf.reshape(tf.ones_like(vertices), [1, vertices.get_shape()[0].value, 3])\nlight_positions = tf.expand_dims(lightbulb, axis=0)\nlight_intensities = tf.ones([1, 1, 3], dtype=tf.float32)\nambient_color = tf.constant([[0.0, 0.0, 0.0]])\n\nvertex_positions = tf.reshape(\n tf.matmul(vertices, model_rotation, transpose_b=True),\n [1, vertices.get_shape()[0].value, 3])\ndesired_normals = tf.reshape(\n tf.matmul(normals, model_rotation, transpose_b=True),\n [1, vertices.get_shape()[0].value, 3])\n\n# render is a tf.Tensor 3d tensor of shape height x width x 4 (r, g, b, a)\n# you can backpropagate through it.\nrender = mesh_renderer.mesh_renderer(\n vertex_positions, triangles, desired_normals,\n vertex_diffuse_colors, eye, center, world_up, light_positions,\n light_intensities, image_width, image_height,\n ambient_color=ambient_color,\n)\n```\n\n\n# Original Readme\n\nThis is a differentiable, 3D mesh renderer using TensorFlow.\n\nThis is not an official Google product.\n\nThe interface to the renderer is provided by mesh_renderer.py and\nrasterize_triangles.py, which provide TensorFlow Ops that can be added to a\nTensorFlow graph. The internals of the renderer are handled by a C++ kernel.\n\nThe input to the C++ rendering kernel is a list of 3D vertices and a list of\ntriangles, where a triangle consists of a list of three vertex ids. The\noutput of the renderer is a pair of images containing triangle ids and\nbarycentric weights. Pixel values in the barycentric weight image are the\nweights of the pixel center point with respect to the triangle at that pixel\n(identified by the triangle id). The renderer provides derivatives of the\nbarycentric weights of the pixel centers with respect to the vertex\npositions.\n\nAny approximation error stems from the assumption that the triangle id at a\npixel does not change as the vertices are moved. This is a reasonable\napproximation for small changes in vertex position. Even when the triangle id\ndoes change, the derivatives will be computed by extrapolating the barycentric\nweights of a neighboring triangle, which will produce a good approximation if\nthe mesh is smooth. The main source of error occurs at occlusion boundaries, and\nparticularly at the edge of an open mesh, where the background appears opposite\nthe triangle's edge.\n\nThe algorithm implemented is described by Olano and Greer, \"Triangle Scan\nConversion using 2D Homogeneous Coordinates,\" HWWS 1997.\n\nHow to Build\n------------\n\nFollow the instructions to [install TensorFlow using virtualenv](https://www.tensorflow.org/install/install_linux#installing_with_virtualenv).\n\nBuild and run tests using Bazel from inside the (tensorflow) virtualenv:\n\n`(tensorflow)$ ./runtests.sh`\n\nThe script calls the Bazel rules using the Python interpreter at\n`$VIRTUAL_ENV/bin/python`. If you aren't using virtualenv, `bazel test ...` may\nbe sufficient.\n\nCitation\n--------\n\nIf you use this renderer in your research, please cite [this paper](http://openaccess.thecvf.com/content_cvpr_2018/html/Genova_Unsupervised_Training_for_CVPR_2018_paper.html \"CVF Version\"):\n\n*Unsupervised Training for 3D Morphable Model Regression*. Kyle Genova, Forrester Cole, Aaron Maschinot, Aaron Sarna, Daniel Vlasic, and William T. Freeman. CVPR 2018, pp. 8377-8386.\n\n```\n@InProceedings{Genova_2018_CVPR,\n author = {Genova, Kyle and Cole, Forrester and Maschinot, Aaron and Sarna, Aaron and Vlasic, Daniel and Freeman, William T.},\n title = {Unsupervised Training for 3D Morphable Model Regression},\n booktitle = {The IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},\n month = {June},\n year = {2018}\n}\n```\n\n\nBust of safo: https://cdn.thingiverse.com/zipfiles/ac/39/53/07/80/Bust_of_Sappho_.zip", "description_content_type": "text/markdown", "docs_url": null, "download_url": "https://github.com/JonathanRaiman/tf_mesh_renderer", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/JonathanRaiman/tf_mesh_renderer", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "mesh-renderer", "package_url": "https://pypi.org/project/mesh-renderer/", "platform": "any", "project_url": "https://pypi.org/project/mesh-renderer/", "project_urls": { "Download": "https://github.com/JonathanRaiman/tf_mesh_renderer", "Homepage": "https://github.com/JonathanRaiman/tf_mesh_renderer" }, "release_url": "https://pypi.org/project/mesh-renderer/1.4/", "requires_dist": null, "requires_python": "", "summary": "", "version": "1.4" }, "last_serial": 5280069, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "0751c38df396fc8aaa29b6f04f67c669", "sha256": "6cfd12e3886df04cc5bc0437d74fa2bfa916a0afc74a7140295956311c625258" }, "downloads": -1, "filename": "mesh_renderer-1.0.tar.gz", "has_sig": false, "md5_digest": "0751c38df396fc8aaa29b6f04f67c669", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15729, "upload_time": "2019-05-15T21:03:05", "url": "https://files.pythonhosted.org/packages/a9/cc/c5e1447e8bc38b0198114cb8589af4f0fa128ac53c10b3adcb47b7a4ba04/mesh_renderer-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "b57815ee8f6e30ba84334229f6362f38", "sha256": "7cc1b6e28678902a80ee24a3ad6f26716459b27cce727ea2060bcfcec466eb9e" }, "downloads": -1, "filename": "mesh_renderer-1.1.tar.gz", "has_sig": false, "md5_digest": "b57815ee8f6e30ba84334229f6362f38", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20556, "upload_time": "2019-05-15T22:13:58", "url": "https://files.pythonhosted.org/packages/de/a5/ec2a312cb5a74c6551bb10bc9a371166bd1ab81ade10d71a5cad01509399/mesh_renderer-1.1.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "b868af7b57c0adb13360098a250feb1a", "sha256": "86bfec42af313770fa04e5508c7602c69776d5f731d74ab533266b7371932afb" }, "downloads": -1, "filename": "mesh_renderer-1.2.tar.gz", "has_sig": false, "md5_digest": "b868af7b57c0adb13360098a250feb1a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21157, "upload_time": "2019-05-15T23:10:32", "url": "https://files.pythonhosted.org/packages/a5/ed/1a55b2edcd734dcf5046d0ccdd25011e27b49c2dd17a4f7afb92e4673f95/mesh_renderer-1.2.tar.gz" } ], "1.3": [ { "comment_text": "", "digests": { "md5": "fbd73f2a1c3281278d6e920bbd37c8e8", "sha256": "8be1fc9e9d48c2e0b202345b7bdcdb3cbbbc242a755eda4681b9a5e32ab764bd" }, "downloads": -1, "filename": "mesh_renderer-1.3-py3.7-macosx-10.14-x86_64.egg", "has_sig": false, "md5_digest": "fbd73f2a1c3281278d6e920bbd37c8e8", "packagetype": "bdist_egg", "python_version": "3.7", "requires_python": null, "size": 39756, "upload_time": "2019-05-17T01:59:32", "url": "https://files.pythonhosted.org/packages/30/d5/be4adc9a327884c66407a1e88f97c8ddefa39c4db287e49c0df79c47c7db/mesh_renderer-1.3-py3.7-macosx-10.14-x86_64.egg" }, { "comment_text": "", "digests": { "md5": "ac40709385b8b5882ff0f6cb748831f5", "sha256": "ab560caf88985f7b1329af0cde5f2bfb13e875baab6814ee6efe4bc5bef6d92e" }, "downloads": -1, "filename": "mesh_renderer-1.3.tar.gz", "has_sig": false, "md5_digest": "ac40709385b8b5882ff0f6cb748831f5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21175, "upload_time": "2019-05-15T23:12:14", "url": "https://files.pythonhosted.org/packages/0d/cf/c38d344261dfc3a291a2e7491f7c75a68738631da206e246aee5c6274e53/mesh_renderer-1.3.tar.gz" } ], "1.4": [ { "comment_text": "", "digests": { "md5": "dda6033d2c493fb0f7931c6b062228b1", "sha256": "dd3b47ad3cf5c310ad1320985696e6a5e4cc7d120fdf9b0f23f5d52b213de68f" }, "downloads": -1, "filename": "mesh_renderer-1.4.tar.gz", "has_sig": false, "md5_digest": "dda6033d2c493fb0f7931c6b062228b1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21232, "upload_time": "2019-05-17T01:59:34", "url": "https://files.pythonhosted.org/packages/2e/29/105065c0c066da24bcdbbb3f7da454fac427bdbbdf96b21e05af8972d60d/mesh_renderer-1.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "dda6033d2c493fb0f7931c6b062228b1", "sha256": "dd3b47ad3cf5c310ad1320985696e6a5e4cc7d120fdf9b0f23f5d52b213de68f" }, "downloads": -1, "filename": "mesh_renderer-1.4.tar.gz", "has_sig": false, "md5_digest": "dda6033d2c493fb0f7931c6b062228b1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21232, "upload_time": "2019-05-17T01:59:34", "url": "https://files.pythonhosted.org/packages/2e/29/105065c0c066da24bcdbbb3f7da454fac427bdbbdf96b21e05af8972d60d/mesh_renderer-1.4.tar.gz" } ] }