見出し画像

Fixed segment-anything-2

以下のエラーに対する対策です。このノードは現状、漸次既存のjsonsに対して置き換えしつつあるFlorence-2主体で組んだ新型Face detailer(Parts Detailer)で使用しています。


# ComfyUI Error Report
## Error Details
- **Node ID:** 122
- **Node Type:** Sam2Segmentation
- **Exception Type:** AttributeError
- **Exception Message:** 'SAM2ImagePredictor' object has no attribute 'reset_state'

## Stack Trace
```
  File "D:\USERFILES\ComfyUI\ComfyUI\execution.py", line 496, in execute
    output_data, output_ui, has_subgraph, has_pending_tasks = await get_output_data(prompt_id, unique_id, obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb, hidden_inputs=hidden_inputs)
                                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "D:\USERFILES\ComfyUI\ComfyUI\execution.py", line 315, in get_output_data
    return_values = await _async_map_node_over_list(prompt_id, unique_id, obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb, hidden_inputs=hidden_inputs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "D:\USERFILES\ComfyUI\ComfyUI\execution.py", line 289, in _async_map_node_over_list
    await process_inputs(input_dict, i)

  File "D:\USERFILES\ComfyUI\ComfyUI\execution.py", line 277, in process_inputs
    result = f(**inputs)

  File "D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI-segment-anything-2\nodes.py", line 414, in segment
    model.reset_state(self.inference_state)
    ^^^^^^^^^^^^^^^^^

```
## System Information
- **ComfyUI Version:** 0.3.59
- **Arguments:** ComfyUI\main.py --use-sage-attention --output-directory D:\USERFILES\A1111\outputs\ComfyUI
- **OS:** nt
- **Python Version:** 3.13.6 (tags/v3.13.6:4e66535, Aug  6 2025, 14:36:00) [MSC v.1944 64 bit (AMD64)]
- **Embedded Python:** true
- **PyTorch Version:** 2.8.0+cu129
## Devices

- **Name:** cuda:0 NVIDIA GeForce RTX 5060 Ti : cudaMallocAsync
  - **Type:** cuda
  - **VRAM Total:** 17102864384
  - **VRAM Free:** 15802040320
  - **Torch VRAM Total:** 0
  - **Torch VRAM Free:** 0

