Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a3b0beac1 | ||
|
|
28e19ce5d2 |
@@ -261,12 +261,44 @@ class Sam2RealtimeSegmentation:
|
||||
|
||||
return (stacked_frames, stacked_masks)
|
||||
|
||||
class BoundingBoxToCenter:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"bbox_data": ("JSON",),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("STRING",)
|
||||
RETURN_NAMES = ("center_coordinates",)
|
||||
FUNCTION = "convert_bbox_to_center"
|
||||
CATEGORY = "SAM2-Realtime"
|
||||
|
||||
def convert_bbox_to_center(self, bbox_data):
|
||||
try:
|
||||
bbox_list = ast.literal_eval(bbox_data)
|
||||
tlx, tly, brx, bry = bbox_list[0][0]
|
||||
|
||||
center_x = int((tlx + brx) / 2)
|
||||
center_y = int((tly + bry) / 2)
|
||||
|
||||
center_coords = f"[[{center_x}, {center_y}]]"
|
||||
|
||||
return (center_coords,)
|
||||
|
||||
except (ValueError, SyntaxError, IndexError) as e:
|
||||
print(f"Error processing bounding box data: {e}")
|
||||
return ("[[0, 0]]",)
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"DownloadAndLoadSAM2RealtimeModel": DownloadAndLoadSAM2RealtimeModel,
|
||||
"Sam2RealtimeSegmentation": Sam2RealtimeSegmentation
|
||||
"Sam2RealtimeSegmentation": Sam2RealtimeSegmentation,
|
||||
"BoundingBoxToCenter": BoundingBoxToCenter
|
||||
}
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"DownloadAndLoadSAM2RealtimeModel": "(Down)Load sam2_realtime Model",
|
||||
"Sam2RealtimeSegmentation": "Sam2RealtimeSegmentation"
|
||||
"Sam2RealtimeSegmentation": "Sam2RealtimeSegmentation",
|
||||
"BoundingBoxToCenter": "BoundingBox To Center"
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,4 +4,4 @@ tqdm>=4.66.1
|
||||
hydra-core>=1.3.2
|
||||
iopath>=0.1.10
|
||||
pillow>=9.4.0
|
||||
git+https://github.com/pschroedl/ComfyUI-SAM2-Realtime.git@main#egg=sam2_realtime
|
||||
-e .
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
# This source code is licensed under the license found in the
|
||||
# LICENSE file in the root directory of this source tree.
|
||||
|
||||
import os
|
||||
# Set the CUDA architecture list
|
||||
os.environ["TORCH_CUDA_ARCH_LIST"] = "8.0 8.6+PTX 8.7 9.0 9.0a"
|
||||
|
||||
from setuptools import find_packages, setup
|
||||
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
|
||||
|
||||
@@ -57,7 +53,7 @@ setup(
|
||||
license=LICENSE,
|
||||
packages=find_packages(),
|
||||
install_requires=REQUIRED_PACKAGES,
|
||||
python_requires=">=3.10.15",
|
||||
python_requires=">=3.11.10",
|
||||
ext_modules=get_extensions(),
|
||||
cmdclass={"build_ext": BuildExtension.with_options(no_python_abi_suffix=True)},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user