Commit Graph
92 Commits
Author SHA1 Message Date
limbicnation 3168ecdd67 fix: remove schemas.py, use src.validation consistently
- Remove duplicate schemas.py (near-duplicate of src/validation.py)
- Update test_node_smoke.py to import from src.validation
- All 9 smoke tests pass
2026-04-24 05:29:36 +02:00
limbicnation ba22db3be5 feat: audit fixes, validation, smoke tests, and conflict resolution
- Add Pydantic parameter validation (src/validation.py)
- Add structured logging with structlog fallback
- Add IS_CHANGED, OUTPUT_NODE, DESCRIPTION metadata to all nodes
- Add comprehensive smoke and unit tests
- Fix invert_mask double-application bug
- Fix create_fallback_processor()() double call
- Resolve merge conflicts in .gitignore, grabcut_nodes.py, nodes.py, requirements.txt
- Remove FLOYO_INTEGRATION_GUIDE.md, schemas.py (superseded)
- Update CI: Python 3.10-3.12, pytest smoke tests
2026-04-24 05:18:02 +02:00
limbicnation cb221b16a2 chore: gitignore local tool state and publish artifact
- Ignore .claude/, .kilo/, .memory/, kilo.json — IDE/CLI caches that
  shouldn't be shared. .kilo/ alone was 58MB of tool state.
- Ignore node.zip — generated by `comfy node publish`, not source.

Remove existing node.zip (8.6MB) from the working tree. It wasn't tracked,
but it was sitting at the repo root cluttering listings.
2026-04-24 04:37:57 +02:00
limbicnation 84deeb20bf fix: wire up PR #15 validation/logging and add smoke tests
PR #15 shipped four NameError-class bugs that crash at call time but slip
past import-only CI: validate_node_params, log, _log_gpu_memory, and
invert_mask were referenced without being defined.

This commit:

- Adds schemas.py with Pydantic v2 NodeParams (ranges mirror INPUT_TYPES)
  and a dataclass fallback so minimal envs still validate.
- Adds a structlog-or-stdlib logging guard and _log_gpu_memory helper at
  the top of grabcut_nodes.py; the stdlib adapter preserves exc_info
  semantics.
- Exposes invert_mask on both AutoGrabCutRemover and GrabCutRefinement —
  INPUT_TYPES, function signature, and applied to the alpha channel in
  every success/fallback path.
- Fixes torch.stack shape mismatch in GrabCutRefinement.refine_mask: all
  branches now run through the same resize so batches can stack when
  output_size != ORIGINAL.
- Narrows the validation exception handler to (ValidationError,
  ValueError, TypeError).
- Adds OUTPUT_NODE, DESCRIPTION, and IS_CHANGED (deterministic sha256
  hash over scalar inputs) to all four node classes.
- Adds test_node_smoke.py with 9 tests that actually invoke each node's
  FUNCTION, plus parameter validation and regression tests for the
  invert_mask / resize-stack bugs.
- Wires pytest test_node_smoke.py into CI and drops continue-on-error
  from flake8 so real syntax/name errors now block.
- Fixes __init__.py relative imports so pytest can collect tests whose
  parent dir name isn't a valid Python identifier.
