Giter VIP home page Giter VIP logo

cv-tricks.com's People

Contributors

altutimus avatar anshu-ak avatar legolas123 avatar sankit1 avatar shashwathiregoudar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cv-tricks.com's Issues

TypeError: Expected int32, got list containing Tensors of type '_Message' instead

In the folder, Tensorflow-tutorials/Tensorflow-slim-run-prediction when I run python run_inference_on_v3.py http://cv-tricks.com/wp-content/uploads/2017/03/pexels-photo-280207.jpeg
To run the prediction for the model inception_v3 as per the blog post http://cv-tricks.com/tensorflow-tutorial/understanding-alexnet-resnet-squeezenetand-running-on-tensorflow/, I get the following error:

TypeError: Expected int32, got list containing Tensors of type '_Message' instead.
Tensorflow version: 1.1

Which version of keras?

I'm running 2.2.4..

  File "./1_vgg16_pretrain.py", line 1, in <module>
    from network import VGG16
ModuleNotFoundError: No module named 'network'

hey am using ur code on python 2.7 but am getting following error

my issue is in imagnet.py where my tring to access url am getting the url error as follows
filename, _ = urllib.urlretrieve(synset_url,"imagenet_lsvrc_2015_synsets.txt")
File "/usr/lib/python2.7/urllib.py", line 94, in urlretrieve
return _urlopener.retrieve(url, filename, reporthook, data)
File "/usr/lib/python2.7/urllib.py", line 240, in retrieve
fp = self.open(url, data)
and my code is
base_url = 'https://github.com/tensorflow/models/tree/master/research/inception/inception/data'
synset_url = 'https://github.com/tensorflow/models/tree/master/research/inception/inception/data/imagenet_lsvrc_2015_synsets.txt'.format(base_url)
synset_to_human_url = 'https://github.com/tensorflow/models/tree/master/research/inception/inception/data/imagenet_metadata.txt'.format(base_url)

filename, _ = urllib.urlretrieve(synset_url,"imagenet_lsvrc_2015_synsets.txt")
synset_list = [s.strip() for s in open(filename).readlines()]
num_synsets_in_ilsvrc = len(synset_list)
assert num_synsets_in_ilsvrc == 1000

filename, _ = urllib.urlretrieve(synset_to_human_url,"imagenet_metadata.txt")
synset_to_human_list = open(filename).readlines()
num_synsets_in_all_imagenet = len(synset_to_human_list)
assert num_synsets_in_all_imagenet == 21842
please help me am totally frustraed bu this issue

Help porting to Cpp

Hello,
Thank you for sharing this excellent work. I am trying to port the Crop Layer to cpp.
I am not very familiar with Python, can you elaborate on the meaning of this Python operation :

return [inputs[0][:,:,self.ystart:self.yend,self.xstart:self.xend]]

Is inputs[0] a 4D cube and I want to take only the sub-cube delimited by x and y indexes?
Cheers,
Renaud

Dataset comments

Hi,
Thanks for putting this up on github. It got me started with tensorflow.
However some comments;
I think the dataset shows a lot of underfitting. I get a validation score of 0.5 at end, or even below.
I connected tensorboard and the learning graph shows classic underfitting signs (straight learning rate).
Perhaps it doesn't help that the images have wide ranging aspect ratios?
I tried to insert horizontal flipped images as well, but it doesn't help that much.

cannot connect to X server error

Getting an error while running the code.

python3 run_pose.py --input sample.jpg --proto pose/mpi/pose_deploy_linevec_faster_4_stages.prototxt --model pose/mpi/pose_iter_160000.caffemodel --dataset MPI
time is 2.5539000034332275
: cannot connect to X server

Adding data augmentation

Hello,

I am trying to add data augmentation to increase the number of images I have to at least 2,000 images per class. How can I achieve this?
Any help will be really appreciated

Edge detection results in 'getMemoryShapes' error

Hi!

I get the following error when I want to run edge detection on an image. Any idea why I get that specific dnn layer error?

cv2.error: OpenCV(4.6.0) /io/opencv/modules/dnn/src/layers/convolution_layer.cpp:377: error: (-215:Assertion failed) !blobs.empty() || inputs.size() > 1 in function 'getMemoryShapes'

Image classifier CNN - Getting error!

Hi,

I am getting the following error when using code from your repository for Image classifier CNN:

