Can we use Keras model's accuracy metric for Image Captioning model?

Issue Kindly consider the following line of code. model.compile(loss=’categorical_crossentropy’, optimizer=’adam’,metrics=[‘accuracy’]) I am allowed to use metrics=[‘accuracy’] for my Image Captioning model. My model has been defined as follows: inputs1 = Input(shape=(2048,)) fe1 = Dropout(0.2)(inputs1) fe1=BatchNormalization()(fe1) fe2 = Dense(256, activation=’relu’)(fe1) inputs2

Continue reading

how to get history['val_accuracy'] from ImageDataGenerator

Issue I’m using keras.preprocessing.image.ImageDataGenerator When i fed it to model.fit like that history = model.fit( train_data_gen, epochs=EPOCHS, steps_per_epoch=steps_per_epoch, validation_data=val_data_gen, validation_freq=validation_freq, callbacks=[EarlyStopping(monitor=’val_accuracy’, patience=2)] ) it works fine, but there is no actual validation data, so my callback doesn’t work, as well

Continue reading

Error: (-215:Assertion failed) npoints > 0 while working with contours using OpenCV

Issue When I run this code: import cv2 image = cv2.imread(‘screenshoot10.jpg’) cv2.imshow(‘input image’, image) gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) edged = cv2.Canny(gray, 30, 200) cv2.imshow(‘canny edges’, edged) _, contours = cv2.findContours(edged, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) cv2.imshow(‘canny edges after contouring’, edged) print(contours) print(‘Numbers of

Continue reading

What purpose does .astype("uint8") have here?

Issue (score,diff)= structural_similarity(original_gray,tempered_gray,full=True) diff = (diff*255).astype("uint8") print("SSIM:{}".format(score)) The above mentioned code is a snippet from a program that matches two images using their SSIM score. What I don’t understand here is the function of .astype("uint8"), and why are we multiplying

Continue reading

Removing Horizontal Lines in image (OpenCV, Python, Matplotlib)

Issue Using the following code I can remove horizontal lines in images. See result below. import cv2 from matplotlib import pyplot as plt img = cv2.imread(‘image.png’,0) laplacian = cv2.Laplacian(img,cv2.CV_64F) sobelx = cv2.Sobel(img,cv2.CV_64F,1,0,ksize=5) plt.subplot(2,2,1),plt.imshow(img,cmap = ‘gray’) plt.title(‘Original’), plt.xticks([]), plt.yticks([]) plt.subplot(2,2,2),plt.imshow(laplacian,cmap =

Continue reading

Find near duplicate and faked images

Issue I am using Perceptual hashing technique to find near-duplicate and exact-duplicate images. The code is working perfectly for finding exact-duplicate images. However, finding near-duplicate and slightly modified images seems to be difficult. As the difference score between their hashing

Continue reading