- Adds pydantic>=2.0 and structlog>=23.0 to requirements.txt.
2026-04-24 04:34:14 +02:00
limbicnation 6b86f14324 feat: audit fixes — OUTPUT_NODE, DESCRIPTION, IS_CHANGED, structlog guard, CI Python versions
- Add OUTPUT_NODE=True to all 5 node classes for ComfyUI execution triggers
- Add DESCRIPTION attributes for ComfyUI 0.19+ frontend info panel
- Add IS_CHANGED with deterministic hash for execution caching (H100 compute savings)
- Guard structlog import in grabcut_nodes.py with stdlib logging fallback
- Update CI Python matrix to 3.10-3.12 (drop EOL 3.8/3.9)
- Remove dead RGBA loop in GrabCutRefinement (redundant alpha multiply)
- Wire all Pydantic-validated params in AutoGrabCutRemover
2026-04-24 03:26:54 +02:00
limbicnation 5ef7a445a7 Updated pyproject to 1.3.0 2026-04-22 05:56:26 +02:00
Gero Doll 74bb29dbe1 Merge pull request #14 from Limbicnation/chore/lint-and-docs
Chore/lint and docs
2026-04-22 05:53:27 +02:00
limbicnation d53c734df1 docs: update README with v1.2.0 node and dev instructions
- Add missing dependencies (ultralytics, pydantic, structlog, opencv-contrib)
- Document RemoveBackgroundAndResizeNode
- Add Development section with testing, linting, and project structure
2026-04-22 05:01:13 +02:00
limbicnation faab680db5 chore: lint cleanup and artifact removal
- Remove unused imports (ruff F401)
- Fix f-strings without placeholders (ruff F541)
- Resolve E402 import ordering in grabcut_nodes.py
- Fix B108 hardcoded /tmp fallback in nodes.py (use tempfile.gettempdir())
- Delete untracked artifacts: .claude/, node.zip, __pycache__/
- Add .claude/ and *.zip to .gitignore
2026-04-22 04:57:18 +02:00
limbicnation 5e880496fd chore: bump version to 1.2.0 for RemoveBackgroundAndResizeNode release 2026-04-20 07:27:32 +02:00
Gero Doll 6ccd894989 Merge pull request #13 from Limbicnation/feature/remove-background-resize-node
feat: add RemoveBackgroundAndResizeNode — standalone PIL-only backgro…
2026-04-20 07:18:21 +02:00
limbicnation a27550b7f3 fix: address code review issues from PR #13
Bugs:
- Remove unused edge_sensitivity param from remove_background_pil()
- Add try/except fallback for structlog import (was ImportError outside ComfyUI)

Warnings:
- Subsample pixels in _kmeans_colors() to prevent OOM on 4K images
- Set OUTPUT_NODE = True (node produces terminal IMAGE+MASK output)
- Narrow except Exception to except ImportError in __init__.py

Suggestions:
- Extract ScalingMixin to shared scaling.py (used by both nodes)
- Remove unused comfy.utils import and _COMFY_AVAILABLE flag
2026-04-20 07:08:10 +02:00
limbicnation 36e20e6052 feat: add RemoveBackgroundAndResizeNode — standalone PIL-only background removal with resize
- Single-file node combining background removal + resize (no external background_remover.py dependency)
- PIL-only implementation: k-means colour clustering, dominant-bg estimation from edges, alpha binarisation
- ScalingMixin from grabcut_nodes.py: power-of-8 resize, 6 preset sizes + ORIGINAL
- ComfyUI contract: INPUT_TYPES, RETURN_TYPES (IMAGE + MASK), FUNCTION, CATEGORY
- Registered in __init__.py alongside existing TransparencyBackgroundRemover and GrabCut nodes
- structlog logging, torch.no_grad() guard, full validation
2026-04-20 00:11:30 +02:00
limbicnation 21cc047d54 fix: install project deps before import test in publish workflow 2026-03-31 06:24:37 +02:00
Gero Doll 711b5be4c3 Merge pull request #12 from Limbicnation/feature/grabcut-h100-optimized
feat: GrabCut H100 optimization — torch.no_grad, Pydantic validation,…
2026-03-31 06:19:17 +02:00
limbicnation e64319c780 fix: align CI matrix to Python 3.10+, extract all Pydantic-validated params, remove alpha premultiply inconsistency 2026-03-31 06:02:15 +02:00
limbicnation e4c3e38aea fix: remove dead ternary fallbacks in batch validation, split h/w for readability 2026-03-29 08:25:39 +02:00
limbicnation fa7e9b7f20 fix: GrabCutRefinement mask unsqueeze, batch fallbacks, FFT div-by-zero, dead field removal
- Move mask.unsqueeze(0) outside else branch in GrabCutRefinement.refine_mask
  (same bug pattern fixed in AutoGrabCutRemover, line 841)
- Replace bare `continue` in batch validation loop with fallback tensor append
  to prevent torch.stack crash on empty list and bbox_metadata misalignment
- Derive exception-handler fallback h,w from input tensor instead of first
  processed item to avoid shape mismatch across batch items
