p4vv37/SDTG4B

WindowManager has been removed

Closed this issue · 5 comments

Was hoping to get this working, got most of the way there but hit a snag upon the generate button.

I get this error in blender:

Python: Traceback (most recent call last):
File "C:\Users\VidEvage\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\SDTG4B-release\operators.py", line 427, in invoke
self.wm.progress_begin(0, 100)
ReferenceError: StructRNA of type WindowManager has been removed

Inside the Conda it more or less stops at this point and I can't seem to connect to Stable Diffusion:

127.0.0.1 - - [20/Feb/2023 22:06:52] "GET /status HTTP/1.1" 200 -

I typcally use Automatic1111 for SD, so I'm not sure where the disconnect for this is. Any insight you could give me on why this isn't working would be fantastic, as currently the way you handle SD in Blender with this looking right on point to what I'd like to get to. Dream's texture plugin, while great, falls short of surrounding the whole model with a texture bake based on depth maps.

Hi

Automatic1111 is missing Depth2img, when they'll add it, I'd prefer to switch. On the other hand, maybe just forking the project and adding it was the way to go.

hmm.. check in the browser:
127.0.0.1:{port here}/status
If you'll see some connection error, then something is wrong. I see that line 127 of operators.py should be a connection error, so something might be wrong.
But apart from the line, the error message points to a different issue: possibly I should not pass the WindowManager and just get it there from bpy.context.window_manager, I do not remember why it was done like this.. I cannot test it now, but later I'll check it out. This could be an easy fix.

Thanks, I appreciate it and any time to check in on it.
Just checked the http://127.0.0.1:5000/status after launching the SD Server Host and it came back as an empty screen with no connection error mentioned. Just a blank page. (Keep in mind my coding experience is pretty barren, I usually trial and error my way through things, I wouldn't have bugged you on this normally but I hit a wall here).

Chatting with ChatGPT it had mentioned something similiar to what you just said on the note of passing the WindowManager.
I'm working off Blender 3.3.1 and just realized perhaps I should update to to the latest 3.4.1 if that makes any difference. If it does I'll update you here.

I tested the change, and it works for me, so you can test it out when you'll have time:
https://github.com/p4vv37/SDTG4B/releases/tag/0.0.2

If you did not get the error, it's ok. I hope that I'll have some time soon to improve or replace the server, but today is not yet the day for that :)

btw this idea of getting IT support-type help from ChatGPT is awesome :D I'm not sure if the Blender version would matter, but I think it should work.

Okay!

Got it to work. Though I did have to further change the code in operators.py

I ran into this error on the new version:

Python: Traceback (most recent call last):
File "C:\Users\VidEvage\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\SDTG4B\operators.py", line 395, in invoke
bpy.context.window_manager = bpy.context.window_manager
AttributeError: bpy_struct: attribute "window_manager" from "Context" is read-only

After some back and forth with ChatGPT the solution was a change on line 395.

self.window_manager = context.window_manager
to:
self.window_manager = bpy.context.window_manager

And voila. Works now. Takes awhile to process. (I'm assuming this connects to one of the SD online servers? Would love to run locally eventually) Can definitely see some of the jank but I'm still getting my feet wet with it. The concept alone is still super cool. I'll be playing around with this for a bit. Thanks so much for your help and for making this.

Hi

Great! The SD works locally, you can play with options to make it run faster, they're in the UI in the stable diffusion settings tab. Significantly lowering the number of iterations, "Number of interference steps", could help a lot, even 10 could work, which would be 10x faster. views_num is 4 by default, but possibly for some objects 3 could work fine. The resolution also affects speed a lot, both resolution of texture and Resolution X and Resolution Y of SD generation settings.
There are also a lot of optimizations that can be done in code, I do a lot of things on loops on every element in the array, which could be replaced with CV2 methods, probably. This could be a very significant speedup.
But right, it's slow right now.
Thank you, I submitted a commit with a similar change.