Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About test.py #95

Open
huahuabai opened this issue May 16, 2022 · 4 comments
Open

About test.py #95

huahuabai opened this issue May 16, 2022 · 4 comments

Comments

@huahuabai
Copy link

Hello, author. When I execute test according to the command you gave me, I have the following problem
image
How can I solve this problem?

@lyx-0213
Copy link

Hi, were you able to solve this issue?

@Ycxyue
Copy link

Ycxyue commented Jul 12, 2022

在dataset/pan_ctw.py的prepare_test_data函数中有关于img_meta的字段写入,只需要添加

def prepare_test_data(self, index):
        img_path = self.img_paths[index]
        # print('img_path:', img_path)
        img_name = img_path.split('/')[-1]#修改的地方
        img = get_img(img_path, self.read_type)
        img_meta = dict(org_img_size=np.array(img.shape[:2]))

        img = scale_aligned_short(img, self.short_size)
        img_meta.update(dict(img_size=np.array(img.shape[:2])))
        img_meta.update(dict(img_name=img_name))#add
        img_meta.update(dict(img_path=img_path))#add

        img = Image.fromarray(img)
        img = img.convert('RGB')
        img = transforms.ToTensor()(img)
        img = transforms.Normalize(mean=[0.485, 0.456, 0.406],
                                   std=[0.229, 0.224, 0.225])(img)

        data = dict(imgs=img, img_metas=img_meta)

        return data 

修改完后就可以跑通test.py了

@lyx-0213
Copy link

成啦!谢!谢!你!

@huahuabai
Copy link
Author

在dataset/pan_ctw.py的prepare_test_data函数中有关于img_meta的字段写入,只需要添加

def prepare_test_data(self, index):
        img_path = self.img_paths[index]
        # print('img_path:', img_path)
        img_name = img_path.split('/')[-1]#修改的地方
        img = get_img(img_path, self.read_type)
        img_meta = dict(org_img_size=np.array(img.shape[:2]))

        img = scale_aligned_short(img, self.short_size)
        img_meta.update(dict(img_size=np.array(img.shape[:2])))
        img_meta.update(dict(img_name=img_name))#add
        img_meta.update(dict(img_path=img_path))#add

        img = Image.fromarray(img)
        img = img.convert('RGB')
        img = transforms.ToTensor()(img)
        img = transforms.Normalize(mean=[0.485, 0.456, 0.406],
                                   std=[0.229, 0.224, 0.225])(img)

        data = dict(imgs=img, img_metas=img_meta)

        return data 

修改完后就可以跑通test.py了

感恩啊!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants