forked from carson-katri/dream-textures
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5d255de
commit c99b560
Showing
11 changed files
with
271 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import numpy as np | ||
from numpy.typing import NDArray | ||
from ..models.optimizations import Optimizations | ||
|
||
def controlnet_aux( | ||
self, | ||
|
||
processor_id: str, | ||
image: NDArray, | ||
|
||
optimizations: Optimizations, | ||
|
||
**kwargs | ||
) -> NDArray: | ||
if processor_id == "none": | ||
return image | ||
|
||
from controlnet_aux.processor import Processor | ||
processor = Processor(processor_id) | ||
device = self.choose_device(optimizations) | ||
processor.processor.to(device) | ||
|
||
processed_image = processor(image) | ||
return np.array(processed_image) / 255.0 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,88 @@ | ||
import bpy | ||
from bpy.props import FloatProperty, EnumProperty, PointerProperty | ||
from bpy.props import FloatProperty, EnumProperty, PointerProperty, IntProperty, BoolProperty | ||
|
||
def control_net_options(self, context): | ||
return [ | ||
None if model is None else (model.id, model.name, model.description) | ||
for model in context.scene.dream_textures_prompt.get_backend().list_controlnet_models(context) | ||
] | ||
|
||
PROCESSOR_IDS = [ | ||
("none", "None", "No pre-processing"), | ||
None, | ||
("depth_leres", "Depth (LeRes)", ""), | ||
("depth_leres++", "Depth (LeRes++)", ""), | ||
("depth_midas", "Depth (MiDaS)", ""), | ||
("depth_zoe", "Depth (Zoe)", ""), | ||
None, | ||
("canny", "Canny", "Canny edge detection"), | ||
("mlsd", "M-LSD", ""), | ||
("softedge_hed", "Soft Edge (HED)", ""), | ||
("softedge_hedsafe", "Soft Edge (HED-Safe)", ""), | ||
("softedge_pidinet", "Soft Edge (PidiNet)", ""), | ||
("softedge_pidsafe", "Soft Edge (Pidsafe)", ""), | ||
None, | ||
("lineart_anime", "Lineart (Anime)", ""), | ||
("lineart_coarse", "Lineart (Coarse)", ""), | ||
("lineart_realistic", "Lineart (Realistic)", ""), | ||
None, | ||
("normal_bae", "Normal (BAE)", ""), | ||
("normal_midas", "Normal (MiDaS)", ""), | ||
None, | ||
("openpose", "OpenPose", ""), | ||
("openpose_face", "OpenPose (Face)", ""), | ||
("openpose_faceonly", "OpenPose (Face Only)", ""), | ||
("openpose_full", "OpenPose (Full)", ""), | ||
("openpose_hand", "OpenPose (Hand)", ""), | ||
("dwpose", "DWPose", ""), | ||
("mediapipe_face", "MediaPipe Face", ""), | ||
None, | ||
("scribble_hed", "Scribble (HED)", ""), | ||
("scribble_pidinet", "Scribble (PidiNet)", ""), | ||
None, | ||
("shuffle", "Shuffle", ""), | ||
] | ||
|
||
class ControlNet(bpy.types.PropertyGroup): | ||
control_net: EnumProperty(name="ControlNet", items=control_net_options, description="Specify which ControlNet to use") | ||
conditioning_scale: FloatProperty(name="ControlNet Conditioning Scale", default=1.0, description="Increases the strength of the ControlNet's effect") | ||
conditioning_scale: FloatProperty(name="Conditioning Scale", default=1.0, description="Increases the strength of the ControlNet's effect") | ||
control_image: PointerProperty(type=bpy.types.Image) | ||
processor_id: EnumProperty( | ||
name="Processor", | ||
items=PROCESSOR_IDS, | ||
description="Pre-process the control image" | ||
) | ||
enabled: BoolProperty(name="Enabled", default=True) | ||
|
||
class ControlNetsAddMenu(bpy.types.Menu): | ||
bl_idname = "DREAM_MT_control_nets_add" | ||
bl_label = "Add ControlNet" | ||
|
||
def draw(self, context): | ||
layout = self.layout | ||
|
||
class SCENE_UL_ControlNetList(bpy.types.UIList): | ||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname): | ||
layout.separator() | ||
layout.prop(item, "control_net", text="") | ||
layout.prop(item, "conditioning_scale", text="") | ||
layout.template_ID(item, "control_image", open="image.open") | ||
for model in control_net_options(self, context): | ||
if model is None: | ||
layout.separator() | ||
else: | ||
layout.operator("dream_textures.control_nets_add", text=model[1]).control_net = model[0] | ||
|
||
class ControlNetsAdd(bpy.types.Operator): | ||
bl_idname = "dream_textures.control_nets_add" | ||
bl_label = "Add ControlNet" | ||
|
||
control_net: EnumProperty(name="ControlNet", items=control_net_options) | ||
|
||
def execute(self, context): | ||
context.scene.dream_textures_prompt.control_nets.add() | ||
net = context.scene.dream_textures_prompt.control_nets.add() | ||
net.control_net = self.control_net | ||
return {'FINISHED'} | ||
class ControlNetsRemove(bpy.types.Operator): | ||
bl_idname = "dream_textures.control_nets_remove" | ||
bl_label = "Add ControlNet" | ||
bl_label = "Remove ControlNet" | ||
|
||
index: IntProperty(name="Index") | ||
|
||
def execute(self, context): | ||
context.scene.dream_textures_prompt.control_nets.remove(context.scene.dream_textures_prompt.active_control_net) | ||
context.scene.dream_textures_prompt.control_nets.remove(self.index) | ||
return {'FINISHED'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters