Ssd_keras: рдпрд╛рджреГрдЪреНрдЫрд┐рдХ рдлрд╕рд▓ рдореЗрдВ рдмрдЧ?

рдХреЛ рдирд┐рд░реНрдорд┐рдд 16 рдлрд╝рд░ре░ 2017  ┬╖  3рдЯрд┐рдкреНрдкрдгрд┐рдпрд╛рдБ  ┬╖  рд╕реНрд░реЛрдд: rykov8/ssd_keras

Ssd_training.ipynb рдореЗрдВ, рдореИрдВрдиреЗ рдкрд╛рдпрд╛ рдХрд┐ random_sized_crop рдХреЗ рдлрд╝рдВрдХреНрд╢рди рдореЗрдВ рдирд┐рдореНрди рдХреЛрдб рд╕рдорд╕реНрдпрд╛рдЧреНрд░рд╕реНрдд рд▓рдЧрддрд╛ рд╣реИ:

if (x_rel < cx < x_rel + w_rel and y_rel < cy < y_rel + h_rel):
                    xmin = (box[0] - x) / w_rel
                    ymin = (box[1] - y) / h_rel
                    xmax = (box[2] - x) / w_rel
                    ymax = (box[3] - y) / h_rel

рдЪреВрдВрдХрд┐ рдирд┐рд░реНрджреЗрд╢рд╛рдВрдХ рдмреЙрдХреНрд╕ рд╣реИрдВ [:] рд╕рд╛рдкреЗрдХреНрд╖ рдирд┐рд░реНрджреЗрд╢рд╛рдВрдХ рд╣реИрдВ, рдореБрдЭреЗ рд▓рдЧрддрд╛ рд╣реИ рдХрд┐ рдпреЗ рд░реЗрдЦрд╛рдПрдВ рд╣реЛрдиреА рдЪрд╛рд╣рд┐рдП

if (x_rel < cx < x_rel + w_rel and y_rel < cy < y_rel + h_rel):
                    xmin = (box[0] - x_rel) / w_rel
                    ymin = (box[1] - y_rel) / h_rel
                    xmax = (box[2] - x_rel) / w_rel
                    ymax = (box[3] - y_rel) / h_rel

рд╕рдмрд╕реЗ рдЙрдкрдпреЛрдЧреА рдЯрд┐рдкреНрдкрдгреА

@juntingzh @chenwgen рдпрд╣рд╛рдБ рд╕рд╣реА рдХрд╛рд░реНрдпрд╛рдиреНрд╡рдпрди рд╣реИ, рдореЗрд░рд╛ рдорд╛рдирдирд╛ тАЛтАЛтАЛтАЛрд╣реИ:

def random_sized_crop(self, img, targets):
        img_w = img.shape[1]
        img_h = img.shape[0]
        img_area = img_w * img_h
        random_scale = np.random.random()
        random_scale *= (self.crop_area_range[1] -
                         self.crop_area_range[0])
        random_scale += self.crop_area_range[0]
        target_area = random_scale * img_area
        random_ratio = np.random.random()
        random_ratio *= (self.aspect_ratio_range[1] -
                         self.aspect_ratio_range[0])
        random_ratio += self.aspect_ratio_range[0]
        w = np.round(np.sqrt(target_area * random_ratio))     
        h = np.round(np.sqrt(target_area / random_ratio))
        if np.random.random() < 0.5:
            w, h = h, w
        w = min(w, img_w)
        w_rel = w / img_w
        w = int(w)
        h = min(h, img_h)
        h_rel = h / img_h
        h = int(h)
        x = np.random.random() * (img_w - w)
        x_rel = x / img_w
        x = int(x)
        y = np.random.random() * (img_h - h)
        y_rel = y / img_h
        y = int(y)
        img = img[y:y+h, x:x+w]
        new_targets = []
        for box in targets:
            cx = 0.5 * (box[0] + box[2])
            cy = 0.5 * (box[1] + box[3])
            if (x_rel < cx < x_rel + w_rel and
                y_rel < cy < y_rel + h_rel):
                xmin = (box[0] - x_rel) / w_rel
                ymin = (box[1] - y_rel) / h_rel
                xmax = (box[2] - x_rel) / w_rel
                ymax = (box[3] - y_rel) / h_rel
                xmin = max(0, xmin)
                ymin = max(0, ymin)
                xmax = min(1, xmax)
                ymax = min(1, ymax)
                box[:4] = [xmin, ymin, xmax, ymax]
                new_targets.append(box)
        new_targets = np.asarray(new_targets).reshape(-1, targets.shape[1])
        return img, new_targets

рд╕рднреА 3 рдЯрд┐рдкреНрдкрдгрд┐рдпрд╛рдБ

