Error after merging two Deep Learning models VGG16 and ResNet50

I have merged two different models namely VGG16 and ResNet50 and given the outputs of the two models as input to another model. I have checked the Layers graph is correct. Before merging the code was running perfectly fine giving correct outputs. I am getting an error: "ValueError: Shapes (None, None) and (None, 7, 7, 3) are incompatible" on the line 6 ValueError Traceback (most recent call last) <ipython-input-36-620554d0106f> in <module>() 4 epochs = 200, 5 validation_data = validation_generator, ----> …
Category: Data Science

When using a model like VGG16 as a classifier within Faster RCNN, does Faster RCNN then use 2 CNNs in total?

Im currently doing a project about CNN's but im quite confused because they can be used to classify and to extract features. According to the Faster RCNN paper, it uses a ResNet backbone. I have also seen that you can use for example VGG16 with Faster RCNN to classify,lets say types of vegetables. Does it mean that when I implement it this way, it uses 2 cnn's in total, namely resnet for extracting features of ROI's and then VGG for …
Category: Data Science

CNN: visualize a model using its description

i created a Resnet model, which i want to show in a presentation, but i don't know how to visualize what i have done? Is there a tool or something to get a graphic from the description of my model. Here you can see how my description looks (had to cut a part out of it as i were using too many characters): model is : ResNet( (conv1): Conv2d(3, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False) (bn1): BatchNorm2d(64, eps=1e-05, …
Category: Data Science

PyTorch resnet bad tensor dimensions

I'm trying to setup a face detection/recognition pipeline using Pytorch. I load the image using opencv image = cv2.imread('...') I load the mtcnn face detection and resnet face recognition models self.mtcnn = MTCNN(keep_all=True, device=self.device) self.resnet = InceptionResnetV1(pretrained='vggface2').eval() Then I run detection and recognition cropped = detector.mtcnn(image) detector.resnet(cropped.unsqueeze(0)) And get this error Expected 4-dimensional input for 4-dimensional weight [32, 3, 3, 3], but got 5-dimensional input of size [1, 1, 3, 160, 160] instead I also tried resizing the image to …
Category: Data Science

Empty model when using ResNet50 for transfer learning

I am working on transfer learning using ResNet50. I have a code which was working four months before in Google Colab but when I checked it now, it is no longer working. I am not sure whether this is caused by an updates of the packages I am using. from keras.models import Sequential from keras.layers import Dense, Dropout, Flatten, Activation from keras.layers import Conv2D, MaxPooling2D from keras.models import Model from keras.applications.resnet50 import ResNet50 restnet = ResNet50(include_top=False, weights='imagenet', input_shape=(64,64,3)) output = …
Category: Data Science

How to utilize the multilabel calssification labels during the course of training

I have a data set that consists of images. I am trying to perform multi-label classification on this data set. But the training labels consist of too many labels which are CSV file format. Now I find it a little difficult on how to utilizes these labels in CSV file during the course of training. I read some blogs; the author suggested performing one-hot encoding on these labels. Now I am stuck on how to proceed. Below is the screenshot …
Category: Data Science

Deep Learning Classification Model for data with time dimension

I know it might be a generic question but I would still appreciate some feedback. So I have a dataset with 4 dimensions (time, x, y, color). Where I have a total of 24000 records each with (5, 188, 188, 3) this dimension where I have a 5-time dimension which is like 5 different time intervals each at 15 minutes difference. Now I have to build a model for binary classification from the image. So initially I used Resnet with …
Category: Data Science

What should be the input shape for convLSTM if ResNet-50 is applied before?

I have a video dataset, extracted all its frames, and applied ResNet-50 to extract features from all frames. ResNet-50 provides feature map of (2534, 7, 7, 2048), 2534 are the number of frames. Now I have to apply convLSTM to train the model, but what should be its input shape. Regards
Category: Data Science

Transfer Learning on Resnets/VGGs -- Validation accuracy can never be over 75%

I am trying to classify skin cancer images into two categories -- malignant and benign. Literatures suggest that using pre-trained resnet/vgg network achieves more than 90% accuracy. However, with my dataset, whatever I try, the validation accuracy can never be greater than 75%. I am using a well-balanced dataset where there are 500 malignant and 500 benign images in the training dataset. The number of images is on a smaller end; however, the fact that I am using transfer learning …
Category: Data Science

