check if all the images have been loaded

本文介绍了一个实用的JavaScript函数,用于检测网页上所有图片是否已完全加载。通过遍历页面中的图片并检查其完成属性,该函数能够返回一个指示所有图片加载状态的值。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


        // allImagesLoaded()
        // Checks if all the images are loaded in the document
        // It Does this by looping through all the images and checks the attribute .complete
        // If .complete is false then we set the return variable to 0
        function allImagesLoaded() {
       
                // return variable
                var imagesloaded = 1;
       
                // All images are saved in an array called document.images. Very usefull
                var images = document.images;
                // Loop through all the images
                for (var i = 0;i<images.length;i++)
                {
                        // If the image isnt loaded we set the return varible to 0
                        if(images[i].complete == false) {
                                imagesloaded = 0;
                        }
                }
       
                // This will return 0 if one or more images are not loaded and 1 if all images are loaded.
                return imagesloaded;
        }
2025-03-20 04:26:29.893491: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:467] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered WARNING: All log messages before absl::InitializeLog() is called are written to STDERR E0000 00:00:1742459189.923278 7224 cuda_dnn.cc:8579] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered E0000 00:00:1742459189.932373 7224 cuda_blas.cc:1407] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered W0000 00:00:1742459189.960838 7224 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once. W0000 00:00:1742459189.960898 7224 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once. W0000 00:00:1742459189.960902 7224 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once. W0000 00:00:1742459189.960905 7224 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once. 2025-03-20 04:26:29.966980: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations. To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags. Namespace(weights='/home/book/rk3566/ai_tools/FaceRecognition-master/weights/last.pt', source='/home/book/rk3566/ai_tools/yolov5-face-master/data/images/lhr.jpg', output='../inference/output', img_size=640, conf_thres=0.3, iou_thres=0.5, fourcc='mp4v', device='', view_img=False, save_txt=False, classes=None, agnostic_nms=False, augment=False, facenet_model_path='../20180408-102900', svc_path='../SVCmodel.pkl', database_path='../Database.npz') Using CPU Traceback (most recent call last): File "/home/book/rk3566/ai_tools/FaceRecognition-master/recognition/test.py", line 374, in <module> detect(setOPT()) # step3 File "/home/book/rk3566/ai_tools/FaceRecognition-master/recognition/test.py", line 37, in detect model = torch.load(weights, map_location=device)['model'].float() # load to FP32 File "/home/book/anaconda3/envs/yolov5face/lib/python3.9/site-packages/torch/serialization.py", line 1494, in load raise pickle.UnpicklingError(_get_wo_message(str(e))) from None _pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those steps only if you trust the source of the checkpoint. (1) In PyTorch 2.6, we changed the default value of the `weights_only` argument in `torch.load` from `False` to `True`. Re-running `torch.load` with `weights_only` set to `False` will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source. (2) Alternatively, to load with `weights_only=True` please check the recommended steps in the following error message. WeightsUnpickler error: Unsupported global: GLOBAL numpy.core.multiarray._reconstruct was not an allowed global by default. Please use `torch.serialization.add_safe_globals([_reconstruct])` or the `torch.serialization.safe_globals([_reconstruct])` context manager to allowlist this global if you trust this class/function. Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html. 报错了
03-21
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值