@juntingzh рд╣рд╛рдБ, рд╢рд╛рдпрдж, рддреБрдо рд╕рд╣реА рд╣реЛред рдореБрдЭреЗ рдкрддрд╛ рд╣реИ рдХрд┐ рд╡рд┐рдзрд┐ random_sized_crop рдореЗрдВ рдмрдЧ рд╣реИрдВред рдореИрдВ рдЗрд╕реЗ рдЬрд▓реНрдж рд╕реЗ рдЬрд▓реНрдж рдареАрдХ рдХрд░рдиреЗ рдХреА рдЙрдореНрдореАрдж рдХрд░рддрд╛ рд╣реВрдВред рдореЗрд░реЗ рдкрд╛рд╕ рд╕рд░реНрд╡рд░ рдкрд░ рдЗрд╕ рдкрджреНрдзрддрд┐ рдХрд╛ рдХрд╛рд░реНрдпрд╢реАрд▓ рд╕рдВрд╕реНрдХрд░рдг рд╣реИ, рд▓реЗрдХрд┐рди рдЕрднреА рдЗрд╕рдХреА рдкрд╣реБрдВрдЪ рдирд╣реАрдВ рд╣реИред

рдХрдХреНрд╖рд╛ рдЬрдирд░реЗрдЯрд░ рдореЗрдВ, self.crop_attempts рдХреНрдпрд╛ рдХрд░рддрд╛ рд╣реИ?

@juntingzh @chenwgen рдпрд╣рд╛рдБ рд╕рд╣реА рдХрд╛рд░реНрдпрд╛рдиреНрд╡рдпрди рд╣реИ, рдореЗрд░рд╛ рдорд╛рдирдирд╛ тАЛтАЛтАЛтАЛрд╣реИ:

def random_sized_crop(self, img, targets):
        img_w = img.shape[1]
        img_h = img.shape[0]
        img_area = img_w * img_h
        random_scale = np.random.random()
        random_scale *= (self.crop_area_range[1] -
                         self.crop_area_range[0])
        random_scale += self.crop_area_range[0]
        target_area = random_scale * img_area
        random_ratio = np.random.random()
        random_ratio *= (self.aspect_ratio_range[1] -
                         self.aspect_ratio_range[0])
        random_ratio += self.aspect_ratio_range[0]
        w = np.round(np.sqrt(target_area * random_ratio))     
        h = np.round(np.sqrt(target_area / random_ratio))
        if np.random.random() < 0.5:
            w, h = h, w
        w = min(w, img_w)
        w_rel = w / img_w
        w = int(w)
        h = min(h, img_h)
        h_rel = h / img_h
        h = int(h)
        x = np.random.random() * (img_w - w)
        x_rel = x / img_w
        x = int(x)
        y = np.random.random() * (img_h - h)
        y_rel = y / img_h
        y = int(y)
        img = img[y:y+h, x:x+w]
        new_targets = []
        for box in targets:
            cx = 0.5 * (box[0] + box[2])
            cy = 0.5 * (box[1] + box[3])
            if (x_rel < cx < x_rel + w_rel and
                y_rel < cy < y_rel + h_rel):
                xmin = (box[0] - x_rel) / w_rel
                ymin = (box[1] - y_rel) / h_rel
                xmax = (box[2] - x_rel) / w_rel
                ymax = (box[3] - y_rel) / h_rel
                xmin = max(0, xmin)
                ymin = max(0, ymin)
                xmax = min(1, xmax)
                ymax = min(1, ymax)
                box[:4] = [xmin, ymin, xmax, ymax]
                new_targets.append(box)
        new_targets = np.asarray(new_targets).reshape(-1, targets.shape[1])
        return img, new_targets
рдХреНрдпрд╛ рдпрд╣ рдкреГрд╖реНрда рдЙрдкрдпреЛрдЧреА рдерд╛?
0 / 5 - 0 рд░реЗрдЯрд┐рдВрдЧреНрд╕

рд╕рдВрдмрдВрдзрд┐рдд рдореБрджреНрджреЛрдВ

abduallahmohamed picture abduallahmohamed  ┬╖  16рдЯрд┐рдкреНрдкрдгрд┐рдпрд╛рдБ

freshn picture freshn  ┬╖  4рдЯрд┐рдкреНрдкрдгрд┐рдпрд╛рдБ

natlachaman picture natlachaman  ┬╖  6рдЯрд┐рдкреНрдкрдгрд┐рдпрд╛рдБ

fferroni picture fferroni  ┬╖  16рдЯрд┐рдкреНрдкрдгрд┐рдпрд╛рдБ

kitterive picture kitterive  ┬╖  11рдЯрд┐рдкреНрдкрдгрд┐рдпрд╛рдБ