## Logs
```
2025-09-23T19:05:03.669419 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\comfyui_instantid
2025-09-23T19:05:03.669463 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI-TiledDiffusion
2025-09-23T19:05:03.669506 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI-GGUF
2025-09-23T19:05:03.669550 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\LanPaint
2025-09-23T19:05:03.669592 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\comfyui-wd14-tagger
2025-09-23T19:05:03.669634 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\comfyui-inpaint-nodes
2025-09-23T19:05:03.669678 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\comfyui-various
2025-09-23T19:05:03.669719 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\comfyui-prompt-composer
2025-09-23T19:05:03.669766 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\cg-use-everywhere
2025-09-23T19:05:03.669812 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI-AutoCropFaces
2025-09-23T19:05:03.669860 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\comfyui-florence2
2025-09-23T19:05:03.669902 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI_IPAdapter_plus
2025-09-23T19:05:03.669945 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI-NAG
2025-09-23T19:05:03.669988 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\wavespeed
2025-09-23T19:05:03.670032 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyMath
2025-09-23T19:05:03.670076 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\comfyui_ultimatesdupscale
2025-09-23T19:05:03.670118 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\comfyui_essentials
2025-09-23T19:05:03.670161 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\comfyui-multigpu
2025-09-23T19:05:03.670204 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\comfyui-custom-scripts
2025-09-23T19:05:03.670246 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\efficiency-nodes-comfyui
2025-09-23T19:05:03.670289 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\comfyui_sunxAI_facetools
2025-09-23T19:05:03.670331 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\comfyui_patches_ll
2025-09-23T19:05:03.670374 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\comfyui-frame-interpolation
2025-09-23T19:05:03.670421 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\controlaltai-nodes
2025-09-23T19:05:03.670464 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI-IPAdapter-Flux
2025-09-23T19:05:03.670505 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI-KJNodes
2025-09-23T19:05:03.670549 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI-Impact-Pack
2025-09-23T19:05:03.670593 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\comfyui_faceanalysis
2025-09-23T19:05:03.670635 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\comfyui-jakeupgrade
2025-09-23T19:05:03.670677 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\universaltoolkit
2025-09-23T19:05:03.670720 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\rgthree-comfy
2025-09-23T19:05:03.670762 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI-segment-anything-2
2025-09-23T19:05:03.670805 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\comfyui-ic-light
2025-09-23T19:05:03.670847 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\facerestore_cf
2025-09-23T19:05:03.670889 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\comfyui_controlnet_aux
2025-09-23T19:05:03.670931 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI_Comfyroll_CustomNodes
2025-09-23T19:05:03.670973 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI-Inspire-Pack
2025-09-23T19:05:03.671015 -    0.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\comfyui-videohelpersuite
2025-09-23T19:05:03.671058 -    0.1 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI_LayerStyle_Advance
2025-09-23T19:05:03.671100 -    0.1 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\eden_comfy_pipelines
2025-09-23T19:05:03.671143 -    0.1 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\comfyui_pulid_flux_ll
2025-09-23T19:05:03.671185 -    0.1 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI-tbox
2025-09-23T19:05:03.671228 -    0.1 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI-S4Tool-Image
2025-09-23T19:05:03.671270 -    0.1 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\comfyui-reactor-node
2025-09-23T19:05:03.671312 -    0.1 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI-Impact-Subpack
2025-09-23T19:05:03.671354 -    0.1 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI_LayerStyle
2025-09-23T19:05:03.671395 -    0.1 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\wavespeed-comfyui
2025-09-23T19:05:03.671440 -    0.1 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\comfyui-tensorops
2025-09-23T19:05:03.671486 -    0.1 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\comfyui-supir
2025-09-23T19:05:03.671529 -    0.2 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI-Crystools
2025-09-23T19:05:03.671571 -    0.2 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI-Manager
2025-09-23T19:05:03.671613 -    0.2 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\LCM_Inpaint_Outpaint_Comfy
2025-09-23T19:05:03.671656 -    0.2 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\comfyui-ollama
2025-09-23T19:05:03.671696 -    0.3 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI-CCSR
2025-09-23T19:05:03.671737 -    0.4 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\comfyui-art-venture
2025-09-23T19:05:03.671780 -    0.4 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\RES4LYF
2025-09-23T19:05:03.671820 -    0.4 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI-Upscaler-Tensorrt
2025-09-23T19:05:03.671865 -    0.5 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI-Addoor
2025-09-23T19:05:03.671905 -    0.6 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\clipseg.py
2025-09-23T19:05:03.671949 -    0.9 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI-Image-Filters
2025-09-23T19:05:03.671990 -    1.0 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI-nunchaku
2025-09-23T19:05:03.672034 -    1.1 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\was-node-suite-comfyui
2025-09-23T19:05:03.672075 -    1.3 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\comfyui_custom_nodes_alekpet
2025-09-23T19:05:03.672116 -    1.4 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI-BiRefNet-ZHO
2025-09-23T19:05:03.672160 -    2.5 seconds: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI-Easy-Use
2025-09-23T19:05:03.672202 - 
2025-09-23T19:05:04.271938 - Context impl SQLiteImpl.
2025-09-23T19:05:04.272076 - Will assume non-transactional DDL.
2025-09-23T19:05:04.272841 - No target revision found.
2025-09-23T19:05:04.299492 - Starting server

2025-09-23T19:05:04.299961 - To see the GUI go to: http://127.0.0.1:8188
2025-09-23T19:05:05.788843 - FETCH ComfyRegistry Data: 10/982025-09-23T19:05:05.789100 - 
2025-09-23T19:05:09.339226 - FETCH ComfyRegistry Data: 15/982025-09-23T19:05:09.339325 - 
2025-09-23T19:05:10.155725 - got prompt
2025-09-23T19:05:12.423856 - long_hair, looking_at_viewer, smile, shirt, skirt, multiple_girls, brown_hair, black_hair, long_sleeves, 2girls, very_long_hair, brown_eyes, underwear, school_uniform, white_shirt, panties, pleated_skirt, socks, serafuku, indoors, sailor_collar, bra, neckerchief, cosplay, white_bra, holding_clothes, realistic, blue_neckerchief, unworn_panties, unworn_bra, clothes, asian2025-09-23T19:05:12.423949 - 
2025-09-23T19:05:12.985921 - Loads SAM model: D:\USERFILES\ComfyUI\ComfyUI\models\sams\sam_vit_b_01ec64.pth (device:Prefer GPU)
2025-09-23T19:05:13.129214 - Requested to load FluxClipModel_
2025-09-23T19:05:13.136685 - loaded completely 9.5367431640625e+25 9319.4814453125 True
2025-09-23T19:05:13.138416 - CLIP/text encoder model load device: cpu, offload device: cpu, current: cpu, dtype: torch.float16
2025-09-23T19:05:14.400383 - FETCH ComfyRegistry Data: 20/982025-09-23T19:05:14.400482 - 
2025-09-23T19:05:18.091220 - FETCH ComfyRegistry Data: 25/982025-09-23T19:05:18.091448 - 
2025-09-23T19:05:21.670396 - FETCH ComfyRegistry Data: 30/982025-09-23T19:05:21.670507 - 
2025-09-23T19:05:25.258403 - FETCH ComfyRegistry Data: 35/982025-09-23T19:05:25.258593 - 
2025-09-23T19:05:28.016556 - Using xformers attention in VAE
2025-09-23T19:05:28.017447 - Using xformers attention in VAE
2025-09-23T19:05:28.107015 - VAE load device: cuda:0, offload device: cpu, dtype: torch.bfloat16
2025-09-23T19:05:28.143226 - Florence2 using flash_attention_2 for attention2025-09-23T19:05:28.143440 - 
2025-09-23T19:05:28.156669 - `torch_dtype` is deprecated! Use `dtype` instead!
2025-09-23T19:05:29.510685 - FETCH ComfyRegistry Data: 40/982025-09-23T19:05:29.510849 - 
2025-09-23T19:05:32.884026 - </s><s><s>Two young japanese girls in school uniforms standing side by side in a clothing store, smiling at the camera. the girl on the left is wearing a navy blue sailor school uniform with a white blouse and a navy pleated skirt, paired with navy blue socks. her long brown hair cascades down her back, and she has a cheerful expression on her face. on the right of the image, the same girl stands behind her, wearing a similar navy blue school uniform. both girls have their arms around each other's shoulders, and they are standing in front of a display of lingerie in various colors and styles. the store appears to be well-lit with natural light coming from the shelves behind them, creating a warm and inviting atmosphere.</s>2025-09-23T19:05:32.884141 - 
2025-09-23T19:05:32.884359 - Offloading model...2025-09-23T19:05:32.884461 - 
2025-09-23T19:05:33.061238 - FETCH ComfyRegistry Data: 45/982025-09-23T19:05:33.061442 - 
2025-09-23T19:05:36.591467 - FETCH ComfyRegistry Data: 50/982025-09-23T19:05:36.591641 - 
2025-09-23T19:05:39.905422 - model_path: 2025-09-23T19:05:39.905662 -  2025-09-23T19:05:39.905837 - D:\USERFILES\ComfyUI\ComfyUI\models\sam2\sam2_hiera_base_plus.safetensors2025-09-23T19:05:39.905953 - 
2025-09-23T19:05:39.906149 - Using model config: D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI-segment-anything-2\sam2_configs\sam2_hiera_b+.yaml2025-09-23T19:05:39.906226 - 
2025-09-23T19:05:40.214497 - FETCH ComfyRegistry Data: 55/982025-09-23T19:05:40.214691 - 
2025-09-23T19:05:40.425170 - Failed to torch jit script transforms: Failed to get source for <function Enum._generate_next_value_ at 0x000001B287771F80> using inspect.getsource, falling back to normal transforms2025-09-23T19:05:40.425309 - 
2025-09-23T19:05:40.466353 - GPU 0 (NVIDIA GeForce RTX 5060 Ti) Memory: 16310.5625 MiB2025-09-23T19:05:40.466512 - 
2025-09-23T19:05:40.466598 - Enabling CPU offload2025-09-23T19:05:40.466655 - 
2025-09-23T19:05:40.973805 - Injecting quantized module2025-09-23T19:05:40.974035 - 
2025-09-23T19:05:41.019824 - model_type FLUX
2025-09-23T19:05:41.021612 - DEBUG: Using ComfyFluxWrapper from D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI-nunchaku.wrappers.flux2025-09-23T19:05:41.021749 - 
2025-09-23T19:05:41.021906 - DEBUG: Using ComfyFluxWrapper from wrappers.flux2025-09-23T19:05:41.021956 - 
2025-09-23T19:05:41.252314 - Requested to load AutoencodingEngine
2025-09-23T19:05:41.296886 - loaded completely 9051.117740631104 159.87335777282715 True
2025-09-23T19:05:41.505602 - [xformers] memory_efficient_attention: selected kernel = cutlassF-pt
2025-09-23T19:05:41.505748 - [xformers] memory_efficient_attention: selected kernel = cutlassF-pt2025-09-23T19:05:41.505826 - 
2025-09-23T19:05:44.060850 - FETCH ComfyRegistry Data: 60/982025-09-23T19:05:44.061212 - 
2025-09-23T19:05:47.782793 - FETCH ComfyRegistry Data: 65/982025-09-23T19:05:47.782998 - 
2025-09-23T19:05:57.103805 - Requested to load Flux
2025-09-23T19:05:57.103953 - Requested to load ControlNetFlux
2025-09-23T19:05:57.105347 - loaded completely 11387.303835983275 122.3087158203125 True
2025-09-23T19:05:57.417180 - loaded completely 11387.26568901062 2041.69921875 True
2025-09-23T19:05:57.418531 - Patching comfy attention to use sageattn2025-09-23T19:05:57.418645 - 
2025-09-23T19:05:57.420657 - 
  0%|                                                                                           | 0/16 [00:00<?, ?it/s]2025-09-23T19:05:59.616251 - DEBUG: Checking for PuLID weights before LoRA update...2025-09-23T19:05:59.616469 - 
2025-09-23T19:05:59.616605 - DEBUG: First block has pulid_ca: False2025-09-23T19:05:59.616668 - 
2025-09-23T19:05:59.616743 - DEBUG: Original block has pulid_ca: False2025-09-23T19:05:59.616794 - 
2025-09-23T19:05:59.621191 - 
2025-09-23T19:05:59.621401 - 
Converting LoRAs to nunchaku format:   0%|                                                      | 0/57 [00:00<?, ?it/s]2025-09-23T19:05:59.755252 - 
2025-09-23T19:05:59.755665 - 
Converting LoRAs to nunchaku format:   7%|███▏                                          | 4/57 [00:00<00:01, 29.92it/s]2025-09-23T19:05:59.880622 - 
2025-09-23T19:05:59.880971 - 
Converting LoRAs to nunchaku format:  14%|██████▍                                       | 8/57 [00:00<00:01, 31.06it/s]2025-09-23T19:06:00.019551 - 
2025-09-23T19:06:00.020003 - 
Converting LoRAs to nunchaku format:  21%|█████████▍                                   | 12/57 [00:00<00:01, 29.98it/s]2025-09-23T19:06:00.156254 - 
2025-09-23T19:06:00.156530 - 
Converting LoRAs to nunchaku format:  28%|████████████▋                                | 16/57 [00:00<00:01, 29.69it/s]2025-09-23T19:06:00.257901 - 
2025-09-23T19:06:00.258313 - 
Converting LoRAs to nunchaku format:  33%|███████████████                              | 19/57 [00:00<00:01, 29.64it/s]2025-09-23T19:06:00.358280 - 
2025-09-23T19:06:00.358577 - 
Converting LoRAs to nunchaku format:  39%|█████████████████▎                           | 22/57 [00:00<00:01, 29.71it/s]2025-09-23T19:06:00.489538 - 
2025-09-23T19:06:00.489872 - 
Converting LoRAs to nunchaku format:  46%|████████████████████▌                        | 26/57 [00:00<00:01, 29.98it/s]2025-09-23T19:06:00.621028 - 
2025-09-23T19:06:00.621384 - 
Converting LoRAs to nunchaku format:  53%|███████████████████████▋                     | 30/57 [00:00<00:00, 30.13it/s]2025-09-23T19:06:00.755631 - 
2025-09-23T19:06:00.755909 - 
Converting LoRAs to nunchaku format:  60%|██████████████████████████▊                  | 34/57 [00:01<00:00, 29.99it/s]2025-09-23T19:06:00.887838 - 
2025-09-23T19:06:00.888122 - 
Converting LoRAs to nunchaku format:  67%|██████████████████████████████               | 38/57 [00:01<00:00, 30.08it/s]2025-09-23T19:06:01.150983 - 
2025-09-23T19:06:01.151317 - 
Converting LoRAs to nunchaku format:  74%|█████████████████████████████████▏           | 42/57 [00:01<00:00, 23.03it/s]2025-09-23T19:06:01.349115 - 
2025-09-23T19:06:01.349409 - 
Converting LoRAs to nunchaku format:  79%|███████████████████████████████████▌         | 45/57 [00:01<00:00, 20.36it/s]2025-09-23T19:06:01.544079 - 
2025-09-23T19:06:01.544394 - 
Converting LoRAs to nunchaku format:  84%|█████████████████████████████████████▉       | 48/57 [00:01<00:00, 18.76it/s]2025-09-23T19:06:01.743856 - 
2025-09-23T19:06:01.744208 - 
Converting LoRAs to nunchaku format:  89%|████████████████████████████████████████▎    | 51/57 [00:02<00:00, 17.56it/s]2025-09-23T19:06:01.876351 - 
2025-09-23T19:06:01.876770 - 
Converting LoRAs to nunchaku format:  93%|█████████████████████████████████████████▊   | 53/57 [00:02<00:00, 16.99it/s]2025-09-23T19:06:02.014678 - 
2025-09-23T19:06:02.015007 - 
Converting LoRAs to nunchaku format:  96%|███████████████████████████████████████████▍ | 55/57 [00:02<00:00, 16.34it/s]2025-09-23T19:06:02.149117 - 
2025-09-23T19:06:02.149765 - 
Converting LoRAs to nunchaku format: 100%|█████████████████████████████████████████████| 57/57 [00:02<00:00, 22.55it/s]2025-09-23T19:06:02.149854 - 
2025-09-23T19:06:02.384870 - DEBUG: Attempting to restore 0 PuLID weights...2025-09-23T19:06:02.385011 - 
2025-09-23T19:06:02.385127 - DEBUG: No PuLID weights to restore2025-09-23T19:06:02.385196 - 
2025-09-23T19:06:17.650020 - 
100%|██████████████████████████████████████████████████████████████████████████████████| 16/16 [00:20<00:00,  1.26s/it]2025-09-23T19:06:17.650180 - 
2025-09-23T19:06:17.650527 - Restoring initial comfy attention2025-09-23T19:06:17.650605 - 
2025-09-23T19:06:18.957378 - 
2025-09-23T19:06:19.051400 - 0: 512x640 2 faces, 25.8ms
2025-09-23T19:06:19.051663 - Speed: 2.9ms preprocess, 25.8ms inference, 8.6ms postprocess per image at shape (1, 3, 512, 640)
2025-09-23T19:06:19.480518 - Detailer: segment upscale for ((np.float32(101.3978), np.float32(130.71564))) | crop region (304, 392) x 2.6122963428497314 -> (794, 1024)
2025-09-23T19:06:19.504790 - Requested to load AutoencodingEngine
2025-09-23T19:06:19.546924 - loaded completely 8523.120113372803 159.87335777282715 True
2025-09-23T19:06:19.756847 - [Impact Pack] vae encoded in 0.3s
2025-09-23T19:06:19.764014 - Requested to load Flux
2025-09-23T19:06:19.765395 - loaded completely 10275.373415756225 122.3087158203125 True
2025-09-23T19:06:19.766060 - Patching comfy attention to use sageattn2025-09-23T19:06:19.766188 - 
2025-09-23T19:06:20.286585 - 
  6%|█████▏                                                                             | 1/16 [00:00<00:07,  1.93it/s]2025-09-23T19:06:20.822463 - Cannot connect to comfyregistry.2025-09-23T19:06:20.822597 - 
2025-09-23T19:06:23.885218 - 
 50%|█████████████████████████████████████████▌                                         | 8/16 [00:04<00:04,  1.99it/s]2025-09-23T19:06:25.756618 - 
 75%|█████████████████████████████████████████████████████████████▌                    | 12/16 [00:05<00:01,  2.11it/s]2025-09-23T19:06:25.769527 -  [DONE]2025-09-23T19:06:25.769717 - 
2025-09-23T19:06:26.288893 - [ComfyUI-Manager] All startup tasks have been completed.
2025-09-23T19:06:27.690950 - 
100%|██████████████████████████████████████████████████████████████████████████████████| 16/16 [00:07<00:00,  2.02it/s]2025-09-23T19:06:27.691102 - 
2025-09-23T19:06:27.691403 - Restoring initial comfy attention2025-09-23T19:06:27.691464 - 
2025-09-23T19:06:28.017160 - [Impact Pack] vae decoded in 0.3s
2025-09-23T19:06:28.048698 - Detailer: segment upscale for ((np.float32(120.020935), np.float32(145.23988))) | crop region (360, 435) x 2.3544580936431885 -> (847, 1024)
2025-09-23T19:06:28.286809 - [Impact Pack] vae encoded in 0.2s
2025-09-23T19:06:28.290796 - Patching comfy attention to use sageattn2025-09-23T19:06:28.290883 - 
2025-09-23T19:06:36.308770 - 
100%|██████████████████████████████████████████████████████████████████████████████████| 16/16 [00:08<00:00,  2.00it/s]2025-09-23T19:06:36.308844 - 
2025-09-23T19:06:36.309167 - Restoring initial comfy attention2025-09-23T19:06:36.309232 - 
2025-09-23T19:06:36.647850 - [Impact Pack] vae decoded in 0.3s
2025-09-23T19:06:37.494408 - </s><s><s><s>all eyes<loc_276><loc_86><loc_351><loc_136><loc_386><loc_96><loc_468><loc_128>eyes<loc_278><loc_89><loc_306><loc_116><loc_325><loc_113><loc_348><loc_135><loc_436><loc_105><loc_463><loc_126><loc_388><loc_99><loc_416><loc_120></s>2025-09-23T19:06:37.494503 - 
2025-09-23T19:06:37.504681 - match index:2025-09-23T19:06:37.504769 -  2025-09-23T19:06:37.504822 - 02025-09-23T19:06:37.504865 -  2025-09-23T19:06:37.504907 - in mask_indexes:2025-09-23T19:06:37.504947 -  2025-09-23T19:06:37.504990 - ['0', '1', '2', '3', '4', '5']2025-09-23T19:06:37.505032 - 
2025-09-23T19:06:37.505795 - match index:2025-09-23T19:06:37.505850 -  2025-09-23T19:06:37.505892 - 12025-09-23T19:06:37.505929 -  2025-09-23T19:06:37.505965 - in mask_indexes:2025-09-23T19:06:37.506001 -  2025-09-23T19:06:37.506039 - ['0', '1', '2', '3', '4', '5']2025-09-23T19:06:37.506076 - 
2025-09-23T19:06:37.506566 - match index:2025-09-23T19:06:37.506627 -  2025-09-23T19:06:37.506669 - 22025-09-23T19:06:37.506706 -  2025-09-23T19:06:37.506741 - in mask_indexes:2025-09-23T19:06:37.506775 -  2025-09-23T19:06:37.506860 - ['0', '1', '2', '3', '4', '5']2025-09-23T19:06:37.506930 - 
2025-09-23T19:06:37.507425 - match index:2025-09-23T19:06:37.507477 -  2025-09-23T19:06:37.507518 - 32025-09-23T19:06:37.507556 -  2025-09-23T19:06:37.507593 - in mask_indexes:2025-09-23T19:06:37.507629 -  2025-09-23T19:06:37.507666 - ['0', '1', '2', '3', '4', '5']2025-09-23T19:06:37.507703 - 
2025-09-23T19:06:37.508148 - match index:2025-09-23T19:06:37.508198 -  2025-09-23T19:06:37.508237 - 42025-09-23T19:06:37.508359 -  2025-09-23T19:06:37.508420 - in mask_indexes:2025-09-23T19:06:37.508458 -  2025-09-23T19:06:37.508494 - ['0', '1', '2', '3', '4', '5']2025-09-23T19:06:37.508530 - 
2025-09-23T19:06:37.508988 - match index:2025-09-23T19:06:37.509037 -  2025-09-23T19:06:37.509077 - 52025-09-23T19:06:37.509113 -  2025-09-23T19:06:37.509149 - in mask_indexes:2025-09-23T19:06:37.509184 -  2025-09-23T19:06:37.509220 - ['0', '1', '2', '3', '4', '5']2025-09-23T19:06:37.509256 - 
2025-09-23T19:06:37.729846 - Offloading model...2025-09-23T19:06:37.729971 - 
2025-09-23T19:06:38.012440 - Indexes:2025-09-23T19:06:38.012622 -  2025-09-23T19:06:38.012859 - [0, 1, 2, 3, 4, 5]2025-09-23T19:06:38.012986 - 
2025-09-23T19:06:38.013132 - Coordinates:2025-09-23T19:06:38.013290 -  2025-09-23T19:06:38.013384 - [{"x": 364, "y": 99}, {"x": 495, "y": 100}, {"x": 339, "y": 92}, {"x": 390, "y": 111}, {"x": 521, "y": 103}, {"x": 466, "y": 98}]2025-09-23T19:06:38.013472 - 
2025-09-23T19:06:38.015160 - combined labels: 2025-09-23T19:06:38.015242 -  2025-09-23T19:06:38.015436 - [1. 1. 1. 1. 1. 1.]2025-09-23T19:06:38.015506 - 
2025-09-23T19:06:38.015566 - combined labels shape: 2025-09-23T19:06:38.015618 -  2025-09-23T19:06:38.015670 - (6,)2025-09-23T19:06:38.015721 - 
2025-09-23T19:06:38.021817 - 
Processing Images:   0%|                                                                         | 0/1 [00:00<?, ?it/s]2025-09-23T19:06:38.174906 - !!! Exception during processing !!! 'SAM2ImagePredictor' object has no attribute 'reset_state'
2025-09-23T19:06:38.178290 - Traceback (most recent call last):
  File "D:\USERFILES\ComfyUI\ComfyUI\execution.py", line 496, in execute
    output_data, output_ui, has_subgraph, has_pending_tasks = await get_output_data(prompt_id, unique_id, obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb, hidden_inputs=hidden_inputs)
                                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\USERFILES\ComfyUI\ComfyUI\execution.py", line 315, in get_output_data
    return_values = await _async_map_node_over_list(prompt_id, unique_id, obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb, hidden_inputs=hidden_inputs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\USERFILES\ComfyUI\ComfyUI\execution.py", line 289, in _async_map_node_over_list
    await process_inputs(input_dict, i)
  File "D:\USERFILES\ComfyUI\ComfyUI\execution.py", line 277, in process_inputs
    result = f(**inputs)
  File "D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\ComfyUI-segment-anything-2\nodes.py", line 414, in segment
    model.reset_state(self.inference_state)
    ^^^^^^^^^^^^^^^^^
AttributeError: 'SAM2ImagePredictor' object has no attribute 'reset_state'

2025-09-23T19:06:38.181660 - Prompt executed in 88.01 seconds
2025-09-23T19:06:38.524783 - 
Processing Images: 100%|█████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.99it/s]
```
## Attached Workflow
Please make sure that workflow does not contain any sensitive information such as API keys or passwords.
```
Workflow too large. Please manually upload the workflow from local file system.
```

