155.Min Stack(Stack-Easy)

本文介绍了一种使用两个栈实现的高效数据结构,该结构能够支持push、pop、top及获取最小值等操作,并能在常数时间内完成这些操作。通过维护一个辅助栈来跟踪最小值,确保了操作效率。

转载请注明作者和出处:http://blog.csdn.net/c406495762

    Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.

  • push(x) – Push element x onto stack.

  • pop() – Removes the element on top of the stack.

  • top() – Get the top element.

  • getMin() – Retrieve the minimum element in the stack.

Example:

MinStack minStack = new MinStack();
minStack.push(-2);
minStack.push(0);
minStack.push(-3);
minStack.getMin(); –> Returns -3.
minStack.pop();
minStack.top(); –> Returns 0.
minStack.getMin(); –> Returns -2.

题目: 设计一个支持push、pop、top和能返回最小值stack中最小值的stack

思路: 创建两个stack,一个保存所有元素,一个负责保存最小元素。保存最小元素的top元素即为所有元素的最小元素。看代码,很容易理解。

Language : cpp

class MinStack {
public:
    /** initialize your data structure here. */
    stack<int> all_stk;
    stack<int> min_stk;

    void push(int x) {
        all_stk.push(x);
        if(min_stk.empty() || min_stk.top() >= x){
            min_stk.push(x);
        }
    }
    void pop() {
        if(all_stk.top() == min_stk.top()){
            min_stk.pop();
        }
        all_stk.pop();
    }

    int top() {
        if(all_stk.empty()){
            return 0;
        }
        else{
            return all_stk.top();
        }
    }

    int getMin() {
        if(min_stk.empty()){
            return 0;
        }
        else{
            return min_stk.top();
        }
    }
};

/**
 * Your MinStack object will be instantiated and called as such:
 * MinStack obj = new MinStack();
 * obj.push(x);
 * obj.pop();
 * int param_3 = obj.top();
 * int param_4 = obj.getMin();
 */