Traceback (most recent call last):
  File "E:/Machine Learning/TensorFlow/Tutorials & Practice/CV Tricks/train.py", line 292, in <module>
    optimize(num_iterations=3000)
  File "E:/Machine Learning/TensorFlow/Tutorials & Practice/CV Tricks/train.py", line 261, in optimize
    x_batch, y_true_batch, _, cls_batch = data.train.next_batch(train_batch_size)
  File "E:\Machine Learning\TensorFlow\Tutorials & Practice\CV Tricks\dataset.py", line 117, in next_batch
    assert batch_size <= self._num_examples
AssertionError

I am not sure what am I missing, Can you help me please?

OS: Windows 10
IDE: Pycharm
Python: Python 3.5.2 :: Anaconda 4.1.1 (64-bit)

xnornet_plusplus

Quantization code is never called since it is commented. Binary convolution and activation is already implemented. Do I need to uncomment them (a few of them are given below)? During the forward pass I always quantize the weights and activation. Why do I need "quantization.py" ?


# if args.quantize:
    #     global bin_op
    #     bin_op = quantization.Binarize(model)

# if args.quantize:
        #     bin_op.restore()
        #     bin_op.updateBinaryGradWeight()

if I uncomment them, I get the following error.

  File "main2.py", line 88, in main
    bin_op = quantization.Binarize(model)
  File "/media/mmrg/inci/files/quantization.py", line 33, in __init__
    param_grp_1.append(m.conv.weight)
  File "/home/mmrg/anaconda3/envs/pytorch_mmdet/lib/python3.7/site-packages/torch/nn/modules/module.py", line 779, in __getattr__
    type(self).__name__, name))
torch.nn.modules.module.ModuleAttributeError: 'BinConv2d' object has no attribute 'conv'

Maybe a better place for saving?

I run the code of image-classifier, it's a little slow in my laptop.
My computer:
Intel Core i7 6700-HQ
NVIDIA GeForce GTX960M
run in GPU
Then I try move the save code into the if rather than out of if
It become much faster.....
And I think it is useless to do so much save and waste time in IO
Maybe this would be helpful if you want to accelerate your code

Tensorflow-tutorials/tutorial-2-image-classifier/train.py error

~/git/cv-tricks.com/Tensorflow-tutorials/tutorial-2-image-classifier$ python train.py --train training_data/ --val testing_data/ --num_classes 2
Going to read training images
Now going to read dogs files (Index: 0)
Now going to read cats files (Index: 1)
Complete reading input data. Will Now print a snippet of it
Number of files in Training-set: 800
Number of files in Validation-set: 200
WARNING:tensorflow:From train.py:44: calling argmax (from tensorflow.python.ops.math_ops) with dimension is deprecated and will be removed in a future version.
Instructions for updating:
Use the axis argument instead
WARNING:tensorflow:From train.py:160: softmax_cross_entropy_with_logits (from tensorflow.python.ops.nn_ops) is deprecated and will be removed in a future version.
Instructions for updating:

Future major versions of TensorFlow will allow gradients to flow
into the labels input on backprop by default.

See @{tf.nn.softmax_cross_entropy_with_logits_v2}.

Training Epoch 1 --- Training Accuracy: 50.0%, Validation Accuracy: 43.8%, Validation Loss: 0.705
2018-08-17 16:52:14.024307: W tensorflow/core/framework/op_kernel.cc:1275] OP_REQUIRES failed at save_restore_v2_ops.cc:109 : Not found: ; No such file or directory
Traceback (most recent call last):
File "train.py", line 206, in
train(num_iteration=3000)
File "train.py", line 201, in train
saver.save(session, 'dogs-cats-model')
File "/home/Wukong2/l00176142/.local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1637, in save
raise exc
ValueError: Parent directory of dogs-cats-model doesn't exist, can't save.

Issue in training the 'tutorial-2-image-classifier'

Hi Ankit,

I am new to image classification. I cloned your repository and tried to run the code train.py in my system. I just keep getting an error message saying:
"2018-06-17 00:19:55.817737: W tensorflow/core/framework/op_kernel.cc:1318] OP_REQUIRES failed at save_restore_v2_ops.cc:109 : Not found: ; No such file or directory
Traceback (most recent call last):
File "train.py", line 206, in
train(num_iteration=3000)
File "train.py", line 201, in train
saver.save(session, 'dogs-cats-model')
File "/Users/z001txn/anaconda/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1720, in save
raise exc
ValueError: Parent directory of dogs-cats-model doesn't exist, can't save."

