Matlab Parfor实测,成功运行

 
    % 图片描述符计算,开启的线程数
    core = 6;
    p = parpool(core);
    
    % 并行计算的图片数
    sum_batch = numel(imginds);
    n_batch = sum_batch/2000;

    % 第几个批次的图片
    N = 1;
    end_batch = 2000 * N;
    start_batch = 2000 *(N-1)+1;

    
    % 原文计算方法
    parfor i=start_batch:end_batch
        % totaldesctime、desccount、errorimages
        % 上面三个变量在parfor运行中出现问题
        
        %显示生成图像的描述符的进度
        imgind = imginds(i);
        disp(['Image ',num2str(i),' / ',num2str(numel(imginds))]);     
        
        imgfilename = rels.imgfilenames{imgind};
        
        % get all relevant relationships in the current image
        if not(isempty(inputrels))
            disp('inputrels is not empty!');
            % query given relationships
            imgrels{i} = DatabaseRelationshipSet;
            imgrels{i}.append(inputrels,inputrels.imgrelinds{i});
            imgrels{i}.lockimgfilenames = true;
            
            % filter by source and target labels
            validmask = true(1,numel(imgrels{i}.id));
            
            if not(isempty(sourcelbl)) || not(isempty(targetlbl))
                if not(isempty(sourcelbl))
                    relind = cellind_mex(imgrels{i}.sourcelabels);
                    relind = [relind{:}];
                    imgsrclbls = [imgrels{i}.sourcelabels{:}];
                    validsrclbl = ismember(imgsrclbls,sourcelbl);
                    validsrclbl = array2cell_mex(double(validsrclbl),relind,numel(imgrels{i}.sourcelabels));
                    validsrclbl = cellfun(@(x) not(isempty(x)) && all(x),validsrclbl);
                else
                    validsrclbl = true(1,numel(imgrels{i}.sourcelabels));
                end

                if not(isempty(targetlbl))
                    relind = cellind_mex(imgrels{i}.targetlabels);
                    relind = [relind{:}];
                    imgtgtlb
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值