{"id":28381,"library":"tensorflow-graphics","title":"TensorFlow Graphics","description":"A library that provides well-defined, reusable and cleanly written graphics ops and utility functions for TensorFlow, enabling differentiable graphics rendering, transformations, and 3D geometry operations. The latest version on PyPI is 2021.12.3. Releases are infrequent and the library may lag behind TensorFlow releases.","status":"maintenance","version":"2021.12.3","language":"python","source_language":"en","source_url":"https://github.com/tensorflow/graphics","tags":["tensorflow","graphics","3d","geometry","differentiable rendering","mesh","computer graphics"],"install":[{"cmd":"pip install tensorflow-graphics","lang":"bash","label":"Default install"},{"cmd":"pip install tensorflow-graphics==2021.12.3","lang":"bash","label":"Pin to latest version"}],"dependencies":[{"reason":"Core framework for tensor operations and autograd","package":"tensorflow","optional":false},{"reason":"Numerical operations","package":"numpy","optional":false},{"reason":"Some geometry routines use scipy","package":"scipy","optional":true},{"reason":"Visualization utilities","package":"matplotlib","optional":true}],"imports":[{"note":"Incorrect path - the mesh submodule is under geometry.representation.","wrong":"from tensorflow_graphics.mesh import TriangleMesh","symbol":"TriangleMesh","correct":"from tensorflow_graphics.geometry.representation.mesh import TriangleMesh"},{"note":"Wrong module; transformation module is under geometry, not top-level.","wrong":"from tensorflow_graphics.transforms import perspective","symbol":"perspective","correct":"from tensorflow_graphics.geometry.transformation import perspective"},{"note":"Rendering submodule is named 'rendering', not 'render'.","wrong":"from tensorflow_graphics.render import rasterizer","symbol":"render","correct":"from tensorflow_graphics.rendering import rasterizer"}],"quickstart":{"code":"import tensorflow as tf\nimport tensorflow_graphics as tfg\nfrom tensorflow_graphics.geometry.representation.mesh import TriangleMesh\n\n# Create a simple mesh (cube)\nvertices = tf.constant([\n    [0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0],\n    [0, 0, 1], [1, 0, 1], [1, 1, 1], [0, 1, 1]\n], dtype=tf.float32)\nfaces = tf.constant([\n    [0, 1, 2], [2, 3, 0],\n    [1, 5, 6], [6, 2, 1],\n    [5, 4, 7], [7, 6, 5],\n    [4, 0, 3], [3, 7, 4],\n    [3, 2, 6], [6, 7, 3],\n    [4, 5, 1], [1, 0, 4]\n], dtype=tf.int32)\nmesh = TriangleMesh(vertices=vertices, indices=faces)\nprint('Mesh vertex count:', tf.shape(mesh.vertices)[0].numpy())","lang":"python","description":"Initialize a simple triangle mesh with vertices and face indices, and verify the mesh creation."},"warnings":[{"fix":"Pin tensorflow to 2.8-2.9 or use the nightly build from GitHub.","message":"TensorFlow Graphics v2021.x may not be compatible with TensorFlow 2.x later than 2.9. Installing newer tensorflow versions can cause import errors or broken ops.","severity":"breaking","affected_versions":">=2021.12.3"},{"fix":"Use with caution; consider alternative libraries for actively maintained features.","message":"The library has not been actively updated since 2021. Some modules like 'rendering' are experimental and may have breaking changes if future releases occur.","severity":"deprecated","affected_versions":"all"},{"fix":"Wrap only pure TF ops inside tf.function; keep graphics-specific ops in eager mode.","message":"Expects TensorFlow eager mode by default; using tf.function on graphics ops may cause unexpected graph tracing errors if the ops have side effects or use Python control flow.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure face winding is consistent; use tfg.geometry.representation.mesh.normals functions to verify.","message":"Mesh face indices must be in counter-clockwise order for correct normal computation, but the library does not validate orientation.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Run: pip install tensorflow-graphics","cause":"Library not installed or installed under a different name.","error":"ModuleNotFoundError: No module named 'tensorflow_graphics'"},{"fix":"Use: from tensorflow_graphics.geometry.representation.mesh import TriangleMesh","cause":"Incorrect import path; TriangleMesh is not in the top-level module.","error":"ImportError: cannot import name 'TriangleMesh' from 'tensorflow_graphics'"},{"fix":"Ensure full install: pip install tensorflow-graphics[all]","cause":"Rendering module may not be installed if 'tensorflow-graphics' was installed via minimal extras.","error":"AttributeError: module 'tensorflow_graphics' has no attribute 'rendering'"},{"fix":"Cast face indices to tf.int32 before passing: tf.cast(faces, tf.int32)","cause":"Function expecting integer tensor but passed float; face indices must be integer type.","error":"TypeError: Expected int32, got list containing Tensors of type 'float32'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}