Skip to content

Commit 71882df

Browse files
authored
History and Troubleshooting Panels (#132)
* Move Troubleshooting and History into panels * Update VERSION * Fix version checking * Remove concept artist picker * Fix issue with inpaint/init image toggling * Improve history header
1 parent f67fb7f commit 71882df

File tree

10 files changed

+127
-133
lines changed

10 files changed

+127
-133
lines changed

__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,16 @@
1616
"author": "Carson Katri, Greg Richardson, Kevin C. Burke",
1717
"description": "Use Stable Diffusion to generate unique textures straight from the shader editor.",
1818
"warning": "Requires installation of Stable Diffusion model weights",
19-
"blender": (2, 80, 0),
20-
"version": (0, 0, 5),
19+
"blender": (3, 0, 0),
20+
"version": (0, 0, 6),
2121
"location": "",
2222
"warning": "",
23-
"category": "Node"
23+
"category": "Paint"
2424
}
2525

2626
import bpy
2727
from bpy.props import IntProperty, PointerProperty, EnumProperty
2828
import sys
29-
import importlib
3029

3130
from .help_section import register_section_props
3231

classes.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
from .operators.install_dependencies import InstallDependencies
22
from .operators.open_latest_version import OpenLatestVersion
33
from .operators.dream_texture import DreamTexture, ReleaseGenerator
4-
from .operators.help_panel import HelpPanel
5-
from .operators.view_history import RecallHistoryEntry, SCENE_UL_HistoryList, ViewHistory
4+
from .operators.view_history import RecallHistoryEntry, SCENE_UL_HistoryList
65
from .operators.inpaint_area_brush import InpaintAreaStroke
76
from .property_groups.dream_prompt import DreamPrompt
8-
from .ui.panel import DREAM_PT_dream_panel, DREAM_PT_dream_node_panel
7+
from .ui.panel import panels, history_panels, troubleshooting_panels
98
from .preferences import OpenGitDownloads, OpenHuggingFace, OpenWeightsDirectory, OpenRustInstaller, ValidateInstallation, StableDiffusionPreferences
109

1110
CLASSES = (
1211
DreamTexture,
1312
ReleaseGenerator,
14-
HelpPanel,
1513
OpenLatestVersion,
16-
ViewHistory,
1714
RecallHistoryEntry,
1815
InpaintAreaStroke,
1916
SCENE_UL_HistoryList,
20-
DREAM_PT_dream_panel,
21-
DREAM_PT_dream_node_panel,
17+
*panels(),
18+
*history_panels(),
19+
*troubleshooting_panels(),
2220
)
2321

2422
PREFERENCE_CLASSES = (

generator_process.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ def view_step(samples, step):
198198
return # stdin closed
199199
args = json.loads(stdin.read(json_len))
200200

201-
if generator is None or generator.full_precision != args['full_precision']:
202-
writeInfo("Initializing Generator")
201+
if generator is None or (generator.full_precision != args['full_precision'] and sys.platform != 'darwin'):
202+
writeInfo("Loading Model")
203203
try:
204204
generator = Generate(
205205
conf=models_config,

operators/dream_texture.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@
2020
last_data_block = None
2121
timer = None
2222

23-
def image_has_alpha(img):
24-
b = 32 if img.is_float else 8
25-
return (
26-
img.depth == 2*b or # Grayscale+Alpha
27-
img.depth == 4*b # RGB+Alpha
28-
)
29-
3023
class DreamTexture(bpy.types.Operator):
3124
bl_idname = "shade.dream_texture"
3225
bl_label = "Dream Texture"
@@ -162,7 +155,7 @@ def save_temp_image(img, path=None):
162155
if scene.dream_textures_prompt.use_inpainting:
163156
for area in screen.areas:
164157
if area.type == 'IMAGE_EDITOR':
165-
if area.spaces.active.image is not None and image_has_alpha(area.spaces.active.image):
158+
if area.spaces.active.image is not None:
166159
init_img = area.spaces.active.image
167160
init_img_path = None
168161
if init_img is not None:

operators/help_panel.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

operators/view_history.py

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,20 @@
11
import bpy
22
from ..property_groups.dream_prompt import sampler_options
33
from ..preferences import StableDiffusionPreferences
4-
5-
class ViewHistory(bpy.types.Operator):
6-
bl_idname = "shade.dream_textures_history"
7-
bl_label = "History"
8-
bl_description = "View and reload previous prompts"
9-
bl_options = {'REGISTER'}
10-
11-
selection: bpy.props.IntProperty(name="Selection")
12-
13-
@classmethod
14-
def poll(self, context):
15-
return True
16-
17-
def invoke(self, context, event):
18-
return context.window_manager.invoke_props_dialog(self, width=500)
19-
20-
def draw(self, context):
21-
# split = self.layout.split(factor=0.95)
22-
# header = split.row()
23-
header = self.layout.row()
24-
header.label(text="Subject")
25-
header.label(text="Size")
26-
header.label(text="Steps")
27-
header.label(text="Sampler")
28-
self.layout.template_list("SCENE_UL_HistoryList", "", context.preferences.addons[StableDiffusionPreferences.bl_idname].preferences, "history", context.scene, "dream_textures_history_selection")
29-
self.layout.operator(RecallHistoryEntry.bl_idname)
30-
31-
def execute(self, context):
32-
return {"FINISHED"}
334

345
class SCENE_UL_HistoryList(bpy.types.UIList):
356
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
367
if self.layout_type in {'DEFAULT', 'COMPACT'}:
37-
layout.label(text=item.get_prompt_subject(), translate=False, icon_value=icon)
38-
layout.label(text=f"{item.width}x{item.height}", translate=False)
39-
layout.label(text=f"{item.steps} steps", translate=False)
40-
layout.label(text=next(x for x in sampler_options if x[0] == item.sampler)[1], translate=False)
8+
if item.prompt_structure_token_subject == "SCENE_UL_HistoryList_header":
9+
layout.label(text="Subject")
10+
layout.label(text="Size")
11+
layout.label(text="Steps")
12+
layout.label(text="Sampler")
13+
else:
14+
layout.label(text=item.get_prompt_subject(), translate=False, icon_value=icon)
15+
layout.label(text=f"{item.width}x{item.height}", translate=False)
16+
layout.label(text=f"{item.steps} steps", translate=False)
17+
layout.label(text=next(x for x in sampler_options if x[0] == item.sampler)[1], translate=False)
4118
elif self.layout_type == 'GRID':
4219
layout.alignment = 'CENTER'
4320
layout.label(text="", icon_value=icon)
@@ -50,13 +27,12 @@ class RecallHistoryEntry(bpy.types.Operator):
5027

5128
@classmethod
5229
def poll(self, context):
53-
return context.scene.dream_textures_history_selection is not None
30+
return context.scene.dream_textures_history_selection is not None and context.scene.dream_textures_history_selection > 0
5431

5532
def execute(self, context):
5633
selection = context.preferences.addons[StableDiffusionPreferences.bl_idname].preferences.history[context.scene.dream_textures_history_selection]
5734
for prop in selection.__annotations__.keys():
5835
if hasattr(context.scene.dream_textures_prompt, prop):
5936
setattr(context.scene.dream_textures_prompt, prop, getattr(selection, prop))
60-
bpy.ops.shade.dream_texture('INVOKE_DEFAULT')
6137

6238
return {"FINISHED"}

prompt_engineering.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,6 @@ def photography_prompt(tokens):
9898
('vehicle', 'Vehicle'),
9999
))
100100