- Guard FFT peak_ratio division against zero mean on uniform images
- Remove dead edge_threshold field from GrabCutParams (never passed from nodes)
- Log warning when Pydantic validation is unavailable instead of silent skip
2026-03-29 08:08:22 +02:00
limbicnation bfb7d072f6 chore: remove FLOYO_INTEGRATION_GUIDE.md
No longer needed — integration details tracked elsewhere.
2026-03-29 07:41:49 +02:00
limbicnation 58906fe894 fix: resolve remaining code review issues — mask batch safety, validation capture, import cleanup
- Move initial_mask unsqueeze guard outside non-batch branch to prevent
  silent data corruption when 2D mask meets 4D batched image
- Capture Pydantic validation return values and use normalised fields
  (scaling_method, iterations, margin, etc.) instead of discarding them
- Add .upper() to _RESAMPLING_MAP lookup for case-insensitive safety
- Simplify double-try sys.path.insert to single try with upfront path
- Add bicubic to ScalingParams description to match validator valid set
2026-03-29 07:39:23 +02:00
limbicnation 77b189a05a fix: resolve code review issues — BBOX_TENSOR type, validation params, cache safety, dead write removal
- RETURN_TYPES: "FLOAT" → "BBOX_TENSOR" for [B,6] metadata tensor (prevents scalar misinterpretation)
- Validation: remove hardcoded phantom params, pass actual scaling_method; fix field name to match Pydantic model
- YOLO cache: device-aware key ("model::device"), threading.Lock, CUDA-only torch.compile()
- Scaling validator: add "bicubic", case-insensitive normalization to match node uppercase values
- Remove dead rgba[:,:,3] write-back in GrabCutRefinement (only alpha used downstream)
- Add initial_mask.unsqueeze(0) for single-image 2D masks
- Remove unused Annotated import from validation.py
2026-03-29 07:13:02 +02:00
limbicnation b557c6729e feat: remaining H100 audit fixes — invert_mask, bbox_tensor [B,6], float edge_blur, tests/
Steps completed (per abstract-painting-kitten.md):
1. FIX edge_blur_amount float truncation: int→float in MaskParams + removed int() casts
2. Wire invert_mask: INPUT_TYPES, method signatures, Pydantic validation, alpha inversion
   applied in both AutoGrabCutRemover and GrabCutRefinement success paths
3. Add [B,6] bbox_metadata tensor output to AutoGrabCutRemover RETURN_TYPES
4. nodes.py: @torch.no_grad() on remove_background + batch_remove_background;
   all .float()→.to(dtype=torch.float32)
5. Structured tests/ suite: conftest.py, test_grabcut_processor.py,
   test_grabcut_nodes.py, test_nodes.py, test_validation.py

Verification:
- 48/48 new tests pass
- 6/6 original test_grabcut.py tests pass
- 4/4 node import test pass
- 0 flake8 E9/F63/F7/F82 errors
- edge_blur_amount=1.7 correctly stores as float (not truncated to 1)

BREAKING: AutoGrabCutRemover RETURN_TYPES changed from 5→6 (bbox_tensor added)
2026-03-29 06:53:33 +02:00
limbicnation 3094651eb8 feat: GrabCut H100 optimization — torch.no_grad, Pydantic validation, structlog, type hints
- grabcut_nodes.py: torch.no_grad() on remove_background + refine_mask,
  dtype=torch.float32 on all tensor conversions, torch.cuda.empty_cache()
  in finally blocks, Pydantic validation at start of every execute()
- grabcut_remover.py: Full type-hinting on GrabCutProcessor (mypy-ready),
  structlog observability with GPU memory tracking (_log_gpu_memory),
  torch.no_grad() + empty_cache() on all inference paths
- requirements.txt: Pin torch>=2.1.0, Pillow>=10.4.0 (CVE fix),
  opencv>=4.10.0, structlog>=24.4.0, pydantic>=2.7.0
- pyproject.toml: python>=3.10 (from 3.8)
- src/validation.py: NEW — Pydantic models for all user-facing params
  (GrabCutParams, ScalingParams, MaskParams, BBoxParams, GrabCutNodeParams)
