backtime92 / CRAFT-Reimplementation

CRAFT-Pyotorch:Character Region Awareness for Text Detection Reimplementation for Pytorch
464 stars 157 forks source link

data processing bug #54

Open shuangshuangguo opened 4 years ago

shuangshuangguo commented 4 years ago

https://github.com/backtime92/CRAFT-Reimplementation/blob/3240fd6e49521a50bd122cba965e742514aa6000/gaussian.py#L131

The code can only process horizontal text, but not vertical text. I modify it as follows.

def add_affinity(self, image, bbox_1, bbox_2, flag_vertical=False):
        center_1, center_2 = np.mean(bbox_1, axis=0), np.mean(bbox_2, axis=0)
        if flag_vertical:
            tl = np.mean([bbox_1[0], bbox_1[3], center_1], axis=0)
            bl = np.mean([bbox_2[0], bbox_2[3], center_2], axis=0)
            tr = np.mean([bbox_1[1], bbox_1[2], center_1], axis=0)
            br = np.mean([bbox_2[1], bbox_2[2], center_2], axis=0)
        else:
            tl = np.mean([bbox_1[0], bbox_1[1], center_1], axis=0)
            bl = np.mean([bbox_1[2], bbox_1[3], center_1], axis=0)
            tr = np.mean([bbox_2[0], bbox_2[1], center_2], axis=0)
            br = np.mean([bbox_2[2], bbox_2[3], center_2], axis=0)

        affinity = np.array([tl, tr, br, bl])

        return self.add_affinity_character(image, affinity.copy()), np.expand_dims(affinity, axis=0)
shuangshuangguo commented 4 years ago

The trained model which you support can not detect vertical text.