## Additional Context
(Please add any additional context or steps to reproduce the error here)

以下の原因からして、万人において発生しうる理屈ですが。

エラーの原因

`'SAM2ImagePredictor' object has no attribute 'reset_state'` エラーは、ComfyUIのカスタムノード「ComfyUI-segment-anything-2」で発生しています。このエラーの原因は以下の通りです:

  1. SAM2ImagePredictorクラスには`reset_state`メソッドが存在しない

    • 調査の結果、`SAM2ImagePredictor`クラスには`reset_state`メソッドが定義されていません

    • 代わりに`reset_predictor`メソッドが存在します(459行目)

  2. カスタムノードのコードが古いAPIを使用している

    • カスタムノードのコードが、SAM2ライブラリの古いAPIを参照している可能性があります

ComfyUI SAM2エラー修正記録

エラー概要

  • エラー: `'SAM2ImagePredictor' object has no attribute 'reset_state'`

  • 発生箇所: ComfyUI-segment-anything-2カスタムノード

  • 原因: SAM2ライブラリのAPI変更による互換性問題

根本原因

  • SAM2ライブラリが更新され、メソッド名が変更された

  • 古いAPI: `reset_state(inference_state)` → 新しいAPI: `reset_predictor()`

  • カスタムノードが古いAPIを使用していた

