Code Monkey home page Code Monkey logo

blendify's Introduction

blendify Logo

Open In Colab

Introduction

Blendify is a lightweight Python framework that provides a high-level API for creating and rendering scenes with Blender. Developed with a focus on 3D computer vision visualization, Blendify simplifies access to selected Blender functions and objects.

Key features of Blendify:

  1. Simple interface: Blendify provides a user-friendly interface for performing common visualization tasks without having to dive into the complicated Blender API.

  2. Easy integration: Blendify seamlessly integrates with development scripts, implementing commonly used routines and functions:

    • native support of point clouds, meshes, and primitives;
    • support of per-vertex colors and textures;
    • advanced shadows with shadow catcher objects;
    • video rendering with smooth camera trajectories;
    • support for common camera models;
    • import and export of .blend files for deeper integration with Blender.
  3. Quick start: Blendify is easy to get started with and does not require a standalone Blender installation. All you need to do is run pip install blendify.

  4. Blendify works in Colab: check out our Google Colab demo!

Installation instructions

Please note: Blendify requires Python 3.10

Install from pip

pip install blendify

Optional requirements

pip install blendify[utils / examples / docs / all]

Running examples 4 and 5 requires PyTorch with PyTorch3D.

Running example 5 requires SMPL model files, please refer to the installation instructions in README.

Quick Start

# Script to render cube
from blendify import scene
from blendify.materials import PrincipledBSDFMaterial
from blendify.colors import UniformColors
# Add light
scene.lights.add_point(strength=1000, translation=(4, -2, 4))
# Add camera
scene.set_perspective_camera((512, 512), fov_x=0.7, quaternion=(0.82, 0.42, 0.18, 0.34), translation=(5, -5, 5))
# Create material
material = PrincipledBSDFMaterial()
# Create color
color = UniformColors((0.0, 1.0, 0.0))
# Add cube mesh
scene.renderables.add_cube_mesh(1.0, material, color)
# Render scene
scene.render(filepath="cube.png")

Examples

Cornell Box Color, albedo and depth
Mesh with texture Camera colored point cloud
SMPL movement NURBS trajectory

Works that use blendify

Contributors

Blendify is written and maintained by Vladimir Guzov and Ilya Petrov.

Acknowledgments

We thank Verica Lazova for providing her Blender rendering scripts. Our code for processing point clouds is mostly based on the amazing Blender-Photogrammetry-Importer addon.

License

The code is released under the GNU General Public License v3.

The Python logo is trademark of Python Software Foundation. The Blender logo is a registered property of Blender Foundation. Blender-Photogrammetry-Importer is distributed under the MIT License. Blender is released under the GNU General Public License v3.

blendify's People

Contributors

vguzov avatar ptrvilya avatar

Stargazers

 avatar Sudheer Kumar N avatar  avatar  avatar Alex Sommer avatar  avatar Hongbo Kang avatar Purva Tendulkar avatar Hyeongjun Heo avatar Ishan avatar :D avatar Helen Miles avatar  avatar Mike Stringer avatar Jer NC avatar Neil Ferguson avatar George avatar Guangze Zheng avatar Alara Dirik avatar Divano avatar Zhu Shuai avatar Jakob Meyer avatar  avatar Okhai. avatar Haoyu Zhen avatar Fangzhou Hong avatar David BG avatar Catalin Moldovan avatar FFengIll avatar Stefan Jeske avatar Haiyi avatar Hyoseok Lee avatar Nguyễn Quí Vinh Quang avatar Ash avatar  avatar askender avatar Hanzhi Chen avatar  avatar Christen Millerdurai avatar Crosstyan avatar Arne Koenig avatar tm avatar weiWang avatar Tsun-Yi Yang avatar Jonáš Kulhánek avatar Ke Lee avatar Zhibing Li avatar Jack avatar GUO-W avatar Yongtao Ge avatar Andrew avatar  avatar  avatar AI Researcher avatar Jeff Carpenter avatar Zijie Ye avatar  avatar Terrie Simmons-Ehrhardt avatar Siddharth Katageri avatar Yang Fu avatar  avatar  avatar Yoav Alon avatar Zhixuan Xu avatar Edson-Niu avatar Baoxiong Jia avatar Yixin Chen avatar Harvey avatar inFinith avatar carmen1203 avatar brunozc avatar Nikos Vaggalis avatar  avatar Jooeun Son avatar  avatar Donggeun Lim avatar  avatar Kristijan Bartol avatar  avatar Tihan Pelser avatar David Bojanić avatar  avatar arizeworks avatar Miles avatar Samet Hi avatar  avatar Ahmed A. A. Osman avatar koji avatar Junjie Wang avatar Yalım Doğan avatar Muhammed Kocabas avatar Chen Xin avatar Yannan He avatar Damien ROBERT avatar Keno Moenck avatar Eduardo Arnold avatar  avatar Vanessa Sklyarova avatar Kerry M avatar Tan Jun Liang avatar

