首页 其他比赛 帖子详情
关于猫十二分类
收藏
快速回复
其他比赛 问答其他 3890 10
关于猫十二分类
收藏
快速回复
其他比赛 问答其他 3890 10

请问哪里能够看到可以运行的代码,我实在写不出来了,在项目里找找到的又都是没有写完的,后面还好,我在前面读取数据、数据处理部分就很懵。。

0
收藏
回复
全部评论(10)
时间顺序
Z
ZTR1997
#2 回复于2020-04

0
回复
快乐的小花匠
#3 回复于2020-05

https://aistudio.baidu.com/aistudio/projectdetail/107695

0
回复
星光ld1
#4 回复于2020-05
def custom_image_reader(file_list, data_dir, mode):
    """
    自定义用户图片读取器,先初始化图片种类,数量
    :param file_list:
    :param data_dir:
    :param mode:
    :return:
    """
    with codecs.open(file_list) as flist:
        lines = [line.strip() for line in flist]

    def reader():
        np.random.shuffle(lines)
        for line in lines:
            if mode == 'train' or mode == 'val':
                img_path, label = line.split()
                img = Image.open(img_path)
                try:
                    if img.mode != 'RGB':
                        img = img.convert('RGB')
                    if train_parameters['image_enhance_strategy']['need_distort'] == True:
                        img = distort_color(img)
                    if train_parameters['image_enhance_strategy']['need_rotate'] == True:
                        img = rotate_image(img)
                    if train_parameters['image_enhance_strategy']['need_crop'] == True:
                        img = random_crop(img, train_parameters['input_size'])
                    if train_parameters['image_enhance_strategy']['need_flip'] == True:
                        mirror = int(np.random.uniform(0, 2))
                        if mirror == 1:
                            img = img.transpose(Image.FLIP_LEFT_RIGHT)
                    # HWC--->CHW && normalized
                    img = np.array(img).astype('float32')
                    img -= train_parameters['mean_rgb']
                    img = img.transpose((2, 0, 1))  # HWC to CHW
                    img *= 0.007843                 # 像素值归一化
                    yield img, int(label)
                except Exception as e:
                    pass                            # 以防某些图片读取处理出错,加异常处理
            elif mode == 'test':
                img_path = os.path.join(data_dir, line)
                img = Image.open(img_path)
                if img.mode != 'RGB':
                    img = img.convert('RGB')
                img = resize_img(img, train_parameters['input_size'])
                # HWC--->CHW && normalized
                img = np.array(img).astype('float32')
                img -= train_parameters['mean_rgb']
                img = img.transpose((2, 0, 1))  # HWC to CHW
                img *= 0.007843  # 像素值归一化
                yield img

    return reader
0
回复
joker-wt
#5 回复于2020-06

有人提交过最终的result文件了嘛。CSV内容大概是什么样的,为什么我提交之后得分是0啊

 

0
回复
星光ld1
#6 回复于2020-06
有人提交过最终的result文件了嘛。CSV内容大概是什么样的,为什么我提交之后得分是0啊  

格式错的话不会占用提交次数的

0
回复
星光ld1
#7 回复于2020-06
有人提交过最终的result文件了嘛。CSV内容大概是什么样的,为什么我提交之后得分是0啊  

格式的话我记得是path,label

0
回复
joker-wt
#8 回复于2020-06

 

最终我生成的CSV文件内容那那个是这样的,为什么没有成绩啊

0
回复
星光ld1
#9 回复于2020-06
  最终我生成的CSV文件内容那那个是这样的,为什么没有成绩啊 [图片]

path好像只要文件名,有点久了不太确定,你改成只有文件名试试?另外我看你给的infer结果也不是特别好,是网络没收敛还是前处理不一致?

0
回复
geoyee
#10 回复于2020-08
  最终我生成的CSV文件内容那那个是这样的,为什么没有成绩啊 [图片]

图像只要名字,XX.jpg,不用前面的地址;表头应该不要吧

0
回复
寂寞你快进去
#11 回复于2020-08

这个项目最后生成的csv就是能够正确提交的:https://aistudio.baidu.com/aistudio/projectdetail/524018

0
回复
在@后输入用户全名并按空格结束,可艾特全站任一用户