I think the problem is in saving the model but I am not able to figure out how to solve it. Can you please help me out here.

Thanks,
Aishwarya

predict

Hi!
In predict.py I am always getting the same output even though the image are of cats(for example ), the probability is very less for that image.

not able to retrieve the image for prediction

I am not able to get the image_path correctly.
The output is showing ---------------------list index out of range by running your code predict.py
dir_path = os.path.dirname(os.path.abspath(__file__)) image_path=sys.argv[1]

due to which image = cv2.resize(image, (image_size, image_size),0,0, cv2.INTER_LINEAR) is also not working.

output of dir_path D:\WORKSPACE\Deep_learning\others\cv_tricks.com_new\cv-tricks.com\Tensorflow-tutorials\tutorial-2-image-classifier
output of image_path D:/WORKSPACE/Deep_learning/others/cv_tricks.com_new/cv-tricks.com/Tensorflow-tutorials/tutorial-2-image-classifier/predict.py

how can this be solved?

training cnn network

i have built a cnn network which im trying to train with my own data. but when i run the code i get the next error:

File "C:/linear regression/new_net.py", line 92, in <module>

ValueError: Cannot feed value of shape (500, 99999) for Tensor 'X:0', which has shape '(500, 4392)'

and i dont know what value i need to fix. my data is built of 100,000 rows on 4392 column. i reshape each row to 61*72 pixels which means i have 100,000 images. i take 80,000 to the training and 20,000 to the test. and using batch size of 500. i dont know what is wrong with the code if someone can help please!!!

here is my code:

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import csv
import time
import os
import urllib

import numpy as np
import tensorflow as tf
#input images- chek if i need the transpose command
data_in = np.transpose(np.loadtxt(open("images.csv"), delimiter=","))

images_training="images.csv"

train_X=data_in[0:80000,:]
test_X=data_in[80001:100000,:]

test_images=test_X[:,1]
test_labels=test_X[:,0]

n = train_X.shape[1]
l = test_X.shape[0]

n_epochs = 10
batch_size = 500
regions=50
height = 61
width = 72
channels = 1

n_inputs = height * width #4392

X = tf.placeholder(tf.float32, shape=[batch_size, n_inputs], name="X")
X_reshaped = tf.reshape(X, shape=[-1, height, width, channels])
y = tf.placeholder(tf.int32, shape=[None], name="y")
labels=tf.placeholder(tf.int32, shape=[batch_size], name="labels")

conv1 = tf.layers.conv2d(inputs=X_reshaped,filters=32,kernel_size=[5, 
5],padding="same",activation=tf.nn.relu)

pool1 = tf.layers.max_pooling2d(inputs=conv1, pool_size=[2, 2], strides=2) 
#need to change pool size and strides according to image pixels

conv2 = tf.layers.conv2d(inputs=pool1,filters=64,kernel_size=[5, 
5],padding="same",activation=tf.nn.relu)

pool2 = tf.layers.max_pooling2d(inputs=conv2, pool_size=[2, 2], 
strides=2)#need to change pool size and strides according to image pixels

pool2_flat = tf.reshape(pool2, [-1, 15 * 18 * 64]) #change it according to 
the pooling layers size:[batch_size,18432]

dense = tf.layers.dense(inputs=pool2_flat, units=1024, 
activation=tf.nn.relu)

# Add dropout operation; 0.6 probability that element will be kept
dropout = tf.layers.dropout(inputs=dense, rate=0.4)

# Logits layer
# Input Tensor Shape: [batch_size, 1024]
# Output Tensor Shape: [batch_size, 50]
logits = tf.layers.dense(inputs=dropout, units=50) #size=[batch_size,50]

predictions = {
  # Generate predictions (for PREDICT and EVAL mode)
  "classes": tf.argmax(input=logits, axis=1),
  # Add `sigmoid_tensor` to the graph. It is used for PREDICT and by the
  # `logging_hook`.
  "probabilities": tf.nn.sigmoid(logits, name="sigmoid_tensor")}


 onehot_labels = tf.one_hot(indices=tf.cast(labels, tf.int32), depth=50)
 #loss = tf.losses.sigmoid_cross_entropy(multi_class_labels=labels, 
 logits=logits)
 loss = tf.losses.sigmoid_cross_entropy(onehot_labels, logits=logits) 


