# PixlHop ++
for i in range(
        22
):  # pixelHop 0, 1: {TH1: 0.05, TH2: 0.005} finished   # features: 0 finished
    print(i)

    # p2_1 = Pixelhop2(depth=2, TH1=0.0000001, TH2=0.00000001, SaabArgs=SaabArgs, shrinkArgs=shrinkArgs,
    #                concatArg=concatArg).fit(train_selected[:, :, :, i][:, :, :, None])
    # f = open("/mnt/zhengwen/image_steganalysis/dataset/codes/PixelHopStegoPts_5_5_2nd_3rd_layer_" + str(i) + "_PIXEL_sample.pkl", 'wb')
    # pickle.dump(p2_1, f)
    # f.close()
    p2_1 = Pixelhop2(depth=2,
                     TH1=0.0000001,
                     TH2=0.00000001,
                     SaabArgs=SaabArgs,
                     shrinkArgs=shrinkArgs,
                     concatArg=concatArg).fit(train_selected[:, :, :,
                                                             i][:, :, :, None])
    f = open(
        "/mnt/zhengwen/image_steganalysis/dataset/codes/PixelHopStegoPts_5_5_2nd_3rd_layer_"
        + str(i) + "_PIXEL_sample_ALL.pkl", 'wb')
    pickle.dump(p2_1, f)
    f.close()

    feature_p2_1 = p2_1.transform(train_selected[:, :, :, i][:, :, :, None])
    print(i, feature_p2_1[1].shape)
    # np.save("/mnt/zhengwen/image_steganalysis/dataset/codes/end_features_from_" + str(i) + "_PIXEL_0_sample.npy", feature_p2_1[0])
    # np.save("/mnt/zhengwen/image_steganalysis/dataset/codes/end_features_from_" + str(i) + "_PIXEL_1_sample.npy", feature_p2_1[1])
    np.save(
        "/mnt/zhengwen/image_steganalysis/dataset/codes/end_features_from_" +
    'func': Shrink,
    'win': 3
}]
concatArg = {'func': Concat}

train_patches = np.concatenate((original_vectors, stego_vectors), axis=0)
train_labels = np.concatenate(
    (0 * np.ones(len(original_vectors)), 1 * np.ones(len(stego_vectors))),
    axis=0)
idx = np.random.permutation(len(train_patches))
train_patches = train_patches[idx]
train_labels = train_labels[idx]

p2_original = Pixelhop2(depth=2,
                        TH1=0.005,
                        TH2=0.001,
                        SaabArgs=SaabArgs,
                        shrinkArgs=shrinkArgs,
                        concatArg=concatArg)
p2_original.fit(train_patches[:, :, :, None])

f = open('/mnt/zhengwen/new_trial/p2_original_week8_HONGSHUO', 'wb')
pickle.dump(p2_original, f)
f.close()

train_features = p2_original.transform(train_patches[:, :, :, None])

pixel_hop_2 = train_features[1]
n_channels = pixel_hop_2.shape[-1]
N_train = pixel_hop_2.shape[0]

params = {
    return X


# set args for PixelHop++
SaabArgs = [{
    'num_AC_kernels': -1,
    'needBias': True,
    'useDC': True,
    'batch': None
}]
shrinkArgs = [{'func': Shrink, 'win': 5}]
concatArg = {'func': Concat}

p2 = Pixelhop2(depth=1,
               TH1=1e-20,
               TH2=1e-30,
               SaabArgs=SaabArgs,
               shrinkArgs=shrinkArgs,
               concatArg=concatArg).fit(steg_patches)

# f = open("/mnt/zhengwen/image_steganalysis/dataset/codes/PixelHopStegoPts_5_5_1st_layer.pkl", 'wb') # overlapping
f = open(
    "/mnt/zhengwen/image_steganalysis/dataset/codes/PixelHopStegoPts_5_5_1st_layer_sampled.pkl",
    'wb')  # sampled
# f = open("/mnt/zhengwen/image_steganalysis/dataset/codes/PixelHopStegoPts_7_7_1st_layer.pkl", 'wb')
pickle.dump(p2, f)
f.close()

features_cover = p2.transform(cover_patches)
features_steg = p2.transform(steg_patches)

features_cover = np.squeeze(features_cover)
示例#4
0
}, {
    'func': Shrink,
    'win': 5
}, {
    'func': Shrink,
    'win': 5
}, {
    'func': Shrink,
    'win': 5
}]
concatArg = {'func': Concat}

# PixlHop ++
p2 = Pixelhop2(depth=4,
               TH1=0.005,
               TH2=0.0005,
               SaabArgs=SaabArgs,
               shrinkArgs=shrinkArgs,
               concatArg=concatArg).fit(train_img)

p2.construct_count()

# f = open("PixelHopUniform.pkl", 'wb')  # 3 PixelHop, win: 5, TH1:0.005, TH2:0.005, CH1: 15, CH2: 20, CH3: 25, NUM_TRAIN=500
f = open("PixelHopUniform_4PH.pkl", 'wb')
pickle.dump(p2, f)
f.close()

# test_feature = p2.transform(test_images)
#
# print(train_feature[0].shape, train_feature[1].shape)
# print("------- DONE -------\n")
#
    'needBias': True,
    'useDC': False,
    'batch': None
}, {
    'num_AC_kernels': -1,
    'needBias': True,
    'useDC': False,
    'batch': None
}]
shrinkArgsTrain = [{'func': Shrink, 'win': 5}, {'func': Shrink, 'win': 5}]
concatArg = {'func': Concat}

p1_max = Pixelhop2(depth=1,
                   TH1=1e-20,
                   TH2=1e-30,
                   SaabArgs=SaabArgs,
                   shrinkArgs=shrinkArgsTrain,
                   concatArg=concatArg).fit(
                       blocks_cover_train[kmeans.labels_ == steg_top_class])
f = open(
    "/mnt/zhengwen/image_steganalysis/dataset/codes/PXH_patch_energy_MAX.pkl",
    'wb')  # 1st hop
pickle.dump(p1_max, f)
f.close()

features_cover_max_p1 = p1_max.transform(
    blocks_cover_train[kmeans.labels_ == steg_top_class])
features_stego_max_p1 = p1_max.transform(
    blocks_stego_train[kmeans.labels_ == steg_top_class])

feature_max_p1 = np.concatenate(
示例#6
0
    'needBias': True,
    'useDC': False,
    'batch': None
}, {
    'num_AC_kernels': -1,
    'needBias': True,
    'useDC': False,
    'batch': None
}]
shrinkArgsTrain = [{'func': Shrink, 'win': 5}, {'func': Shrink, 'win': 5}]
concatArg = {'func': Concat}

p_single = Pixelhop2(depth=1,
                     TH1=1e-20,
                     TH2=1e-30,
                     SaabArgs=SaabArgs,
                     shrinkArgs=shrinkArgsTrain,
                     concatArg=concatArg).fit(
                         single_circle[None, :, :, None].astype('double'))
p_multip = Pixelhop2(depth=1,
                     TH1=1e-20,
                     TH2=1e-30,
                     SaabArgs=SaabArgs,
                     shrinkArgs=shrinkArgsTrain,
                     concatArg=concatArg).fit(
                         multip_circle[None, :, :, None].astype('double'))

channel_idx = 20

single_BY_single_feature = np.squeeze(
    p_single.transform(single_circle[None, :, :, None])[0])[:, :, channel_idx]