- src/__init__.py: NEW — package marker
- 6/6 pytest tests pass, node import test passes

Ref: CD-14 | notion:32c40bf6-db23-8001-92b8-dfe4d91dccb4
2026-03-29 06:14:15 +02:00
limbicnation e582d1d22d Add Floyo H100 Integration Guide — GrabCut Easter Sprint
Covers:
- Environment audit (architecture, dependency stack, issues)
- Feature gap analysis vs H100 cloud-native pipeline
- 2026 refactoring standards (torch.no_grad, YOLO cache, type hints)
- pytest suite design (test_h100_pipeline, test_depth_estimation_chain)
- Pipeline integration (GrabCut → DepthEstimation → LTX-Video)
- Troubleshooting (VRAM debugging, error codes, thresholding reference)
2026-03-29 03:46:57 +02:00
Gero Doll e28b7128ec Merge pull request #11 from Limbicnation/fix/sklearn-dependency-handling
fix: add graceful sklearn dependency handling and installation scripts
2025-11-14 05:36:36 +01:00
geroandClaude a0982d1221 docs: enable GrabCut nodes with ultralytics dependency
- GrabCut nodes now functional after installing ultralytics
- Cleaned up temporary sklearn fix verification scripts
- Removed development-specific sync scripts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-14 05:28:05 +01:00
gero e95a71a900 fix: make GrabCut nodes optional to prevent blocking main nodes
When GrabCut nodes fail to import (e.g., missing ultralytics dependency),
the entire custom node package was failing to load. This meant users couldn't
access the main TransparencyBackgroundRemover nodes at all.

Changes:
- Wrap grabcut_nodes import in try-except block
- Provide clear error message when GrabCut nodes are disabled
- Allow main TransparencyBackgroundRemover nodes to load independently
- Add GRABCUT_AVAILABLE flag for runtime checks

Behavior:
- Main nodes always available (TransparencyBackgroundRemover, TransparencyBackgroundRemoverBatch)
- GrabCut nodes optional (only load if dependencies available)
- Clear messaging about what's enabled/disabled and how to fix
2025-11-14 05:03:57 +01:00
gero 8c9d10009c fix: add graceful sklearn dependency handling and installation scripts
Resolves ModuleNotFoundError when scikit-learn is not installed in the
ComfyUI Python environment. The node now uses lazy loading with graceful
degradation, allowing it to function without sklearn while maintaining
full functionality when available.

Changes:
- Remove unused sklearn import from nodes.py
- Implement lazy loading in background_remover.py with SKLEARN_AVAILABLE flag
- Add graceful fallback in color clustering detection
- Display helpful warning messages on startup when sklearn unavailable
- Create cross-platform installation scripts (install.bat, install.sh, install.py)
- Update README with dependency installation instructions and troubleshooting

Behavior:
- With sklearn: Full functionality (100% accuracy, all 4 detection methods)
- Without sklearn: Degraded mode (~85-90% accuracy, 3 of 4 detection methods)
- Clear warnings guide users to install dependencies for best results

Installation scripts support:
- Windows ComfyUI App (portable and standalone)
- Linux/Mac environments
- Manual pip installation
2025-11-14 04:35:18 +01:00
Gero Doll 005d136ad9 Merge pull request #10 from Limbicnation/fix/grabcut-refinement-issues
fix(grabcut): resolve bbox cropping and edge blur artifacts
2025-09-04 06:20:18 +02:00
limbicnation 1acd3f04bf Add Qwen GrabCut background removal workflows with edge blur support 2025-09-04 05:34:05 +02:00
limbicnation aed1245f01 Added the two crabcut images to the README file 2025-09-04 05:29:01 +02:00
limbicnation 92f17dcb3e fix(grabcut): resolve bbox validation and edge blur issues
- Fix bounding box validation logic to properly enforce min_bbox_size
  - Improve test coverage with synthetic small object scenarios
  - Extract magic numbers to named constants for maintainability
  - Remove duplicate blur code and optimize edge processing