optimizer = tf.train.GradientDescentOptimizer(learning_rate=0.001)
train_op = optimizer.minimize(loss=loss, 
global_step=tf.train.get_global_step())

# Initializing the variables
init = tf.global_variables_initializer()

with tf.Session() as sess:
     sess.run(init)
     for epoch in range(n_epochs):
     for iteration in range(len(train_X) // batch_size):
          # this cycle is for dividing step by step the heavy work of each neuron
          X_batch = train_X[iteration * batch_size:iteration * batch_size + batch_size, 1:]
          y_batch = train_X[iteration * batch_size:iteration * batch_size + batch_size, 0]
          sess.run(optimizer,feed_dict={X:X_batch, y:y_batch})
     sess.run(train_op, feed_dict={X: X_batch, y: y_batch})
     acc_train =accuracy.eval(feed_dict={X: X_batch, y: y_batch})
     acc_test  =accuracy.eval(feed_dict={X: test_images, y: test_labels})
     print("Epoch:", epoch + 1, "Train accuracy:", acc_train, "test accuracy:", acc_test)
     print("Optimization Finished!")

in addition i dont understand why python takes my data as 99,999 and not 100,000.

thank you!!!

edge detection only caffe ?

is there a edge detection model which is not in caffe ?
as caffe merged into pytorch, it's almost not used anymore. instaling caffe "just for that" is too bad.

dnn_registerLayer not found

Traceback (most recent call last):
  File "edge.py", line 42, in <module>
    cv.dnn_registerLayer('Crop', CropLayer)
AttributeError: module 'cv2.cv2' has no attribute 'dnn_registerLayer'

Error when running train.py in tutorial-2-image-classifier

WARNING:tensorflow:From train.py:43: calling argmax (from tensorflow.python.ops.math_ops) with dimension is deprecated and will be removed in a future version.
Instructions for updating:
Use the axis argument instead
WARNING:tensorflow:From train.py:156: calling argmax (from tensorflow.python.ops.math_ops) with dimension is deprecated and will be removed in a future version.
Instructions for updating:
Use the axis argument instead
Going to read training images
Now going to read dogs files (Index: 0)
Now going to read cats files (Index: 1)
Complete reading input data. Will Now print a snippet of it
Number of files in Training-set: 800
Number of files in Validation-set: 200
Training Epoch 1 --- Training Accuracy: 50.0%, Validation Accuracy: 43.8%, Validation Loss: 0.703
Traceback (most recent call last):
File "C:\Users\USER\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\client\session.py", line 1327, in _do_call
return fn(*args)
File "C:\Users\USER\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\client\session.py", line 1306, in _run_fn
status, run_metadata)
File "C:\Users\USER\AppData\Local\Programs\Python\Python36\lib\contextlib.py", line 89, in exit
next(self.gen)
File "C:\Users\USER\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.NotFoundError: Failed to create a directory:
[[Node: save/SaveV2 = SaveV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_arg_save/Const_0_0, save/SaveV2/tensor_names, save/SaveV2/shape_and_slices, Variable, Variable/Adam, Variable/Adam_1, Variable_1, Variable_1/Adam, Variable_1/Adam_1, Variable_2, Variable_2/Adam, Variable_2/Adam_1, Variable_3, Variable_3/Adam, Variable_3/Adam_1, Variable_4, Variable_4/Adam, Variable_4/Adam_1, Variable_5, Variable_5/Adam, Variable_5/Adam_1, Variable_6, Variable_6/Adam, Variable_6/Adam_1, Variable_7, Variable_7/Adam, Variable_7/Adam_1, Variable_8, Variable_8/Adam, Variable_8/Adam_1, Variable_9, Variable_9/Adam, Variable_9/Adam_1, beta1_power, beta2_power)]]

How to interpret the prediction result?

I am getting the below outputs for Cat and Dog images respectively. how do i interpret it?

run : python predict.py testing_data/cats/cat.1041.jpg
output: [[3.3456912e-05 9.9996650e-01]]

run: python predict.py testing_data/dogs/dog.1000.jpg
output: [[5.817143e-05 9.999418e-01]]

Cats dogs prediction

I did the training, it had 95% confidence.

Somehow my prediction is always the same, even when giving a different image to test (changing cats to dogs):

[[0.5592177  0.44078225]]
[[0.5690457  0.43095428]]

Anyway to debug or help out what is going wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.