mirror of
https://git.datalinker.icu/kijai/ComfyUI-KJNodes.git
synced 2026-05-02 11:00:12 +08:00
Fix InstanceDiffusion bboxes
Seems it uses x1, y2, x2, y2 instead of x, y, width, height
This commit is contained in:
parent
4412c67aa6
commit
8ccc080bf4
@ -114,7 +114,7 @@ NODE_CONFIG = {
|
|||||||
"GLIGENTextBoxApplyBatchCoords": {"class": GLIGENTextBoxApplyBatchCoords},
|
"GLIGENTextBoxApplyBatchCoords": {"class": GLIGENTextBoxApplyBatchCoords},
|
||||||
"Intrinsic_lora_sampling": {"class": Intrinsic_lora_sampling, "name": "Intrinsic Lora Sampling"},
|
"Intrinsic_lora_sampling": {"class": Intrinsic_lora_sampling, "name": "Intrinsic Lora Sampling"},
|
||||||
"CreateInstanceDiffusionTracking": {"class": CreateInstanceDiffusionTracking},
|
"CreateInstanceDiffusionTracking": {"class": CreateInstanceDiffusionTracking},
|
||||||
"AppendInstanceDiffusionTracking": {"class": AppendInstanceDiffusionTracking, "name": "Append Diffusion Tracking"},
|
"AppendInstanceDiffusionTracking": {"class": AppendInstanceDiffusionTracking},
|
||||||
}
|
}
|
||||||
|
|
||||||
def generate_node_mappings(node_config):
|
def generate_node_mappings(node_config):
|
||||||
|
|||||||
@ -76,8 +76,8 @@ class PlotCoordinates:
|
|||||||
},
|
},
|
||||||
"optional": {"size_multiplier": ("FLOAT", {"default": [1.0], "forceInput": True})},
|
"optional": {"size_multiplier": ("FLOAT", {"default": [1.0], "forceInput": True})},
|
||||||
}
|
}
|
||||||
RETURN_TYPES = ("IMAGE", )
|
RETURN_TYPES = ("IMAGE", "INT", "INT", "INT", "INT",)
|
||||||
RETURN_NAMES = ("images", )
|
RETURN_NAMES = ("images", "width", "height", "bbox_width", "bbox_height",)
|
||||||
FUNCTION = "append"
|
FUNCTION = "append"
|
||||||
CATEGORY = "KJNodes/experimental"
|
CATEGORY = "KJNodes/experimental"
|
||||||
DESCRIPTION = """
|
DESCRIPTION = """
|
||||||
@ -94,7 +94,7 @@ Plots coordinates to sequence of images using Matplotlib.
|
|||||||
|
|
||||||
plot_image_tensor = plot_coordinates_to_tensor(coordinates, height, width, bbox_height, bbox_width, size_multiplier, text)
|
plot_image_tensor = plot_coordinates_to_tensor(coordinates, height, width, bbox_height, bbox_width, size_multiplier, text)
|
||||||
|
|
||||||
return (plot_image_tensor,)
|
return (plot_image_tensor, width, height, bbox_width, bbox_height)
|
||||||
|
|
||||||
class SplineEditor:
|
class SplineEditor:
|
||||||
|
|
||||||
@ -665,7 +665,7 @@ bounding boxes.
|
|||||||
|
|
||||||
for i in range(batch_size):
|
for i in range(batch_size):
|
||||||
x_position, y_position = coordinates[i]
|
x_position, y_position = coordinates[i]
|
||||||
position_param = (cond_pooled, int((height // 8) * size_multiplier[i]), int((width // 8) * size_multiplier[i]), (y_position - height / 2) // 8, (x_position - width / 2) // 8)
|
position_param = (cond_pooled, int((height // 8) * size_multiplier[i]), int((width // 8) * size_multiplier[i]), (y_position - height // 2) // 8, (x_position - width // 2) // 8)
|
||||||
position_params_batch[i].append(position_param) # Append position_param to the correct sublist
|
position_params_batch[i].append(position_param) # Append position_param to the correct sublist
|
||||||
|
|
||||||
prev = []
|
prev = []
|
||||||
@ -687,8 +687,8 @@ bounding boxes.
|
|||||||
|
|
||||||
class CreateInstanceDiffusionTracking:
|
class CreateInstanceDiffusionTracking:
|
||||||
|
|
||||||
RETURN_TYPES = ("TRACKING",)
|
RETURN_TYPES = ("TRACKING", "INT", "INT", "INT", "INT",)
|
||||||
RETURN_NAMES = ("TRACKING",)
|
RETURN_NAMES = ("tracking", "width", "height", "bbox_width", "bbox_height",)
|
||||||
FUNCTION = "tracking"
|
FUNCTION = "tracking"
|
||||||
CATEGORY = "KJNodes/experimental"
|
CATEGORY = "KJNodes/experimental"
|
||||||
DESCRIPTION = """
|
DESCRIPTION = """
|
||||||
@ -710,8 +710,7 @@ for example:
|
|||||||
"height": ("INT", {"default": 512,"min": 16, "max": 4096, "step": 1}),
|
"height": ("INT", {"default": 512,"min": 16, "max": 4096, "step": 1}),
|
||||||
"bbox_width": ("INT", {"default": 512,"min": 16, "max": 4096, "step": 1}),
|
"bbox_width": ("INT", {"default": 512,"min": 16, "max": 4096, "step": 1}),
|
||||||
"bbox_height": ("INT", {"default": 512,"min": 16, "max": 4096, "step": 1}),
|
"bbox_height": ("INT", {"default": 512,"min": 16, "max": 4096, "step": 1}),
|
||||||
|
"class_name": ("STRING", {"default": "class_name"}),
|
||||||
"class_name": ("STRING", {"default": "class_id"}),
|
|
||||||
"class_id": ("INT", {"default": 0,"min": 0, "max": 255, "step": 1}),
|
"class_id": ("INT", {"default": 0,"min": 0, "max": 255, "step": 1}),
|
||||||
},
|
},
|
||||||
"optional": {
|
"optional": {
|
||||||
@ -730,16 +729,28 @@ for example:
|
|||||||
# Initialize a list to hold the coordinates for the current ID
|
# Initialize a list to hold the coordinates for the current ID
|
||||||
id_coordinates = []
|
id_coordinates = []
|
||||||
|
|
||||||
for detection in coordinates:
|
for coord in coordinates:
|
||||||
# Append the 'x' and 'y' coordinates along with bbox width/height and frame width/height to the list for the current ID
|
x = coord['x']
|
||||||
id_coordinates.append([detection['x'], detection['y'], bbox_width, bbox_height, width, height])
|
y = coord['y']
|
||||||
|
# Calculate the top left and bottom right coordinates
|
||||||
|
top_left_x = x - bbox_width // 2
|
||||||
|
top_left_y = y - bbox_height // 2
|
||||||
|
bottom_right_x = x + bbox_width // 2
|
||||||
|
bottom_right_y = y + bbox_height // 2
|
||||||
|
|
||||||
|
# Append the top left and bottom right coordinates to the list for the current ID
|
||||||
|
id_coordinates.append([top_left_x, top_left_y, bottom_right_x, bottom_right_y, width, height])
|
||||||
|
|
||||||
|
# Append the 'x' and 'y' coordinates along with bbox width/height and frame width/height to the list for the current ID
|
||||||
|
#id_coordinates.append([coord['x'] - bbox_width // 2 , coord['y'] - bbox_height // 2, bbox_width, bbox_height, width, height])
|
||||||
|
|
||||||
|
class_id = int(class_id)
|
||||||
|
print(class_id)
|
||||||
# Assign the list of coordinates to the specified ID within the class_id dictionary
|
# Assign the list of coordinates to the specified ID within the class_id dictionary
|
||||||
tracked[class_name][class_id] = id_coordinates
|
tracked[class_name][class_id] = id_coordinates
|
||||||
|
|
||||||
|
|
||||||
print(tracked)
|
print(tracked)
|
||||||
return (tracked, )
|
|
||||||
|
return (tracked, width, height, bbox_width, bbox_height,)
|
||||||
|
|
||||||
class AppendInstanceDiffusionTracking:
|
class AppendInstanceDiffusionTracking:
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user