GithubHelp home page GithubHelp logo

Comments (13)

Horea94 avatar Horea94 commented on August 23, 2024

The commented line #saver.restore(sess, ckpt.model_checkpoint_path) is responsible for loading the saved model . Without it , the script does not load anything and tests a model that was not trained, so the result is 0% accuracy.

from fruit-images-dataset.

sainisanjay avatar sainisanjay commented on August 23, 2024

Okay, i have commented out saver.restore(sess, ckpt.model_checkpoint_path) from the fruit_test_net.py test script. I am getting following error, may i know how to resolve this.

File "network/fruit_test_net.py", line 82, in <module>
  saver.restore(sess, ckpt.model_checkpoint_path)
AttributeError: 'NoneType' object has no attribute 'model_checkpoint_path'

from fruit-images-dataset.

Horea94 avatar Horea94 commented on August 23, 2024

It seems that the ckpt object is not properly initialized by the
ckpt = tf.train.get_checkpoint_state(checkpoint_dir) line
Did you ensure that the files resulted from the fruit_train_net.py script are all in the folder pointed by the "checkpoint_dir" variable?

from fruit-images-dataset.

sainisanjay avatar sainisanjay commented on August 23, 2024

Yes i can see in the fruit_models folder which is created during training. The following 5 files available

/fruit_models/checkpoint   (381 bytes)
/fruit_models/graph.pbtxt  (284.3 kb)
/fruit_models/model.ckpt.data-00000-of-00001 (83.7 MB)
/fruit_models/model.ckpt.index  (1.5 kb)
/fruit_models/model.ckpt.meta  (145.2 kb)

Even i tried by doing fresh training:

time: 21.5204 step: 1 loss: 4.0560 accuracy: 0.0600
time: 117.3164 step: 500 loss: 0.1250 accuracy: 0.9700
time: 118.0530 step: 1000 loss: 0.0824 accuracy: 0.9700
time: 118.3158 step: 1500 loss: 0.0165 accuracy: 1.0000
time: 119.6045 step: 2000 loss: 0.0233 accuracy: 0.9900
time: 119.7569 step: 2500 loss: 0.0021 accuracy: 1.0000
time: 116.7455 step: 3000 loss: 0.0091 accuracy: 1.0000
time: 111.8938 step: 3500 loss: 0.0205 accuracy: 1.0000
time: 110.3421 step: 4000 loss: 0.0279 accuracy: 0.9800
time: 108.9707 step: 4500 loss: 0.0203 accuracy: 0.9900
time: 109.2560 step: 5000 loss: 0.0210 accuracy: 0.9800
time: 106.7813 step: 5500 loss: 0.0011 accuracy: 1.0000
time: 105.4543 step: 6000 loss: 0.0025 accuracy: 1.0000
time: 108.1577 step: 6500 loss: 0.0763 accuracy: 0.9600
time: 109.1269 step: 7000 loss: 0.0107 accuracy: 0.9900
time: 108.0914 step: 7500 loss: 0.0218 accuracy: 0.9800
time: 114.1078 step: 8000 loss: 0.0116 accuracy: 1.0000
time: 119.6590 step: 8500 loss: 0.0094 accuracy: 1.0000
time: 119.5516 step: 9000 loss: 0.0110 accuracy: 1.0000
time: 117.5011 step: 9500 loss: 0.0110 accuracy: 0.9900
time: 113.2210 step: 10000 loss: 0.0008 accuracy: 1.0000
time: 106.1483 step: 10500 loss: 0.0062 accuracy: 1.0000
time: 106.7721 step: 11000 loss: 0.0160 accuracy: 0.9800
time: 107.3277 step: 11500 loss: 0.0050 accuracy: 1.0000
time: 107.9952 step: 12000 loss: 0.0005 accuracy: 1.0000
time: 117.4758 step: 12500 loss: 0.0023 accuracy: 1.0000

But still same problem during testing

from fruit-images-dataset.

Horea94 avatar Horea94 commented on August 23, 2024

What is the value of the "checkpoint_dir" variable when it executes
ckpt = tf.train.get_checkpoint_state(checkpoint_dir) ?
Is it the same as the path to the folder with those 5 files?

from fruit-images-dataset.

sainisanjay avatar sainisanjay commented on August 23, 2024

Yes its has same.

from fruit-images-dataset.

sainisanjay avatar sainisanjay commented on August 23, 2024

I have resolved that issues but accuracy is coming always 0

Predicted 86 out of 100; partial accuracy 0.0000
Predicted 181 out of 200; partial accuracy 0.0000
Predicted 277 out of 300; partial accuracy 0.0000
Predicted 367 out of 400; partial accuracy 0.0000
Predicted 465 out of 500; partial accuracy 0.0000
Predicted 560 out of 600; partial accuracy 0.0000
Predicted 648 out of 700; partial accuracy 0.0000

from fruit-images-dataset.

Horea94 avatar Horea94 commented on August 23, 2024

From the prints it looks like it counts the number of correctly classified images as well as the total number of images.
I think the issue is caused by python rounding down the result. Please try changing in the print the "correct / (total_test_images - images_left_to_process)" into
"float(correct / (total_test_images - images_left_to_process))"

from fruit-images-dataset.

sainisanjay avatar sainisanjay commented on August 23, 2024

I guess you are right but still showing same accuracy 0.0000. No luck

Predicted 11437 out of 12300; partial accuracy 0.0000
Predicted 11531 out of 12400; partial accuracy 0.0000
Predicted 11618 out of 12500; partial accuracy 0.0000
0

from fruit-images-dataset.

Horea94 avatar Horea94 commented on August 23, 2024

I think I was mistaken. Please try
float(correct) / float(total_test_images - images_left_to_process)
to let python know that you want a division between 2 floats, and the result is expected to be a float.
What version of python are you using, because I cannot replicate this issue with my version?
I use Python 3.6.6.

from fruit-images-dataset.

sainisanjay avatar sainisanjay commented on August 23, 2024

Great now its working absolutely fine. just one more doubt while detecting fruits from detect_fruits.py i am getting error as per below:

FailedPreconditionError (see above for traceback): .../Fruit-Images-Dataset/test-multiple_fruits; Is a directory
	 [[Node: ReaderReadV2_1 = ReaderReadV2[_device="/job:localhost/replica:0/task:0/device:CPU:0"](WholeFileReaderV2, input_producer_1)]]
	 [[Node: DecodeJpeg_1/_93 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_5_DecodeJpeg_1", tensor_type=DT_UINT8, _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]]

I am running as per:
.../Fruit-Images-Dataset/src/image_classification$python fruit_detection/detect_fruits.py --image_path=/home/sanjay.saini/Deeplearning/DeepTensorFlow/My_TensorFlow_tutorials/Fruits_Classification/Fruit-Images-Dataset/test-multiple_fruits

Any idea whats wrong?

from fruit-images-dataset.

Horea94 avatar Horea94 commented on August 23, 2024

For this script you need to provide the path to a jpg file, not the folder.
Something like
.../Fruit-Images-Dataset/src/image_classification$python fruit_detection/detect_fruits.py --image_path=/home/sanjay.saini/Deeplearning/DeepTensorFlow/My_TensorFlow_tutorials/Fruits_Classification/Fruit-Images-Dataset/test-multiple_fruits/apple.jpg

from fruit-images-dataset.

sainisanjay avatar sainisanjay commented on August 23, 2024

Thanks a lot.

from fruit-images-dataset.

Related Issues (20)

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.