修正ファイル

ComfyUI/custom_nodes/ComfyUI-segment-anything-2/nodes.py

修正箇所

1. 414行目(Sam2Segmentationクラス)

# 修正前
model.reset_state(self.inference_state)

# 修正後
model.reset_predictor()

2. 351行目(Sam2Segmentationクラス)

# 修正前
if hasattr(self, 'inference_state'):
    model.reset_state(self.inference_state)

# 修正後
if hasattr(self, 'inference_state') and self.inference_state is not None:
    model.reset_predictor()

3. 510行目(Sam2VideoSegmentationAddPointsクラス)

# 修正前
if hasattr(self, 'inference_state'):
    model.reset_state(self.inference_state)

# 修正後
if hasattr(self, 'inference_state'):
    model.reset_predictor()

4. 569行目(Sam2VideoSegmentationクラス)

# 修正前(コメントアウト部分)
#    model.reset_state(self.inference_state)

# 修正後
#    model.reset_predictor()

修正内容

  • `reset_state(inference_state)` → `reset_predictor()`

  • 引数を削除(新しいAPIでは不要)

  • 条件分岐の改善

結果

  • ✅ エラー完全解決

  • ✅ Sam2Segmentationノード正常動作

  • ✅ 後方互換性保持

学んだこと

  • ComfyUIエコシステムでは依存関係の変更が頻繁

  • カスタムノードの更新が追いつかない場合がある

  • コメントアウト部分も見落とさないことが重要

  • 系統的な修正アプローチが効果的


修正日: 2025-09-23
対象: ComfyUI 0.3.59 + ComfyUI-segment-anything-2

いいなと思ったら応援しよう!