# ComfyUI Error Report ## Error Details - **Node ID:** 90 - **Node Type:** WanVideoSampler - **Exception Type:** UnboundLocalError - **Exception Message:** cannot access local variable 'callback_latent' where it is not associated with a value ## Stack Trace ``` File "G:\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 "G:\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 "G:\comfyui\ComfyUI\execution.py", line 289, in _async_map_node_over_list await process_inputs(input_dict, i) File "G:\comfyui\ComfyUI\execution.py", line 277, in process_inputs result = f(**inputs) ^^^^^^^^^^^ File "G:\comfyui\ComfyUI\custom_nodes\ComfyUI-WanVideoWrapper\nodes.py", line 3988, in process "samples": callback_latent.unsqueeze(0).cpu() if callback is not None else None, ^^^^^^^^^^^^^^^ ``` ## System Information - **ComfyUI Version:** 0.3.56 - **Arguments:** main.py --auto-launch - **OS:** nt - **Python Version:** 3.12.10 (tags/v3.12.10:0cc8128, Apr 8 2025, 12:21:36) [MSC v.1943 64 bit (AMD64)] - **Embedded Python:** false - **PyTorch Version:** 2.7.1+cu128 ## Devices - **Name:** cuda:0 NVIDIA GeForce RTX 4070 Ti SUPER : cudaMallocAsync - **Type:** cuda - **VRAM Total:** 17170956288 - **VRAM Free:** 15821963264 - **Torch VRAM Total:** 0 - **Torch VRAM Free:** 0 ## Logs ``` 2025-09-01T14:58:56.860057 - 0.9 seconds: G:\comfyui\ComfyUI\custom_nodes\comfyui-mixlab-nodes 2025-09-01T14:58:56.860057 - 1.1 seconds: G:\comfyui\ComfyUI\custom_nodes\ComfyUI_Custom_Nodes_AlekPet 2025-09-01T14:58:56.861054 - 1.7 seconds: G:\comfyui\ComfyUI\custom_nodes\ComfyUI-nunchaku 2025-09-01T14:58:56.861054 - 2.4 seconds: G:\comfyui\ComfyUI\custom_nodes\ComfyUI-Easy-Use 2025-09-01T14:58:56.861054 - 2025-09-01T14:58:57.088527 - Context impl SQLiteImpl. 2025-09-01T14:58:57.088527 - Will assume non-transactional DDL. 2025-09-01T14:58:57.089524 - No target revision found. 2025-09-01T14:58:57.111451 - Starting server 2025-09-01T14:58:57.112447 - To see the GUI go to: http://127.0.0.1:8188 2025-09-01T14:58:58.110145 - G:\comfyui\ComfyUI\custom_nodes\comfyui-mixlab-nodes\webApp\lib/photoswipe-lightbox.esm.min.js2025-09-01T14:58:58.110145 - 2025-09-01T14:58:58.154639 - G:\comfyui\ComfyUI\custom_nodes\comfyui-mixlab-nodes\webApp\lib/photoswipe.min.css2025-09-01T14:58:58.154639 - 2025-09-01T14:58:58.155636 - G:\comfyui\ComfyUI\custom_nodes\comfyui-mixlab-nodes\webApp\lib/pickr.min.js2025-09-01T14:58:58.155636 - 2025-09-01T14:58:58.192513 - G:\comfyui\ComfyUI\custom_nodes\comfyui-mixlab-nodes\webApp\lib/classic.min.css2025-09-01T14:58:58.192513 - 2025-09-01T14:58:58.193509 - G:\comfyui\ComfyUI\custom_nodes\comfyui-mixlab-nodes\webApp\lib/model-viewer.min.js2025-09-01T14:58:58.193509 - 2025-09-01T14:58:58.197497 - G:\comfyui\ComfyUI\custom_nodes\comfyui-mixlab-nodes\webApp\lib/juxtapose.css2025-09-01T14:58:58.198493 - 2025-09-01T14:58:58.209456 - G:\comfyui\ComfyUI\custom_nodes\comfyui-mixlab-nodes\webApp\lib/juxtapose.min.js2025-09-01T14:58:58.209456 - 2025-09-01T14:58:58.799579 - [G:\comfyui\ComfyUI\custom_nodes\comfy_mtb] | INFO -> Found multiple match, we will pick the last D:\AI-sd\sd-webui-aki-v4\models\SwinIR ['G:\\comfyui\\ComfyUI\\models\\upscale_models', 'D:\\AI-sd\\sd-webui-aki-v4\\models\\ESRGAN', 'D:\\AI-sd\\sd-webui-aki-v4\\models\\RealESRGAN', 'D:\\AI-sd\\sd-webui-aki-v4\\models\\SwinIR'] 2025-09-01T14:58:58.807556 - []2025-09-01T14:58:58.807556 - 2025-09-01T14:58:58.807556 - []2025-09-01T14:58:58.807556 - 2025-09-01T14:59:00.532965 - got prompt 2025-09-01T14:59:00.569842 - Using xformers attention in VAE 2025-09-01T14:59:00.570844 - Using xformers attention in VAE 2025-09-01T14:59:00.726582 - VAE load device: cuda:0, offload device: cpu, dtype: torch.bfloat16 2025-09-01T14:59:00.882662 - Requested to load FluxClipModel_ 2025-09-01T14:59:00.889639 - loaded completely 9.5367431640625e+25 4777.53759765625 True 2025-09-01T14:59:00.998583 - CLIP/text encoder model load device: cuda:0, offload device: cpu, current: cuda:0, dtype: torch.float16 2025-09-01T14:59:01.063367 - clip missing: ['text_projection.weight'] 2025-09-01T14:59:01.722971 - FETCH ComfyRegistry Data: 5/962025-09-01T14:59:01.722971 - 2025-09-01T14:59:03.042519 - model weight dtype torch.float8_e4m3fn, manual cast: torch.bfloat16 2025-09-01T14:59:03.043516 - model_type FLUX 2025-09-01T14:59:11.471386 - FETCH ComfyRegistry Data: 10/962025-09-01T14:59:11.473376 - 2025-09-01T14:59:11.998346 - Requested to load Flux 2025-09-01T14:59:18.503848 - loaded completely 0.0 11350.067443847656 True 2025-09-01T14:59:18.514805 - Patching comfy attention to use sageattn2025-09-01T14:59:18.514805 - 2025-09-01T14:59:18.688225 - 0%| | 0/20 [00:00<?, ?it/s]2025-09-01T14:59:20.150041 - FETCH ComfyRegistry Data: 15/962025-09-01T14:59:20.150041 - 2025-09-01T14:59:28.628200 - 40%|█████████████████████████████████▏ | 8/20 [00:09<00:14, 1.17s/it]2025-09-01T14:59:29.656666 - FETCH ComfyRegistry Data: 20/962025-09-01T14:59:29.657170 - 2025-09-01T14:59:37.969589 - 80%|█████████████████████████████████████████████████████████████████▌ | 16/20 [00:19<00:04, 1.16s/it]2025-09-01T14:59:38.276116 - FETCH ComfyRegistry Data: 25/962025-09-01T14:59:38.276619 - 2025-09-01T14:59:42.606388 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:23<00:00, 1.16s/it]2025-09-01T14:59:42.609378 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:23<00:00, 1.20s/it]2025-09-01T14:59:42.610375 - 2025-09-01T14:59:42.612369 - Restoring initial comfy attention2025-09-01T14:59:42.613364 - 2025-09-01T14:59:43.566091 - Requested to load AutoencodingEngine 2025-09-01T14:59:44.164328 - loaded completely 0.0 159.87335777282715 True 2025-09-01T14:59:44.683600 - comfyui lumi batcher overwrite task done2025-09-01T14:59:44.684596 - 2025-09-01T14:59:44.695560 - Prompt executed in 44.16 seconds 2025-09-01T14:59:47.355547 - FETCH ComfyRegistry Data: 30/962025-09-01T14:59:47.355547 - 2025-09-01T14:59:50.013416 - got prompt 2025-09-01T14:59:50.431031 - loaded completely 0.0 11350.067443847656 True 2025-09-01T14:59:50.435018 - Patching comfy attention to use sageattn2025-09-01T14:59:50.435018 - 2025-09-01T14:59:55.538670 - 25%|████████████████████▊ | 5/20 [00:05<00:16, 1.11s/it]2025-09-01T14:59:56.060186 - FETCH ComfyRegistry Data: 35/962025-09-01T14:59:56.060689 - 2025-09-01T15:00:03.927199 - 60%|█████████████████████████████████████████████████▏ | 12/20 [00:13<00:09, 1.19s/it]2025-09-01T15:00:04.665127 - FETCH ComfyRegistry Data: 40/962025-09-01T15:00:04.666123 - 2025-09-01T15:00:13.251827 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:22<00:00, 1.14s/it]2025-09-01T15:00:13.252823 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:22<00:00, 1.14s/it]2025-09-01T15:00:13.252823 - 2025-09-01T15:00:13.253821 - Restoring initial comfy attention2025-09-01T15:00:13.253821 - 2025-09-01T15:00:13.397095 - FETCH ComfyRegistry Data: 45/962025-09-01T15:00:13.397604 - 2025-09-01T15:00:14.837381 - loaded completely 0.0 159.87335777282715 True 2025-09-01T15:00:15.176809 - comfyui lumi batcher overwrite task done2025-09-01T15:00:15.177805 - 2025-09-01T15:00:15.179799 - Prompt executed in 25.16 seconds 2025-09-01T15:00:22.087367 - FETCH ComfyRegistry Data: 50/962025-09-01T15:00:22.088368 - 2025-09-01T15:00:26.342724 - got prompt 2025-09-01T15:00:27.137497 - loaded completely 0.0 11350.067443847656 True 2025-09-01T15:00:27.148464 - Patching comfy attention to use sageattn2025-09-01T15:00:27.148464 - 2025-09-01T15:00:29.963897 - 15%|████████████▍ | 3/20 [00:02<00:17, 1.03s/it]2025-09-01T15:00:30.838878 - FETCH ComfyRegistry Data: 55/962025-09-01T15:00:30.839380 - 2025-09-01T15:00:39.316242 - 55%|█████████████████████████████████████████████ | 11/20 [00:12<00:10, 1.17s/it]2025-09-01T15:00:39.731658 - FETCH ComfyRegistry Data: 60/962025-09-01T15:00:39.737147 - 2025-09-01T15:00:47.708181 - 90%|█████████████████████████████████████████████████████████████████████████▊ | 18/20 [00:20<00:02, 1.20s/it]2025-09-01T15:00:48.592029 - FETCH ComfyRegistry Data: 65/962025-09-01T15:00:48.592029 - 2025-09-01T15:00:50.028377 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:22<00:00, 1.18s/it]2025-09-01T15:00:50.029376 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:22<00:00, 1.14s/it]2025-09-01T15:00:50.029376 - 2025-09-01T15:00:50.030370 - Restoring initial comfy attention2025-09-01T15:00:50.030370 - 2025-09-01T15:00:51.666354 - loaded completely 0.0 159.87335777282715 True 2025-09-01T15:00:52.027193 - comfyui lumi batcher overwrite task done2025-09-01T15:00:52.027193 - 2025-09-01T15:00:52.033721 - Prompt executed in 25.69 seconds 2025-09-01T15:00:57.732591 - FETCH ComfyRegistry Data: 70/962025-09-01T15:00:57.732591 - 2025-09-01T15:01:02.463536 - got prompt 2025-09-01T15:01:03.089034 - loaded completely 0.0 11350.067443847656 True 2025-09-01T15:01:03.098004 - Patching comfy attention to use sageattn2025-09-01T15:01:03.098004 - 2025-09-01T15:01:05.773837 - 15%|████████████▍ | 3/20 [00:02<00:17, 1.01s/it]2025-09-01T15:01:06.618083 - FETCH ComfyRegistry Data: 75/962025-09-01T15:01:06.618083 - 2025-09-01T15:01:15.225214 - 55%|█████████████████████████████████████████████ | 11/20 [00:12<00:10, 1.17s/it]2025-09-01T15:01:15.559178 - FETCH ComfyRegistry Data: 80/962025-09-01T15:01:15.559178 - 2025-09-01T15:01:23.462415 - 90%|█████████████████████████████████████████████████████████████████████████▊ | 18/20 [00:20<00:02, 1.18s/it]2025-09-01T15:01:24.532134 - FETCH ComfyRegistry Data: 85/962025-09-01T15:01:24.532134 - 2025-09-01T15:01:25.823332 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:22<00:00, 1.18s/it]2025-09-01T15:01:25.824332 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:22<00:00, 1.14s/it]2025-09-01T15:01:25.824332 - 2025-09-01T15:01:25.824332 - Restoring initial comfy attention2025-09-01T15:01:25.825360 - 2025-09-01T15:01:27.465611 - loaded completely 0.0 159.87335777282715 True 2025-09-01T15:01:27.822201 - comfyui lumi batcher overwrite task done2025-09-01T15:01:27.822201 - 2025-09-01T15:01:27.825191 - Prompt executed in 25.36 seconds 2025-09-01T15:01:33.620743 - FETCH ComfyRegistry Data: 90/962025-09-01T15:01:33.620743 - 2025-09-01T15:01:43.439162 - FETCH ComfyRegistry Data: 95/962025-09-01T15:01:43.439162 - 2025-09-01T15:01:45.474384 - FETCH ComfyRegistry Data [DONE]2025-09-01T15:01:45.474384 - 2025-09-01T15:01:45.625519 - [ComfyUI-Manager] default cache updated: https://api.comfy.org/nodes 2025-09-01T15:01:45.715218 - FETCH DATA from: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json2025-09-01T15:01:45.715218 - 2025-09-01T15:01:47.345156 - got prompt 2025-09-01T15:01:47.361993 - Requested to load Flux 2025-09-01T15:01:47.516137 - [DONE]2025-09-01T15:01:47.516137 - 2025-09-01T15:01:47.591887 - [ComfyUI-Manager] All startup tasks have been completed. 2025-09-01T15:01:48.028249 - loaded completely 0.0 11350.067443847656 True 2025-09-01T15:02:12.473821 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:24<00:00, 1.26s/it]2025-09-01T15:02:12.474817 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:24<00:00, 1.22s/it]2025-09-01T15:02:12.474817 - 2025-09-01T15:02:14.322793 - loaded completely 0.0 159.87335777282715 True 2025-09-01T15:02:14.683971 - comfyui lumi batcher overwrite task done2025-09-01T15:02:14.683971 - 2025-09-01T15:02:14.685964 - Prompt executed in 27.34 seconds 2025-09-01T15:02:19.663561 - got prompt 2025-09-01T15:02:20.178226 - loaded completely 0.0 11350.067443847656 True 2025-09-01T15:02:44.645309 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:24<00:00, 1.25s/it]2025-09-01T15:02:44.646305 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:24<00:00, 1.22s/it]2025-09-01T15:02:44.646305 - 2025-09-01T15:02:46.461739 - loaded completely 0.0 159.87335777282715 True 2025-09-01T15:02:46.818816 - comfyui lumi batcher overwrite task done2025-09-01T15:02:46.818816 - 2025-09-01T15:02:46.820813 - Prompt executed in 27.16 seconds 2025-09-01T15:02:53.822858 - got prompt 2025-09-01T15:02:53.845781 - Requested to load Flux 2025-09-01T15:02:54.625791 - loaded completely 0.0 11350.067443847656 True 2025-09-01T15:02:54.635757 - Patching comfy attention to use sageattn2025-09-01T15:02:54.635757 - 2025-09-01T15:03:17.948689 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:23<00:00, 1.19s/it]2025-09-01T15:03:17.950687 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:23<00:00, 1.17s/it]2025-09-01T15:03:17.951683 - 2025-09-01T15:03:17.953675 - Restoring initial comfy attention2025-09-01T15:03:17.953675 - 2025-09-01T15:03:19.664335 - loaded completely 0.0 159.87335777282715 True 2025-09-01T15:03:20.021412 - comfyui lumi batcher overwrite task done2025-09-01T15:03:20.021412 - 2025-09-01T15:03:20.027392 - Prompt executed in 26.20 seconds 2025-09-01T15:03:29.398450 - got prompt 2025-09-01T15:03:30.062602 - loaded completely 0.0 11350.067443847656 True 2025-09-01T15:03:30.071572 - Patching comfy attention to use sageattn2025-09-01T15:03:30.071572 - 2025-09-01T15:03:52.914438 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:22<00:00, 1.17s/it]2025-09-01T15:03:52.915434 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:22<00:00, 1.14s/it]2025-09-01T15:03:52.915434 - 2025-09-01T15:03:52.916431 - Restoring initial comfy attention2025-09-01T15:03:52.916431 - 2025-09-01T15:03:54.593879 - loaded completely 0.0 159.87335777282715 True 2025-09-01T15:03:54.936053 - comfyui lumi batcher overwrite task done2025-09-01T15:03:54.937051 - 2025-09-01T15:03:54.938046 - Prompt executed in 25.54 seconds 2025-09-01T15:05:17.191259 - got prompt 2025-09-01T15:05:17.823083 - loaded completely 0.0 11350.067443847656 True 2025-09-01T15:05:17.832052 - Patching comfy attention to use sageattn2025-09-01T15:05:17.833050 - 2025-09-01T15:05:40.406129 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:22<00:00, 1.16s/it]2025-09-01T15:05:40.406129 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:22<00:00, 1.13s/it]2025-09-01T15:05:40.406999 - 2025-09-01T15:05:40.407512 - Restoring initial comfy attention2025-09-01T15:05:40.407512 - 2025-09-01T15:05:42.007023 - loaded completely 0.0 159.87335777282715 True 2025-09-01T15:05:42.368928 - comfyui lumi batcher overwrite task done2025-09-01T15:05:42.368928 - 2025-09-01T15:05:42.370921 - Prompt executed in 25.18 seconds 2025-09-01T15:18:47.644508 - got prompt 2025-09-01T15:18:59.759942 - T5Encoder: 29%|███████████████████████████████████████████████████████▏ | 7/24 [00:00<00:00, 69.54it/s]2025-09-01T15:18:59.794825 - T5Encoder: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 24/24 [00:00<00:00, 177.06it/s]2025-09-01T15:18:59.795821 - 2025-09-01T15:19:00.091094 - T5Encoder: 0%| | 0/24 [00:00<?, ?it/s]2025-09-01T15:19:00.139935 - T5Encoder: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 24/24 [00:00<00:00, 501.63it/s]2025-09-01T15:19:00.140927 - 2025-09-01T15:19:16.616558 - CUDA Compute Capability: 8.9 2025-09-01T15:19:16.616558 - Detected model in_channels: 16 2025-09-01T15:19:16.617551 - Model cross attention type: t2v, num_heads: 40, num_layers: 40 2025-09-01T15:19:16.618547 - Model variant detected: 14B 2025-09-01T15:19:17.079385 - model_type FLOW 2025-09-01T15:19:17.592839 - Loading LoRA: Wan2.2加速\Wan21_T2V_14B_lightx2v_cfg_step_distill_lora_rank32 with strength: 3.0 2025-09-01T15:19:17.807323 - Using accelerate to load and assign model weights to device... 2025-09-01T15:19:24.630193 - Loading transformer parameters to cuda:0: 83%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 906/1095 [00:06<00:00, 966.70it/s]2025-09-01T15:19:24.655110 - Loading transformer parameters to cuda:0: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1095/1095 [00:06<00:00, 159.93it/s]2025-09-01T15:19:24.656107 - 2025-09-01T15:19:24.657103 - Using 1052 LoRA weight patches for WanVideo model 2025-09-01T15:19:25.598506 - sigmas: tensor([1.0000, 0.9600, 0.8889, 0.7272, 0.0000]) 2025-09-01T15:19:25.599502 - timesteps: tensor([999, 959, 888, 727], device='cuda:0') 2025-09-01T15:19:25.599502 - Using per-step cfg list: [2.0, 1.0, 1.0, 1.0] 2025-09-01T15:19:25.973765 - Input sequence length: 31050 2025-09-01T15:19:25.973765 - Sampling 89 frames at 720x480 with 4 steps 2025-09-01T15:21:45.420019 - 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4/4 [02:19<00:00, 26.10s/it]2025-09-01T15:21:45.421016 - 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4/4 [02:19<00:00, 34.77s/it]2025-09-01T15:21:45.421016 - 2025-09-01T15:21:47.906432 - Allocated memory: memory=0.097 GB 2025-09-01T15:21:47.906432 - Max allocated memory: max_memory=12.714 GB 2025-09-01T15:21:47.907430 - Max reserved memory: max_reserved=12.938 GB 2025-09-01T15:21:48.211045 - CUDA Compute Capability: 8.9 2025-09-01T15:21:48.211045 - Detected model in_channels: 16 2025-09-01T15:21:48.212042 - Model cross attention type: t2v, num_heads: 40, num_layers: 40 2025-09-01T15:21:48.213039 - Model variant detected: 14B 2025-09-01T15:21:48.689720 - model_type FLOW 2025-09-01T15:21:49.195154 - Loading LoRA: Wan2.2加速\Wan21_T2V_14B_lightx2v_cfg_step_distill_lora_rank32 with strength: 1.0 2025-09-01T15:21:49.294817 - Using accelerate to load and assign model weights to device... 2025-09-01T15:21:58.279127 - Loading transformer parameters to cuda:0: 51%|█████████████████████████████████████████████████████████████████████████████▊ | 553/1095 [00:08<00:18, 29.40it/s]2025-09-01T15:21:58.373810 - Loading transformer parameters to cuda:0: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1095/1095 [00:09<00:00, 120.63it/s]2025-09-01T15:21:58.373810 - 2025-09-01T15:21:58.386767 - Using 1052 LoRA weight patches for WanVideo model 2025-09-01T15:21:58.555691 - sigmas: tensor([0.]) 2025-09-01T15:21:58.556688 - timesteps: tensor([], device='cuda:0', dtype=torch.int64) 2025-09-01T15:22:00.877498 - Input sequence length: 31050 2025-09-01T15:22:00.878495 - Sampling 89 frames at 720x480 with 0 steps 2025-09-01T15:22:01.295938 - 0it [00:00, ?it/s]2025-09-01T15:22:01.297932 - 0it [00:00, ?it/s]2025-09-01T15:22:01.297932 - 2025-09-01T15:22:01.847336 - Allocated memory: memory=0.053 GB 2025-09-01T15:22:01.847336 - Max allocated memory: max_memory=7.034 GB 2025-09-01T15:22:01.847336 - Max reserved memory: max_reserved=7.094 GB 2025-09-01T15:22:02.003449 - !!! Exception during processing !!! cannot access local variable 'callback_latent' where it is not associated with a value 2025-09-01T15:22:02.009429 - Traceback (most recent call last): File "G:\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 "G:\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 "G:\comfyui\ComfyUI\execution.py", line 289, in _async_map_node_over_list await process_inputs(input_dict, i) File "G:\comfyui\ComfyUI\execution.py", line 277, in process_inputs result = f(**inputs) ^^^^^^^^^^^ File "G:\comfyui\ComfyUI\custom_nodes\ComfyUI-WanVideoWrapper\nodes.py", line 3988, in process "samples": callback_latent.unsqueeze(0).cpu() if callback is not None else None, ^^^^^^^^^^^^^^^ UnboundLocalError: cannot access local variable 'callback_latent' where it is not associated with a value 2025-09-01T15:22:02.017402 - comfyui lumi batcher overwrite task done2025-09-01T15:22:02.017402 - 2025-09-01T15:22:02.024379 - Prompt executed in 194.37 seconds 2025-09-01T15:26:18.533291 - got prompt 2025-09-01T15:26:18.565355 - Using accelerate to load and assign model weights to device... 2025-09-01T15:26:25.545938 - Loading transformer parameters to cuda:0: 64%|█████████████████████████████████████████████████████████████████████████████████████████████████▌ | 698/1095 [00:06<00:00, 569.60it/s]2025-09-01T15:26:25.588794 - Loading transformer parameters to cuda:0: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1095/1095 [00:07<00:00, 155.95it/s]2025-09-01T15:26:25.588794 - 2025-09-01T15:26:25.589791 - Using 1052 LoRA weight patches for WanVideo model 2025-09-01T15:26:25.652581 - sigmas: tensor([1.0000, 0.9600, 0.8889, 0.7272, 0.0000]) 2025-09-01T15:26:25.652581 - timesteps: tensor([999, 959, 888, 727], device='cuda:0') 2025-09-01T15:26:25.654574 - Using per-step cfg list: [2.0, 1.0, 1.0, 1.0] 2025-09-01T15:26:26.099813 - Input sequence length: 31050 2025-09-01T15:26:26.099813 - Sampling 89 frames at 720x480 with 4 steps 2025-09-01T15:28:34.761959 - 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4/4 [02:08<00:00, 24.73s/it]2025-09-01T15:28:34.763951 - 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4/4 [02:08<00:00, 32.06s/it]2025-09-01T15:28:34.764948 - 2025-09-01T15:28:37.388334 - Allocated memory: memory=0.097 GB 2025-09-01T15:28:37.389330 - Max allocated memory: max_memory=11.671 GB 2025-09-01T15:28:37.390934 - Max reserved memory: max_reserved=12.312 GB 2025-09-01T15:28:37.402353 - Using accelerate to load and assign model weights to device... 2025-09-01T15:28:42.447834 - Loading transformer parameters to cuda:0: 47%|████████████████████████████████████████████████████████████████████████▍ | 518/1095 [00:05<00:02, 266.27it/s]2025-09-01T15:28:42.541592 - Loading transformer parameters to cuda:0: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1095/1095 [00:05<00:00, 213.15it/s]2025-09-01T15:28:42.541592 - 2025-09-01T15:28:42.542513 - Using 1052 LoRA weight patches for WanVideo model 2025-09-01T15:28:42.585369 - sigmas: tensor([0.]) 2025-09-01T15:28:42.585369 - timesteps: tensor([], device='cuda:0', dtype=torch.int64) 2025-09-01T15:28:42.834138 - Input sequence length: 31050 2025-09-01T15:28:42.835132 - Sampling 89 frames at 720x480 with 0 steps 2025-09-01T15:28:43.084302 - 0it [00:00, ?it/s]2025-09-01T15:28:43.089282 - 0it [00:00, ?it/s]2025-09-01T15:28:43.089282 - 2025-09-01T15:28:43.383958 - Allocated memory: memory=0.053 GB 2025-09-01T15:28:43.383958 - Max allocated memory: max_memory=7.034 GB 2025-09-01T15:28:43.384950 - Max reserved memory: max_reserved=7.094 GB 2025-09-01T15:28:43.414091 - !!! Exception during processing !!! cannot access local variable 'callback_latent' where it is not associated with a value 2025-09-01T15:28:43.418074 - Traceback (most recent call last): File "G:\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 "G:\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 "G:\comfyui\ComfyUI\execution.py", line 289, in _async_map_node_over_list await process_inputs(input_dict, i) File "G:\comfyui\ComfyUI\execution.py", line 277, in process_inputs result = f(**inputs) ^^^^^^^^^^^ File "G:\comfyui\ComfyUI\custom_nodes\ComfyUI-WanVideoWrapper\nodes.py", line 3988, in process "samples": callback_latent.unsqueeze(0).cpu() if callback is not None else None, ^^^^^^^^^^^^^^^ UnboundLocalError: cannot access local variable 'callback_latent' where it is not associated with a value 2025-09-01T15:28:43.423058 - comfyui lumi batcher overwrite task done2025-09-01T15:28:43.423058 - 2025-09-01T15:28:43.428044 - Prompt executed in 144.88 seconds ``` ## 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) 报错的原因,怎么解决
09-02
2.2 Multi-Class CNN This section describes the multi-class implementation used to differentiate and classify four histopathological categories (ductal, lobular, mucinous, and papillary). The implementation followed the same engineering principles as the binary pipeline but used a categorical output and class-aware design choices to address the increased label complexity. 2.2.1 Data and Preprocessing The multi-class dataset was found on “BREAST CANCER HISTOPATHOLOGICAL DATABASE (BreakHisv1).” This dataset is modified to only include four types of malignant breast tumors, which are the four types of breast cancer used in training the model. The data structure is organized by breast cancer types, individual patient histopathology files, and the zoom factor of tissue screening. It is then assembled into a data frame of file paths and labels (class mapping: ductal carcinoma = 0, lobular carcinoma = 1, mucinous carcinoma = 2, papillary carcinoma = 3). The dataset contained 5,429 images distributed unevenly across classes (ductal: 3,451; mucinous: 792; lobular: 626; papillary: 560). An 80/20 train/validation split yielded 4,343 training and 1,086 validation samples. Images were loaded on-the-fly via ImageDataGenerator with rescaling (1./255) and light augmentation (rotation range=15, width/height shifts up to 0.1, horizontal flip). This on-the-fly strategy reduces memory pressure and preserves I/O efficiency for large image collections. Model architecture and training The multi-class CNN uses four convolutional blocks with progressively larger filters (32 → 64 → 128 → 256), each block containing Conv2D→BatchNormalization→MaxPooling2D→Dropout (0.25). After flattening, dense layers of 512 and 256 units with batch normalization and 0.5 dropout are applied; the final layer is Dense. The model is compiled with the Adam optimizer and categorical cross entropy loss to support mutually exclusive class prediction. Two experiment configurations exist in the codebase: (a) the original configuration (Batch Size = 32, Epochs = 30, LR = 0.001) that produced the run log included with this submission, and (b) a speed-optimized variant (Batch Size = 64, Epochs = 15, LR = 0.002) for faster iteration. Evaluation and Diagnostics Model evaluation uses a held-out generator and sklearn.metrics.classification_report and confusion_matrix to report per-class precision, recall, and F1-score; a seaborn heatmap visualizes the confusion matrix and matplotlib plots training/validation accuracy and loss. The run log for the original configuration reports a peak validation accuracy of 0.6529 (epoch 4) and a recorded training accuracy of 0.6967 (epoch 5) during the captured epochs; the full evaluation (per-class metrics and confusion-matrix counts) is then produced and included in the presentation. 2.2.4 Practical observations and improvements The dataset’s class imbalance (ductal dominance) is the main challenge for multi-class discrimination. Remedies to consider include class-weighted loss or oversampling of minority classes, focal loss to mitigate easy negative dominance, stronger augmentation targeted at minority classes, or stratified patch sampling. The model’s dense head (flatten → 512 units) yields ~19.4M parameters and can be prone to overfitting; replacing the flatten + dense stack with a GlobalAveragePooling2D followed by a small dense head or applying more aggressive dropout or L2 regularization may reduce overfitting. The literature suggests further gains from transfer learning (pretrained EfficientNet/ResNet backbones or DenTnet) and patch-level context models (BiLSTM on ordered patches) for cases where contextual arrangement of tissue is diagnostic. Step-by-step processing pipeline: Assemble DataFrame of filepaths and labels and report class counts. Create ImageDataGenerator instances for training (rescale + augmentation) and validation (rescale). Split into train/validation via train_test_split(..., stratify=df['label']) and create flow_from_dataframe generators. Build CNN (Conv blocks → Flatten → Dense → Softmax), compile with Adam + categorical_crossentropy. Train with model.fit using EarlyStopping and ReduceLROnPlateau callbacks; save the best model. Evaluate with a test generator: compute predicted classes, print classification_report, plot confusion matrix, and save accuracy/loss curves.分析multi-CNN模型的作用英文分析优点
最新发布
09-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Jack-Cui

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值