Giter VIP home page Giter VIP logo

cpd's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cpd's Issues

train.py

能否提供训练的代码 train.py

【小白举手提问】

您好,请问model/CPD_models.py中self.upsample(detection)得到的saliency weight map(彩图),物理意义是什么,计算方式是啥?别的代码中没有这个,我怎么得到这个彩图呢?

【欢迎前排的各位大哥指教】

why SGD cannot work?

I want to replace the adam optimizer by the SGD optimizer, however get the bad result. I don't know why ? Can you help me ?

Figure 2

Hi, thanks for your paper and code.
I am curious about how you generate the Figure 2. Your paper states that the saliency maps are genrated by using VGG16. However, feature maps in VGG16 have more than one channel. I guess the saliency maps are produced by correspongding side output layer in DSS, am i right?

About experiment setting

First of all, thanks for the codes. I’m a green man here and I want to know you how to split the datasets into training data and testing data? What about the split rate or do nothing about it?

No data augmentation?

No data augmentation is used in training? decay_epoch is 50 or 30? Looking forward to your reply, thanks.

我运行train.py报错

Traceback (most recent call last):
File "train.py", line 9, in
from model.CPD_models import CPD_VGG
ImportError: bad magic number in 'model': b'\x03\xf3\r\n'
可有解决方法?

No module named 'HolistcAttention'

你好,
请问为什么我test.py的代码在运行过程中总会有error,No module named 'HolistcAttention'。运行HolistcAttention.py文件的话又没有错误,请问可以解答一下吗 谢谢。

关于您代码的fps的计算?

最近有需求需要考虑代码的速度,自己测了下您的代码,我是按照如下的方式测试的。但是和您原文差距实在太大,想向您请教下!

我用myway的方式输出图片要比您的test_CPD.py中提供的方式要快些,~~但是也只有29.6FPS~,当然,我是直接在DUTS-TE上跑了一次,一次处理一张图,不知道和您的方式是否有差异?

NOTE

2019年07月21日21:08:56修改:我再次测试的时候,发现速度快了一些,可能和我当时电脑同时在运行其他占据了大量磁盘IO的程序有关系,这次测得了FPS:49.78818400079663

image

# -*- coding: utf-8 -*-
# @Time    : 2019/7/21 下午9:10
# @Author  : Lart Pang
# @FileName: new_fps.py
# @Project : CPD
# @GitHub  : https://github.com/lartpang

import os
import time

import torch
from PIL import Image
from torchvision import transforms
from tqdm import tqdm

from model.CPD_ResNet_models import CPD_ResNet

torch.manual_seed(0)
torch.cuda.manual_seed_all(0)
torch.cuda.empty_cache()
torch.multiprocessing.set_sharing_strategy('file_system')
torch.backends.cudnn.benchmark = False
torch.backends.cudnn.deterministic = False


def check_mkdir(dir_name):
    if not os.path.exists(dir_name):
        os.makedirs(dir_name)


class FPS():
    def __init__(self, proj_name, args):
        super(FPS, self).__init__()
        self.args = args
        self.to_pil = transforms.ToPILImage()
        self.proj_name = proj_name
        self.dev = torch.device("cuda:0")
        self.net = self.args[proj_name]['net']().to(self.dev)
        self.net.eval()

        self.test_img_transform = transforms.Compose([
            transforms.Resize((self.args['crop_size'], self.args['crop_size'])),
            transforms.ToTensor(),
            transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
        ])

    def get_fps(self, data_path, save_path):
        print(f'保存路径为{save_path}')
        check_mkdir(save_path)

        print(f'开始测试...{data_path}')
        img_path = os.path.join(data_path, 'Image')
        img_list = os.listdir(img_path)

        start_time = time.time()
        tqdm_iter = tqdm(enumerate(img_list), total=len(img_list), leave=False)
        for idx, img_name in tqdm_iter:
            tqdm_iter.set_description(f"{self.proj_name}:te=>{idx + 1}")
            img_fullpath = os.path.join(img_path, img_name)
            test_data = Image.open(img_fullpath).convert('RGB')
            img_size = test_data.size
            test_data = self.test_img_transform(test_data)
            test_data = test_data.unsqueeze(0)

            inputs = test_data.to(self.dev)
            with torch.no_grad():
                _, res = self.net(inputs)
            # res = F.interpolate(res, size=img_size, mode='bilinear', align_corners=False)
            # res = res.sigmoid().data.cpu().numpy().squeeze()
            # res = (res - res.min()) / (res.max() - res.min() + 1e-8) * 255
            # oimg_path = os.path.join(save_path, img_name[:-4] + '.png')
            # imwrite(oimg_path, res.astype(numpy.uint8))

            # myway 29.6
            res = res.sigmoid().cpu().detach().squeeze(0)
            res = self.to_pil(res).resize(img_size)
            oimg_path = os.path.join(save_path, img_name[:-4] + '.png')
            res.save(oimg_path)

        total_time = time.time() - start_time
        fps = len(img_list) / total_time
        return fps


if __name__ == '__main__':
    proj_list = ['CPD']

    data_dicts = {
        'duts': '/home/lart/Datasets/RGBSaliency/DUTS/Test',
    }

    arg_dicts = {
        'CPD'      : {
            'net'     : CPD_ResNet,
            'exp_name': 'CPD_ResNet'
        },
        'crop_size': 352,
    }

    result = {}
    for proj_name in proj_list:
        result[arg_dicts[proj_name]['exp_name']] = {}

        for data_name, data_path in data_dicts.items():
            save_path = (f"/home/lart/Coding/CPD/output/"
                         f"{arg_dicts[proj_name]['exp_name']}/pre/{data_name}")
            fpser = FPS(proj_name, arg_dicts)
            fps = fpser.get_fps(data_path, save_path)
            print(f"FPS:{fps}")
            del fpser
    print('测试完毕')

The conversion from float32 to uint8?

When testing, we have the following warning.
Lossy conversion from float32 to uint8. Range [0, 1]. Convert image to uint8 prior to saving to suppress this warning.
Does this affect the final result?

The parameter of 'trainset'

train.py

parser = argparse.ArgumentParser()
parser.add_argument('--epoch', type=int, default=100, help='epoch number')
parser.add_argument('--lr', type=float, default=1e-4, help='learning rate')
parser.add_argument('--batchsize', type=int, default=10, help='training batch size')
parser.add_argument('--trainsize', type=int, default=352, help='training dataset size')
parser.add_argument('--clip', type=float, default=0.5, help='gradient clipping margin')
parser.add_argument('--is_ResNet', type=bool, default=False, help='VGG or ResNet backbone')
parser.add_argument('--decay_rate', type=float, default=0.1, help='decay rate of learning rate')
parser.add_argument('--decay_epoch', type=int, default=50, help='every n epochs decay learning rate')
opt = parser.parse_args()

print('Learning Rate: {} ResNet: {} Trainset: {}'.format(opt.lr, opt.is_ResNet, opt.trainset))

as you can see from above code , there no declaration about 'trainset' in add_argument(). However, this argument be used in print (...., opt.trainset)

what's mean of trainset? thank you for your anwser

About PiCANet performance at PSACAL-S

I notice that , PiCANet-R performance in original paper is different of that in CPD paper.

PiCANet paper
FMeausre: 0.881
MAE: 0.087

CPD paper
FMeasure: 0.863
MAE: 0.075

Do you reimplement PiCANet or evaluate the provided saliency maps ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.