Watchers

Hai Quang, Kim (kenvink) avatar Jimmy Gunawan avatar Snow avatar  avatar  avatar Pyjcsx avatar KIHONG KIM avatar  avatar

blendify's Issues

File "C:\ProgramData\miniconda3\lib\site-packages\blendify\colors\texture.py", line 109, in __init__ self._texture = bpy.data.images.load(texture_path) RuntimeError: Error: Cannot read './assets/05_smpl_movement/scene_texture.jpg': No such file or directory

File "C:\ProgramData\miniconda3\lib\site-packages\blendify\colors\texture.py", line 109, in init
self._texture = bpy.data.images.load(texture_path)
RuntimeError: Error: Cannot read './assets/05_smpl_movement/scene_texture.jpg': No such file or directory

Running on Google Colab

In theory, we should be able to run this anywhere with Python 3.10 up right?

I am installing the module on Google Colab, then running the example cube, but getting error:

/usr/local/lib/python3.10/dist-packages/numpy/core/getlimits.py:499: UserWarning: The value of the smallest subnormal for <class 'numpy.float64'> type is zero.
  setattr(self, word, getattr(machar, word).flat[0])
/usr/local/lib/python3.10/dist-packages/numpy/core/getlimits.py:89: UserWarning: The value of the smallest subnormal for <class 'numpy.float64'> type is zero.
  return self._float_to_str(self.smallest_subnormal)
/usr/local/lib/python3.10/dist-packages/numpy/core/getlimits.py:499: UserWarning: The value of the smallest subnormal for <class 'numpy.float32'> type is zero.
  setattr(self, word, getattr(machar, word).flat[0])
/usr/local/lib/python3.10/dist-packages/numpy/core/getlimits.py:89: UserWarning: The value of the smallest subnormal for <class 'numpy.float32'> type is zero.
  return self._float_to_str(self.smallest_subnormal)
---------------------------------------------------------------------------
UnsupportedOperation                      Traceback (most recent call last)
[<ipython-input-2-2ae244d3f684>](https://y4plpfm62xs-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab-20230509-060147-RC00_530563781#) in <cell line: 2>()
      1 # Script to render cube
----> 2 from blendify import scene
      3 from blendify.materials import PrinsipledBSDFMaterial
      4 from blendify.colors import UniformColors
      5 # Add light

5 frames
[/usr/local/lib/python3.10/dist-packages/blendify/internal/io.py](https://y4plpfm62xs-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab-20230509-060147-RC00_530563781#) in set_hook(self)
     21         self.logfile = open(self.logfile_path, 'w')
     22         self.logfile_fd = self.logfile.fileno()
---> 23         self.stdout_fd = sys.stdout.fileno()
     24         self.saved_stdout_fd = os.dup(self.stdout_fd)
     25         sys.stdout.flush()

UnsupportedOperation: fileno

Hello, how to render fbx?

Specifically, how to cooperated with blender load fbx API and send to sence.add_mesh for rendering?

bpy.ops.import_scene.fbx(filepath=model_path)

Conflicting dependencies at installation time

Hi, thanks for sharing this work !

I have been trying to pip install blendify but come across some dependency issues :

$ pip install blendify
Defaulting to user installation because normal site-packages is not writeable
Collecting blendify
  Downloading blendify-1.2.2-py3-none-any.whl (60 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.7/60.7 kB 2.8 MB/s eta 0:00:00
Requirement already satisfied: scipy in /home/ign.fr/drobert-admin/.local/lib/python3.10/site-packages (from blendify) (1.8.1)
Requirement already satisfied: numpy in /home/ign.fr/drobert-admin/.local/lib/python3.10/site-packages (from blendify) (1.24.2)
Collecting opencv-python-headless
  Downloading opencv_python_headless-4.7.0.72-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (49.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 49.2/49.2 MB 10.6 MB/s eta 0:00:00
Collecting blendify
  Downloading blendify-1.2.1-py3-none-any.whl (60 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.7/60.7 kB 4.3 MB/s eta 0:00:00
  Downloading blendify-1.2.0-py3-none-any.whl (60 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.0/61.0 kB 4.1 MB/s eta 0:00:00
ERROR: Cannot install blendify==1.2.0, blendify==1.2.1 and blendify==1.2.2 because these package versions have conflicting dependencies.

The conflict is caused by:
    blendify 1.2.2 depends on bpy==3.5.0
    blendify 1.2.1 depends on bpy==3.5.0
    blendify 1.2.0 depends on bpy==3.5.0

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

It seems bpy is needed, but I could not install the seemingly-required bpy==3.5.0 version, only the 3.4.0, even though the official bpy page suggests I should be able to install 3.5.0 .

Did you come across similar installation issues ? Thanks in advance for the help !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.