2025-09-04 05:23:00 +02:00
limbicnation 3b18671182 fix(grabcut): resolve bbox cropping and edge blur artifacts
- Fix axis ordering in mask-based bbox extraction (y,x → x,y)
  - Add bbox validation with safety margins and minimum size constraints
  - Fix edge blur kernel size calculation (ensure odd numbers)
  - Reorder refinement pipeline (blur before threshold) to prevent artifacts
  - Add configurable bbox_safety_margin, min_bbox_size, fallback_margin_percent parameters
  - Enhance both AutoGrabCutRemover and GrabCutRefinement nodes
2025-09-04 04:40:59 +02:00
Gero Doll a21a8f5e7a Merge pull request #9 from Limbicnation/feature/grabcut-edge-blur
feat: add edge blur parameter to GrabCut nodes for softer mask transi…
2025-09-04 03:36:19 +02:00
limbicnation e3af1b63f6 feat(grabcut): increase edge_blur_amount max to 10.0
- Update AutoGrabCutRemover max from 5.0 to 10.0 for consistency with GrabCutRefinement
  - Update parameter tooltips and documentation to reflect new maximum
  - Expand usage examples and troubleshooting guidance for higher blur values
  - Technical implementation safely handles up to 10.0 via kernel size clamping
2025-09-04 02:25:29 +02:00
limbicnation fcf36afefc fix(grabcut): reorder AutoGrabCutRemover parameters to fix ComfyUI validation
Technical changes:
  - Move initial_mask parameter from position 11 to position 2 in remove_background() method signature
  - Resolves parameter misalignment causing validation errors where values were shifted by one position
  - Follows ComfyUI parameter ordering convention where optional parameters are passed in specific sequence

  Issue resolved:
  - Fixed scaling_method: 'True' validation error (boolean passed to scaling method)
  - Fixed binary_threshold: '2048x2048' validation error (size string passed to integer field)
  - Fixed output_size: 'BILINEAR' validation error (scaling method passed to size field)
  - Fixed custom_height: 'PHOTOGRAPHIC' validation error (edge mode passed to integer field)
  - Fixed output_format: '512' validation error (number passed to format field)

  This fix ensures parameters map correctly to their intended variables in the AutoGrabCutRemover node.
2025-09-04 01:52:42 +02:00
limbicnation 806430d15a fix(grabcut): resolve edge blur logic issues and optimize Gaussian blur
- Fix auto-adjustment logic bug where noisy images with sharp edges incorrectly received blur reduction instead of increase
  - Simplify edge blur processing pipeline by eliminating redundant conversions and restructuring if/else logic
  - Optimize Gaussian blur implementation: fix unreachable kernel size limit (31→21) and use OpenCV auto-sigma calculation
2025-09-04 00:56:12 +02:00
limbicnation 9105473ddd test: add comprehensive edge blur functionality tests for GrabCut nodes
- Add test_edge_blur_functionality() to validate edge blur parameter behavior
  - Test multiple blur amounts (0.0, 1.0, 2.5, 5.0) with soft/binary edge validation
  - Test both AutoGrabCutRemover and GrabCutRefinement nodes with edge blur
  - Verify auto-adjustment integration with edge blur parameters
  - Add edge blur test to main test suite execution
2025-09-03 20:24:30 +02:00
limbicnation c520e5f0b8 feat: add edge blur parameter to GrabCut nodes for softer mask transitions
- Add edge_blur_amount parameter (0.0-5.0) to GrabCutProcessor
  - Implement _apply_edge_blur() method using cv2.GaussianBlur with dynamic kernel sizing
  - Update AutoGrabCutRemover and GrabCutRefinement nodes with edge blur UI controls
  - Integrate blur into processing pipeline between edge refinement and binary thresholding
  - Preserve soft edges when blur > 0, maintain binary edges when blur = 0
  - Add intelligent auto-parameter adjustment for edge blur based on image characteristics
  - Add comprehensive test coverage for edge blur functionality with multiple blur amounts
  - Maintain full backward compatibility with existing edge refinement system
