carson-katri / dream-textures

Stable Diffusion built-in to Blender
GNU General Public License v3.0
7.78k stars 418 forks source link

V3.0 with SDXL command line rendering broken #713

Closed GottfriedHofmann closed 8 months ago

GottfriedHofmann commented 11 months ago

Description

When trying to run dream textures as a render engine from the command line with SDXL, I get the following warning:

WARN (bpy.rna): C:\Users\blender\git\blender-v360\blender.git\source\blender\python\intern\bpy_rna.c:1343 pyrna_enum_to_py: current value '1' matches no enum in 'DreamTexturesRenderEngineProperties', '', 'backend' Error: Python: Traceback (most recent call last): File "C:\Users\g\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\dream_textures\engine\nodes\pipeline_nodes.py", line 79, in update self.prompt.backend = bpy.context.scene.dream_textures_render_engine.backend TypeError: bpy_struct: item.attr = val: enum "" not found in ('dream_textures.diffusers_backend.DiffusersBackend') Traceback (most recent call last): File "C:\Users\g\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\dream_textures\engine\nodes\pipeline_nodes.py", line 79, in update self.prompt.backend = bpy.context.scene.dream_textures_render_engine.backend TypeError: bpy_struct: item.attr = val: enum "" not found in ('dream_textures.diffusers_backend.DiffusersBackend')

Then it starts loading the pipeline components and stalls indefinitely:

Fra:1 Mem:88.84M (Peak 88.84M) | Time:00:00.01 | Group Output Fra:1 Mem:88.84M (Peak 88.84M) | Time:00:00.01 | Render Properties Fra:1 Mem:88.84M (Peak 88.84M) | Time:00:00.01 | Stable Diffusion Keyword arguments {'safety_checker': None, 'requires_safety_checker': False} are not expected by StableDiffusionXLPipeline and will be ignored. Loading pipeline components...: 100%|████████████████████████████████████████████████████| 7/7 [00:01<00:00, 6.95it/s]

Steps to Reproduce

Unpack the following .blend, render it from the command line with -a -b You might need to adjust the stablediffusion node to use SDXL.

dream textures bug command line render fails.zip

Expected Behavior

Render the two .png files as an animation.

Addon Version

Windows (CUDA)

GPU

NVIDIA

GottfriedHofmann commented 10 months ago

With the lastest git it gets one step further but fails to write the rendered image to disk:

WARN (bpy.rna): C:\Users\blender\git\blender-v360\blender.git\source\blender\python\intern\bpy_rna.c:1343 pyrna_enum_to_py: current value '1' matches no enum in 'DreamTexturesRenderEngineProperties', '', 'backend' Error: Python: Traceback (most recent call last): File "C:\Users\g\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\dream_textures\engine\nodes\pipeline_nodes.py", line 79, in update self.prompt.backend = bpy.context.scene.dream_textures_render_engine.backend TypeError: bpy_struct: item.attr = val: enum "" not found in ('dream_textures.diffusers_backend.DiffusersBackend') Traceback (most recent call last): File "C:\Users\g\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\dream_textures\engine\nodes\pipeline_nodes.py", line 79, in update self.prompt.backend = bpy.context.scene.dream_textures_render_engine.backend TypeError: bpy_struct: item.attr = val: enum "" not found in ('dream_textures.diffusers_backend.DiffusersBackend') Fra:1 Mem:49.74M (Peak 49.74M) | Time:00:00.00 | Group Output Fra:1 Mem:49.74M (Peak 49.74M) | Time:00:00.00 | Render Properties Fra:1 Mem:49.74M (Peak 49.74M) | Time:00:00.00 | Render Properties Fra:1 Mem:49.74M (Peak 49.74M) | Time:00:00.01 | Render Properties Fra:1 Mem:49.74M (Peak 49.74M) | Time:00:00.01 | Stable Diffusion Keyword arguments {'safety_checker': None, 'requires_safety_checker': False} are not expected by StableDiffusionXLPipeline and will be ignored. Loading pipeline components...: 100%|████████████████████████████████████████████████████| 7/7 [00:00<00:00, 7.62it/s] 100%|██████████████████████████████████████████████████████████████████████████████████| 25/25 [00:08<00:00, 3.02it/s]

GganallHis commented 10 months ago

Same issue here. I get an endless list of 'WARN (bpy.rna): C:\Users\blender\git\blender-v360\blender.git\source\blender\python\intern\bpy_rna.c:1343 pyrna_enum_to_py: current value '0' matches no enum in 'DreamPrompt', '', 'model''.

Also:

WARN (bpy.rna): C:\Users\blender\git\blender-v360\blender.git\source\blender\python\intern\bpy_rna.c:1343 pyrna_enum_to_py: current value '1' matches no enum in 'DreamTexturesRenderEngineProperties', '', 'backend' Traceback (most recent call last): File "C:\Users\GganallHis\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\dream_textures\engine\nodes\pipeline_nodes.py", line 79, in update self.prompt.backend = bpy.context.scene.dream_textures_render_engine.backend TypeError: bpy_struct: item.attr = val: enum "" not found in ('dream_textures.diffusers_backend.DiffusersBackend')

NullSenseStudio commented 10 months ago

Seems primarily the issue is that timers don't run when Blender is started from the command line to render. Likely due to the main thread being used as the render thread, rather than having a separate thread for rendering where the main thread is free to handle timer events. https://github.com/carson-katri/dream-textures/blob/978e7b92db878f156408e4d353d3616bebd1f9c7/generator_process/future.py#L64-L69 These timers are necessary under normal circumstances to run things on Blender's main thread and not cause crashes. We'll have to make sure any requests to the backend are blocking when bpy.app.background==True and have the Future objects queue their callbacks to run on the calling thread somehow.