0
$\begingroup$

i create A model based on ELA [error level Analysis] for image forgery detection i use the following code :

def convert_to_ela_image(path, quality):
    filename = path
    resaved_filename = filename.split('.')[0] + '.resaved.jpg'
    im = Image.open(filename).convert('RGB')
    im.save(resaved_filename, 'JPEG', quality=quality)
    resaved_im = Image.open(resaved_filename)

    ela_im = ImageChops.difference(im, resaved_im)

    extrema = ela_im.getextrema()
    max_diff = max([ex[1] for ex in extrema])
    if max_diff == 0:
        max_diff = 1
    scale = 255.0 / max_diff

    ela_im = ImageEnhance.Brightness(ela_im).enhance(scale)
    return ela_im

dataset = pd.read_csv('MICC2000.csv')

X = []
Y = []

for index, row in dataset.iterrows():
    X.append(array(convert_to_ela_image(row[0], 90).resize((128, 128))).flatten() / 255.0)
    Y.append(row[1])

X = np.array(X)
Y = to_categorical(Y, 2)

X = X.reshape(-1, 128, 128, 3)

X_train, X_val, Y_train, Y_val = train_test_split(X, Y, test_size = 0.50, random_state=5 , shuffle=True)


model = Sequential()



model.add(Conv2D(filters = 32, kernel_size = (5,5),padding = 'valid', activation ='relu', input_shape = (128,128,3)))
model.add(Conv2D(filters = 64, kernel_size = (5,5), strides=(2,2) ,padding = 'valid', activation ='relu'))
model.add(Conv2D(filters = 128, kernel_size = (5,5),padding = 'valid', activation ='relu'))
model.add(Conv2D(filters = 256, kernel_size = (5,5),strides=(2,2),padding = 'valid', activation ='relu'))
model.add(Dropout(0.25))


model.add(Flatten())


model.add(Dense(256, activation = "relu"))
model.add(Dropout(0.5))
model.add(Dense(2, activation = "softmax"))

model.summary()

How i can change in this code so i can add spp layer on it?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.