Skip to content

Commit

Permalink
check weights installed (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
NullSenseStudio committed Oct 18, 2022
1 parent 5e860d4 commit 03e3250
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
20 changes: 12 additions & 8 deletions operators/dream_texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
last_data_block = None
timer = None

def weights_are_installed(report = None):
weights_installed = os.path.exists(WEIGHTS_PATH)
if report and (not weights_installed):
report({'ERROR'}, "Please complete setup in the preferences window.")
return weights_installed

class DreamTexture(bpy.types.Operator):
bl_idname = "shade.dream_texture"
bl_label = "Dream Texture"
Expand All @@ -25,7 +31,12 @@ class DreamTexture(bpy.types.Operator):
@classmethod
def poll(cls, context):
return GeneratorProcess.can_use()


def invoke(self, context, event):
if weights_are_installed(self.report):
return self.execute(context)
return {'CANCELLED'}

def execute(self, context):
history_entry = context.preferences.addons[StableDiffusionPreferences.bl_idname].preferences.history.add()
for prop in context.scene.dream_textures_prompt.__annotations__.keys():
Expand Down Expand Up @@ -113,13 +124,6 @@ class HeadlessDreamTexture(bpy.types.Operator):
def poll(cls, context):
return GeneratorProcess.can_use()

def invoke(self, context, event):
weights_installed = os.path.exists(WEIGHTS_PATH)
if not weights_installed:
self.report({'ERROR'}, "Please complete setup in the preferences window.")
return {'CANCELLED'}
return self.execute(context)

def modal(self, context, event):
if event.type != 'TIMER':
return {'PASS_THROUGH'}
Expand Down
4 changes: 3 additions & 1 deletion render_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from .generator_process import GeneratorProcess

from .operators.dream_texture import dream_texture
from .operators.dream_texture import dream_texture, weights_are_installed

update_render_passes_original = cycles.CyclesRender.update_render_passes
render_original = cycles.CyclesRender.render
Expand Down Expand Up @@ -41,6 +41,8 @@ def render(self, depsgraph):
if size_x % 64 != 0 or size_y % 64 != 0:
self.report({"ERROR"}, f"Image dimensions must be multiples of 64 (e.x. 512x512, 512x768, ...) closest is {round(size_x/64)*64}x{round(size_y/64)*64}")
return result
if not weights_are_installed(self.report):
return result
render_result = self.begin_result(0, 0, size_x, size_y)
for original_layer in original_result.layers:
layer = None
Expand Down

0 comments on commit 03e3250

Please sign in to comment.