def extract(classifier, grayscale, *chs):
    """
    Extract using dense model (faster).

    classifier: Caffe Classifier object
    grayscale: Input image
    """
    # Set scale so that the longest is MAX_SIDE
    min_side = np.min(grayscale.shape[:2])
    max_side = np.max(grayscale.shape[:2])
    scale = min(min_side / MIN_SIDE, 1)
    if max_side * scale >= MAX_SIDE:
        scale = MAX_SIDE / max_side

    HOLE = 4

    #samples = classifier.blobs['centroids'].data.shape[1]
    size = classifier.blobs['data'].data.shape[2]
    #centroids = np.zeros((1, samples, 2), dtype=np.float32)
    full_shape = grayscale.shape[:2]
    raw_grayscale = grayscale.copy()
    if scale != 1:
        grayscale = resize_by_factor(grayscale, scale)
    raw_shape = grayscale.shape[:2]

    st0 = (size - raw_shape[0])//2
    en0 = st0 + raw_shape[0]
    st1 = (size - raw_shape[1])//2
    en1 = st1 + raw_shape[1]

    #raw_img = image.center_crop_reflect(raw_img, (size, size))
    grayscale = image.center_crop(grayscale, (size, size))

    #bgr = raw_img.transpose(2, 0, 1)[np.newaxis]

    data = grayscale[np.newaxis, np.newaxis]

    #shape = grayscale.shape[:2]

    scaled_size = size // HOLE

    scaled_shape = tuple([shi // HOLE for shi in raw_shape[:2]])

    ret = classifier.forward(data=data)

    data = {key: classifier.blobs[key].data for key in classifier.blobs}

    scaleds = [ret['prediction_h_full'][0].transpose(1, 2, 0), ret['prediction_c_full'][0].transpose(1, 2,0)]

    scaled_combined = np.concatenate(scaleds, axis=-1)

    #full_combined = resize_by_factor(scaled_combined, HOLE / scale)
    full_combined = resize_by_factor(scaled_combined, 1 / scale)
    full_combined = image.center_crop(full_combined, full_shape)
    assert full_combined.shape[:2] == full_shape
    combined = full_combined

    res = []
    cur = 0
    for i, ch in enumerate(chs):
        C = scaleds[i].shape[-1]
        res.append(combined[..., cur:cur + C])
        cur += C

    return tuple(res)
dataset/ETHPy150Open gustavla/autocolorize/autocolorize/extraction.py/extract/swapped operands of `/`