From dc195264eb440eec8d19a7fdcb457bd521471ece Mon Sep 17 00:00:00 2001 From: yolain Date: Wed, 10 Dec 2025 02:23:08 +0800 Subject: [PATCH] Fixed the `Unexpected floating ScalarType` issue that occurred when used with wanvideowrapper #6 --- README.md | 11 ++++++++++- README_CN.md | 11 ++++++++++- pyproject.toml | 2 +- sam3/model/decoder.py | 3 +-- sam3/model/sam3_tracking_predictor.py | 3 +-- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b6339c7..87881ac 100644 --- a/README.md +++ b/README.md @@ -255,8 +255,9 @@ Interactive visual editor for creating point and bounding box prompts on images/ ## Model Downloads -Download SAM3 model weights from the official repository: +Download SAM3 model weights from the repository: - [SAM3 Models](https://huggingface.co/facebook/sam3) +- [SAM3 FP16 Model](https://huggingface.co/yolain/sam3-safetensors/blob/main/sam3-fp16.safetensors) Place the downloaded models in: `ComfyUI/models/sam3/` @@ -291,6 +292,14 @@ Contributions are welcome! Please feel free to submit issues or pull requests. ## Changelog +### v1.0.4 + +- Fixed the `Unexpected floating ScalarType` error that occurred when used with wanvideowrapper. + +### v1.0.3 + +- Changed `sam3GetObjectMask` node's `obj_id` to object index ID for easier correspondence with index IDs in visualization + ### v1.0.2 - Added `easy framesEditor` node for interactive image/video frame annotation diff --git a/README_CN.md b/README_CN.md index 3c46bc2..16395bc 100644 --- a/README_CN.md +++ b/README_CN.md @@ -255,8 +255,9 @@ ## 模型下载 -从官方仓库下载 SAM3 模型权重: +从仓库下载 SAM3 模型权重: - [SAM3 模型](https://huggingface.co/facebook/sam3) +- [SAM3 FP16 模型](https://huggingface.co/yolain/sam3-safetensors/blob/main/sam3-fp16.safetensors) 将下载的模型放置在:`ComfyUI/models/sam3/` @@ -291,6 +292,14 @@ ## 更新日志 +### v1.0.4 + +- 修复和 `wanvideowrapper` 节点同时使用时存在 `Unexpected floating ScalarType` 报错的情况 + +### v1.0.3 + +- 将 `sam3GetObjectMask` 节点的 `obj_id` 重新定义为对象索引ID,方便与可视化中的对象索引ID对应 + ### v1.0.2 - 增加 `easy framesEditor` 节点以进行交互式图像/视频帧标注 diff --git a/pyproject.toml b/pyproject.toml index b3d91d4..6cdcfc1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui-easy-sam3" description = "A ComfyUI custom node package for segment anything 3" -version = "1.0.3" +version = "1.0.4" license = {file = "LICENSE"} dependencies = ["timm>=1.0.17", "ftfy==6.1.1", "regex", "iopath>=0.1.10", "einops>=0.6.0", "decord>=0.6.0", "pycocotools>=2.0.10", "numpy>=1.26", "tqdm", "typing_extensions"] diff --git a/sam3/model/decoder.py b/sam3/model/decoder.py index 7efa1df..0d96cac 100644 --- a/sam3/model/decoder.py +++ b/sam3/model/decoder.py @@ -71,8 +71,7 @@ class TransformerDecoderLayer(nn.Module): return tensor if pos is None else tensor + pos def forward_ffn(self, tgt): - with torch.amp.autocast(device_type="cuda", enabled=False): - tgt2 = self.linear2(self.dropout3(self.activation(self.linear1(tgt)))) + tgt2 = self.linear2(self.dropout3(self.activation(self.linear1(tgt)))) tgt = tgt + self.dropout4(tgt2) tgt = self.norm3(tgt) return tgt diff --git a/sam3/model/sam3_tracking_predictor.py b/sam3/model/sam3_tracking_predictor.py index db1f807..2e09bfe 100644 --- a/sam3/model/sam3_tracking_predictor.py +++ b/sam3/model/sam3_tracking_predictor.py @@ -46,8 +46,7 @@ class Sam3TrackerPredictor(Sam3TrackerBase): self.max_point_num_in_prompt_enc = max_point_num_in_prompt_enc self.non_overlap_masks_for_output = non_overlap_masks_for_output - self.bf16_context = torch.autocast(device_type="cuda", dtype=torch.bfloat16) - self.bf16_context.__enter__() # keep using for the entire model process + self.bf16_context = None self.iter_use_prev_mask_pred = True self.add_all_frames_to_correct_as_cond = True