deep-learning

How do I output confidence level in Resnet 50 classification?

纵饮孤独 提交于 2020-07-16 01:35:07
问题 I trained Resnet-50 classification network to classify my objects and I use the following code to evaluate the network. from tensorflow.keras.models import load_model import cv2 import numpy as np import os class_names = ["x", "y", "b","g", "xx", "yy", "bb","gg", "xyz","xzy","yy"] model = load_model('transfer_resnet.h5') model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy']) imgg = cv2.imread('/path to image/a1.jpg') img = cv2.resize(imgg,(224,224)) img = np

'tuple' object has no attribute 'rank' when fit keras model with custom generator

牧云@^-^@ 提交于 2020-07-10 10:26:39
问题 The bounty expires in 5 days . Answers to this question are eligible for a +50 reputation bounty. feeeper wants to draw more attention to this question. I want to build neural network with two inputs: for image data and for numeric data. So I wrote custom data generator for that. train and validation dataframes contain 11 columns: image_name — path to the image; 9 numeric features; target — class for the item (last column). The code presented below (based on answer): target_size = (224, 224)

'tuple' object has no attribute 'rank' when fit keras model with custom generator

我与影子孤独终老i 提交于 2020-07-10 10:26:08
问题 The bounty expires in 5 days . Answers to this question are eligible for a +50 reputation bounty. feeeper wants to draw more attention to this question. I want to build neural network with two inputs: for image data and for numeric data. So I wrote custom data generator for that. train and validation dataframes contain 11 columns: image_name — path to the image; 9 numeric features; target — class for the item (last column). The code presented below (based on answer): target_size = (224, 224)

ValueError: Found array with dim 3. Estimator expected <= 2. ( Keras, Sklearn)

偶尔善良 提交于 2020-07-10 08:46:07
问题 I'm trying to train a model using this code from the tutorial of Adrian Rosebrock using my custom dataset to detect the emotion facial expression. INIT_LR = 1e-3 EPOCHS = 30 BS = 10 print("[INFO] loading images...") imagePaths = list(paths.list_images(args["dataset"])) data = [] labels = [] for imagePath in imagePaths: # extract the class label from the filename label = imagePath.split(os.path.sep)[-2] image = cv2.imread(imagePath) image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) image = cv2

How to use repeat() function when building data in Keras?

假装没事ソ 提交于 2020-07-09 05:56:31
问题 I am training a binary classifier on a dataset of cats and dogs: Total Dataset: 10000 images Training Dataset: 8000 images Validation/Test Dataset: 2000 images The Jupyter notebook code: # Part 2 - Fitting the CNN to the images train_datagen = ImageDataGenerator(rescale = 1./255, shear_range = 0.2, zoom_range = 0.2, horizontal_flip = True) test_datagen = ImageDataGenerator(rescale = 1./255) training_set = train_datagen.flow_from_directory('dataset/training_set', target_size = (64, 64), batch

How to use repeat() function when building data in Keras?

淺唱寂寞╮ 提交于 2020-07-09 05:56:21
问题 I am training a binary classifier on a dataset of cats and dogs: Total Dataset: 10000 images Training Dataset: 8000 images Validation/Test Dataset: 2000 images The Jupyter notebook code: # Part 2 - Fitting the CNN to the images train_datagen = ImageDataGenerator(rescale = 1./255, shear_range = 0.2, zoom_range = 0.2, horizontal_flip = True) test_datagen = ImageDataGenerator(rescale = 1./255) training_set = train_datagen.flow_from_directory('dataset/training_set', target_size = (64, 64), batch

ValueError: expected 2D or 3D input (got 1D input) PyTorch

生来就可爱ヽ(ⅴ<●) 提交于 2020-07-09 05:25:04
问题 class VAE(torch.nn.Module): def __init__(self, input_size, hidden_sizes, batch_size): super(VAE, self).__init__() self.input_size = input_size self.hidden_sizes = hidden_sizes self.batch_size = batch_size self.fc = torch.nn.Linear(input_size, hidden_sizes[0]) self.BN = torch.nn.BatchNorm1d(hidden_sizes[0]) self.fc1 = torch.nn.Linear(hidden_sizes[0], hidden_sizes[1]) self.BN1 = torch.nn.BatchNorm1d(hidden_sizes[1]) self.fc2 = torch.nn.Linear(hidden_sizes[1], hidden_sizes[2]) self.BN2 = torch

ValueError: expected 2D or 3D input (got 1D input) PyTorch

给你一囗甜甜゛ 提交于 2020-07-09 05:24:30
问题 class VAE(torch.nn.Module): def __init__(self, input_size, hidden_sizes, batch_size): super(VAE, self).__init__() self.input_size = input_size self.hidden_sizes = hidden_sizes self.batch_size = batch_size self.fc = torch.nn.Linear(input_size, hidden_sizes[0]) self.BN = torch.nn.BatchNorm1d(hidden_sizes[0]) self.fc1 = torch.nn.Linear(hidden_sizes[0], hidden_sizes[1]) self.BN1 = torch.nn.BatchNorm1d(hidden_sizes[1]) self.fc2 = torch.nn.Linear(hidden_sizes[1], hidden_sizes[2]) self.BN2 = torch

Error with net.forward() in OpenCV EAST text detector in pycharm

心不动则不痛 提交于 2020-07-09 04:11:34
问题 I am trying EAST text detector in pycharm but there is an error at line. (scores, geometry) = net.forward(layerNames) cv2.error: OpenCV(4.1.0) C:\projects\opencv-python\opencv\modules\dnn\src\layers\concat_layer.cpp:95: error: (-201:Incorrect size of input array) Inconsistent shape for ConcatLayer in function 'cv::dnn::ConcatLayerImpl::getMemoryShapes' CODE: print("[INFO] loading EAST text detector...") name = 'Pictures/non crop/maths soln analysis 4_89.jpg' image = cv2.imread(name, 1) (H, W)

Invalid argument error (incompatible shapes) with TensorFlow

妖精的绣舞 提交于 2020-07-08 22:43:14
问题 I'm trying to train a simple network with tensorflow for the MNIST dataset. At the moment though it is not working. It is basically a modified version of the example given on the TensorFlow website. I just changed a couple lines and removed a layer to see what happened. Here is my code: #!/usr/bin/python import input_data import tensorflow as tf #MNIST dataset def weight_variable(shape): initial=tf.truncated_normal(shape,stddev=0.1) return tf.Variable(initial) def bias_variable(shape):