2025-09-03 20:05:23 +02:00
Gero Doll 90ee0aefee Merge pull request #8 from Limbicnation/feature/auto-adjust-grabcut-parameters
Feature/auto adjust grabcut parameters
2025-08-30 21:06:07 +02:00
Gero DollandCopilot 95451e1744 Update test_power_of_8_scaling.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-08-30 20:42:21 +02:00
limbicnation 6f1e2b085c chore: clean up repository for registry publication
- Remove development documentation files (6)
  - Remove redundant test files (4)
  - Remove old archive file (node.zip)
  - Remove excessive GitHub workflows (4 gemini-*.yml)
  - Keep essential workflows (comfy-ci.yml, publish.yml)
  - Preserve core functionality and essential tests
  - Reduce repository size for end users
2025-08-30 19:54:16 +02:00
limbicnation f2fe8cc00a refactor(grabcut): extract magic numbers and fix aspect ratio 2025-08-30 19:46:32 +02:00
limbicnation 258dc14298 Updated README with example grabcut images 2025-08-30 09:00:47 +02:00
limbicnation d9562c0d4d feat: Add edge_detection_mode parameter to Auto GrabCut Remover node
- Add edge_detection_mode parameter with AUTO/PIXEL_ART/PHOTOGRAPHIC options
  - Implement _detect_pixel_art_characteristics() method in GrabCutProcessor
  - Add intelligent parameter optimization based on content type detection
  - PIXEL_ART mode: reduced edge refinement, higher binary threshold, minimal margin
  - PHOTOGRAPHIC mode: increased edge refinement, lower binary threshold, expanded margin
  - AUTO mode: analyzes image characteristics to apply optimal settings
  - Enhances background removal quality for different image types
2025-08-30 08:43:43 +02:00
limbicnation a17fba846c Add auto_adjust parameter to Auto GrabCut Background Remover
Implements intelligent parameter adjustment based on image content analysis
  for the AutoGrabCutRemover node, enabling automatic optimization of processing
  parameters to improve background removal quality across diverse image types.

  Features:
  - New auto_adjust boolean parameter (default: false for backward compatibility)
  - Comprehensive image analysis (edge density, contrast, brightness, noise level)
  - Intelligent adjustment of 5 core parameters:
    * confidence_threshold (0.3-0.8 range)
    * iterations (3-8 range)
    * margin_pixels (10-35 range)
    * edge_refinement_strength (0.4-0.9 range)
    * binary_threshold (150-240 range)
2025-08-30 08:11:03 +02:00
limbicnation ee9346d4a1 Improve code quality and documentation in ScalingMixin
- Add PIXEL_TOLERANCE constant to replace magic number in dimension matching
  - Enhance calculate_scaling_factor docstring with detailed aspect ratio behavior
  - Add example demonstrating scaling factor selection logic
  - Verify RGB extraction logic is correctly ordered after resize operations
  - Maintain all existing functionality while improving code clarity
2025-08-30 04:07:28 +02:00
limbicnation dddd83919d Refactor GrabCut nodes to eliminate code duplication
- Create ScalingMixin class to centralize shared scaling functionality
  - Move parse_output_size, calculate_scaling_factor, and intelligent_scale methods to mixin
  - Add _apply_resize helper method to consolidate resize logic blocks
  - Define _RESAMPLING_MAP as class attribute to improve performance
  - Update AutoGrabCutRemover and GrabCutRefinement to inherit from ScalingMixin
  - Remove ~200 lines of duplicated code while preserving functionality
  - Improve maintainability by centralizing scaling logic in single location
2025-08-30 03:45:43 +02:00
limbicnation 3976a0e14c feat(grabcut): add resize functionality with multiple scaling methods
- Added output_size parameter with options: ORIGINAL, 512x512, 1024x1024, 2048x2048, custom
   - Added scaling_method parameter with NEAREST, BILINEAR, BICUBIC, LANCZOS options
   - Implemented custom width/height inputs for custom output size
   - Added intelligent scaling logic that maintains aspect ratio
   - Updated both AutoGrabCutRemover and GrabCutRefinement nodes
   - Maintained backward compatibility with existing workflows
2025-08-30 03:18:50 +02:00
Gero Doll cc023913e3 Merge pull request #6 from Limbicnation/fix/grabcut-tensor-format-compatibility
Fix/grabcut tensor format compatibility
2025-08-21 22:18:12 +02:00