101-
concept_artist_token = PromptToken('concept_artist', 'Concept Artist', (
102-
('blevins', 'Neil Blevins'),
103-
('grimmer', 'Jordan Grimmer'),
104-
('mullins', 'Craig Mullins'),
105-
('rutkowski', 'Greg Rutkowski'),
106-
('shinkai', 'Makoto Shinkai'),
107-
('simonetti', 'Mark Simonetti'),
108-
('stalenhag', 'Simon Stalenhag'),
109-
))
110-
111101
genre_token = PromptToken('genre', 'Genre', (
112102
('scifi', 'Sci-Fi'),
113103
('fantasy', 'Fantasy'),
@@ -116,12 +106,12 @@ def photography_prompt(tokens):
116106
))
117107

118108
def concept_art_prompt(tokens):
119-
return f"{tokens.subject}, {tokens.subject_type} concept art, {tokens.genre} digital painting, by {tokens.concept_artist}, trending on ArtStation"
109+
return f"{tokens.subject}, {tokens.subject_type} concept art, {tokens.genre} digital painting, trending on ArtStation"
120110

121111
concept_art_structure = PromptStructure(
122112
'concept_art',
123113
'Concept Art',
124-
(subject_token, subject_type_token, genre_token, concept_artist_token),
114+
(subject_token, subject_type_token, genre_token),
125115
concept_art_prompt
126116
)
127117

property_groups/dream_prompt.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import bpy
22
from bpy.props import FloatProperty, IntProperty, EnumProperty, BoolProperty, StringProperty, PointerProperty
33
from ..prompt_engineering import *
4+
import sys
45

56
sampler_options = [
67
("ddim", "DDIM", "", 1),
@@ -37,7 +38,7 @@ def seed_clamp(self, ctx):
3738
"show_advanced": BoolProperty(name="", default=False),
3839
"random_seed": BoolProperty(name="Random Seed", default=True, description="Randomly pick a seed"),
3940
"seed": StringProperty(name="Seed", default="0", description="Manually pick a seed", update=seed_clamp),
40-
"full_precision": BoolProperty(name="Full Precision", default=False, description="Whether to use full precision or half precision floats. Full precision is slower, but required by some GPUs"),
41+
"full_precision": BoolProperty(name="Full Precision", default=True if sys.platform == 'darwin' else False, description="Whether to use full precision or half precision floats. Full precision is slower, but required by some GPUs"),
4142
"iterations": IntProperty(name="Iterations", default=1, min=1, description="How many images to generate"),
4243
"steps": IntProperty(name="Steps", default=25, min=1),
4344
"cfg_scale": FloatProperty(name="CFG Scale", default=7.5, min=1, description="How strongly the prompt influences the image"),

0 commit comments

Comments
 (0)