Choosing a set of CNNs for paper

There are so many CNNs out there and I am trying to do a comparison between some of them in my paper. Which networks should I include? Resnet, VGG, and Inception are obvious, but I would like three or four others. Which ones should I choose? There are so many variations out there like Xception, resnext, and ... that I am confused. Which of these networks are most used in the academic papers?
Category: Data Science

what is the largest network used for image recognition/segmentation?

What is the largest network (in number of params and layers) considered in the literature for image recognition/segmentation task? I am in particular interested in ResNet architectures. Any recommendation for literature is appreciated. For natural language processing, the largest models are of order of billions, such as Megatron-LM, or DeepSeed with Zero. Is this also the case for image-classification?
Category: Data Science

Is it possible the model be better on a few epochs rather than hundreds of epochs?

I have very interesting experience in my CNN binary image classification. Do you think the result is by chance or there is a logic behind it? I used InceptionV3 transfer with softmax (I know you will say why not ReLU) but it is what I did. I trained on 100 epochs. But the result was terrible. from the training process I noticed in the 12-th epochs the result is excellent (both train accuracy and validation accuracy ). So I trained …
Category: Data Science

ResNet50 Overfitting even after Dropout

I have a dataset with 60k images in three categories i.e nude, sexy, and safe (each having 30k Images). I am using ResNet50 and observed that the training accuracy and validation accuracy is ok (around 0.82-0.88) although, the validation loss fluctuates a bit. But, on testing, the precision and recall are too low for each of the classes, around(0.30, 0.25) I have tried the following things: Adding DropOut: I have tried adding DropOut with different rates (0.2 - 0.8) Freezing …
Category: Data Science

I'm trying to build a ResNet 18 model for Cifar 10 dataset, but I'm not able to fit the data dimension

At avergae pooling after the ConvNet, the error is displayed as the dimensions cannot be negative because the shape the previous output layer is 1,1,512 and on this the maxpooling cannot be done. Is it something that i did wrong in the architecture design? def identity_block2(X,f,filters): f1,f2 = filters X_init = X X = Conv2D(f1,(3,3),strides=(1,1),padding='same')(X) X = BatchNormalization()(X) X = Activation('relu')(X) X = Conv2D(f1,(3,3),strides=(1,1),padding='same')(X) X = BatchNormalization()(X) X = Activation('relu')(X) X = Add()([X,X_init]) X = Activation('relu')(X) return X def conv_block2(X,f,filters,s=2): …
Category: Data Science

Xavier initialisation vs He initialisation

After reading the famous paper, Delving Deep into Rectifiers: Surpassing Human-Level Performance on ImageNet Classification, I understand two things:- He initilization borrows on the benefits of Xavier initialization except that the latter expected a linear activation and the prior accounts for ReLU non-linear activation. Infact they differ just by a factor of sqrt(2). All the fuss is about layers having 0 mean and 1 std achieved by Xavier initialization but when ReLU is used the negative is clipped and so …
Category: Data Science

Keras Model question for Pre trained model extension

I want to add a few more layers to a Resnet50 model and my question is - do I need to compile it and train it on new data or can I just use it as it is? Will it just give me the Resnet50 results? Here is what I am trying: def base_model(): resnet = resnet50.ResNet50(weights="imagenet", include_top=False) x = resnet.output x = Conv2D(128, (3, 3), activation='relu',padding='same')(x) x = Conv2D(128, (3, 3), activation='relu',padding='same')(x) x = MaxPooling2D((2, 2), strides=(2, 2))(x) x …
Category: Data Science

CNN, sudden drop of accuracy between epochs, steps for improvements?

I am working on a text recognition problem, in which essentially I am trying to read images similar to captchas. I implemented a ResNet in keras and I run it on colab with gpu. Because I cannot upload a million pictures I have created a loop where I train the model in a subset (10000 pics) save them and then load the next subset of pics and continue training. I did some hyper tuning by trial and error but mostly …
Category: Data Science

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.