How to Install Tensorflow 2 Object Detection
Ғылым және технология
Its finally here! Welcome to my tutorial for installing and setting up Tensorflow 2 Object Detection! This tutorial goes over how to install Tensorflow 2 and get object detection up and running. I try to cover as many possible errors you may find when trying to do this yourself so that you can skip the headaches and get right to object detecting!
Watch the other videos in this series: • Tensorflow 2 Object De...
Common Tensorflow 2 fixes:
"protoc not found" - make sure you add protoc to path and also do "conda install protobuf"
"numpy not found" - make sure to do "conda install numpy"
Links used:
Tensorflow github: github.com/tensorflow/models
Tensorflow models: github.com/tensorflow/models/...
Protobuf download: github.com/protocolbuffers/pr...
Anaconda download: www.anaconda.com/
Code used in this tutorial: github.com/Bengemon825/Tensor...
Original inspiration: github.com/TannerGilbert/Tens...
Chapters:
00:00 - Download Tensorflow repo
01:40 - Protobuf/Protoc Download
04:10 - Anaconda
09:04 - protoc command and script
10:45 - setup.py
11:55 - numpy
12:40 - Test the install
14:10 - Setup IDE
17:10 - Model downloader
21:20 - Detection script
25:00 - Results
26:10 - Outro
Пікірлер: 175
Thank you so much! I spent so much time following different turorials but none worked but thankfully this one did. You're a life saver!
@LazyTech825
Жыл бұрын
Great to hear!
had romed around over tons of tutorials for this but i hadn't seen this master piece you owe my respect brother
Worked for me. Initially I faced some issues with the python version and protobuf. But after some version changing according to what is in video, all worked fine. Thank you for your detailed explanations through the video.
@user-ip6kr5bo5f
22 күн бұрын
I got experimental error of keras version in testing of the installation can you please help me to sort it
Btw great tutorial i have been stuck for a few weeks trying to resolve installation errors following backdated tutorials. Thanks for helping solve my headaches :)😀
Thank you for making this straight forward. This may be the only tutorial that i don't get a single error.
@LazyTech825
Жыл бұрын
Glad it helped!
Thank you for making this so straightforward!!!!!
After three days of endless tries it finally works.... thanks my man you really deserve more attention. Most deserved like and sub ever.
@divyamadineni715
Ай бұрын
Can you please tell for which version of protobuf which version of tenspeflow worked
@divyamadineni715
Ай бұрын
Can anyone twll for what version of protobuf which tensorflow worked
Thank you! After watching many tutorials, yours finally worked!!
jesus christ u saved me from smashing my head in. You are so articulate and actually address the 50 errors that occur. Thank you kind sir
Watched so many Videos and read so many webites, but this is the first video which really helped and didn't skipped things. Thank you so much!
@LazyTech825
Жыл бұрын
Happy to hear it! :)
@divyamadineni715
Ай бұрын
Can you please say when you download the model is that savedmodel folder is coming directly because I downloaded manually and pasted folder over there so I don't have any saved model
@divyamadineni715
Ай бұрын
@@LazyTech825 sir, while installing in gpu version i am having this issue sirImportError: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /home/iot/miniconda3/envs/tf2/lib/python3.9/site-packages/scipy/optimize/_highs/_highs_wrapper.cpython-39-x86_64-linux-gnu.so) please resolve it and this would be great help
Thank you brotha!!!Loved it... finally I found it and managed to do things without screwing up
Awesome tutorial!!! fixed common errors
Amazing guidance for beginner like me. Thank you!!
very well explained...got the perfect outputs
It was a great tutorial, ı couldn't do with other tutorials, but now it worked
Thank you so much! Excellent tutorial
Thank you for making this video!! REALLY HELPFUL!!
@LazyTech825
11 ай бұрын
Glad it was helpful!
I'm using ubuntu and it works! thank you for sharing the video:)
Thank you for amazing tutorial!
@LazyTech825
Жыл бұрын
Glad it was helpful!
Very helpful, Thank you so much for your effort!
@LazyTech825
Жыл бұрын
Glad it was helpful!
amazing tutorial man. thank you so much
Thanks for the tutorial it's a life saver!!!!!!!
@LazyTech825
Жыл бұрын
Glad it helped! I have another video about making your own model coming out soon too!
You are a legend brother !
im stuck and setup.py 10.45 where it say Attribute error
great tutorial!
@LazyTech825
Жыл бұрын
Glad you think so!
just watched the custom object detection model video, good series! Now i can detect macaroni and cheese whenever i want :P
@LazyTech825
Жыл бұрын
Go for it!
@divyamadineni715
Ай бұрын
@@LazyTech825 sir, while installing in gpu version i am having this issue sirImportError: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /home/iot/miniconda3/envs/tf2/lib/python3.9/site-packages/scipy/optimize/_highs/_highs_wrapper.cpython-39-x86_64-linux-gnu.so) please resolve it and this would be great help
That was a nice explanation thank you
@LazyTech825
Жыл бұрын
Thanks for watching!
@divyamadineni715
Ай бұрын
@@LazyTech825 sir, while installing in gpu version i am having this issue sirImportError: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /home/iot/miniconda3/envs/tf2/lib/python3.9/site-packages/scipy/optimize/_highs/_highs_wrapper.cpython-39-x86_64-linux-gnu.so) please resolve it and this would be great help
It works thank you ❤❤
I have a gpu on my PC but everytime I try to install tensorflow-gpu==2.10.0 ( is giving me an error) and if I try to install through conda it installs tensorflow-gpu=2.6 ( but I have tensorflow 2.10) so what should I do? Thank you
Hi first thanks you helped me alot!! one question why do you make two anaconda env. second is tf_cpu but you open the first in pycharm?
thanks for everything , but i did not find any images in the output folder after executing command, what can be the possible cause ?
Can anyone twll for what version of protobuf which tensorflow worked
I still get this error: ModuleNotFoundError: No module named 'tensorflow.contrib'
thank so you sir, please make some detailed up to date videos of tensorflow 2.16.1 installation and bug fixing and serving model through app of server to app. and also cuda cudnn path setting and all, thanks in advance
Dunno what to say but thank you very much. +1 Sub gained!
@olusholaosasona1842
10 күн бұрын
You get through with it without any error bro?
I want to detect something similar but will have 2 different classes Yes and No, instead of detecting random items.. How to go about it?
Hi i want to use my gpu for training can you guide for that
from tensorflow.python.keras.layers.preprocessing import image_preprocessing as image_ops ModuleNotFoundError: No module named 'tensorflow.python.keras.layers.preprocessing' how to solve this error im stuck 2 days
Thanks!
Thank you so much. Now could you help me direct to the next step where I can custom train my own dataset? Instead of detecting dogs, people and kites, how can I instead detect what I want to detect? Like my boxes or pencils?
@LazyTech825
Жыл бұрын
My more recent videos show you how to make a custom dataset!
I get the following error when I run "python -m pip install ." after copying the set up file. Pls help :( "AttributeError: cython_sources" Edit: had to do the following to solve the issue pip install "Cython
@rafnex99
Ай бұрын
thx a lot, got the same error. For me pip install "Cython
@jun8aid
Ай бұрын
Thanks bud
I'm getting errors with tf.keras.experimental thing during test at 13:40 did someone else have the same issue?
@aadii2884
28 күн бұрын
Same issues
Thanks for the great video. I have a question, does anyone have experience implementing this on a PI 4 ? Especially Anaconda are difficult to install and Protobuf is difficult to change the system variables? Thanks for the help
@LazyTech825
8 ай бұрын
Check out my video on Tensorflow Lite for raspberry pi
thank you
Merci beaucoup c est super
Hello, great tutorial! I'm stuck at the part of 24:28. The errors: 1. can't open file 2. [Errno 2] No such file or directory Any thoughts on this? Thank you.
@teniolatemidayo7438
Жыл бұрын
Same I am stuck here too
@BharadwajChukkala
7 ай бұрын
try this.. python .\detect_from_image.py -m .\ssd_mobilenet_v2_320x320_coco17_tpu-8\saved_model -l ..\.\data\mscoco_label_map.pbtxt -i ..\.\test_images generally this is due to the argument pointing to a different location. see the difference in directories between where the py file is and the labemap and test images are. i am executing that command from this location in my terminal: \Tensorflow\models esearch\object_detection\utils> my directory structure is like this: object_detection | - data | | - mscoco_label_map.pbtxt | - test_images | - utils | | - ssd_mobilenet_v2_320x320_coco17_tpu-8 | | | - saved_model | | | - checkpoint | | - ssd_mobilenet_v2_320x320_coco17_tpu-8.tar.gz | | - detect_from_image.py | | - model_downloader.py
@nkyau445
3 ай бұрын
hey @keithsoriano1083 you can solve this by delete 1 equal sign before the ssd_efficient.det. etc python model_main_tf2.py --pipeline_config_path=ssd_efficientdet_d0_512x512_coco17_tpu-8.config --model_dir==training --alsologtostderr. Hope this one helps
Great tutorial! can you please explain how to train such models such models like Mobilenetv SSD on custom dataset. Thanks.
@LazyTech825
Жыл бұрын
Yes! On my channel I have another video showing how to do that which is part of this tutorial series!
@ameer-alahmadi
Жыл бұрын
@@LazyTech825 Thanks a alot, I will see that then.
Amazing video!! Such a great explanation with clarity. If possible will you please make a video on custom object detection using tf2. I tried to follow your custom object detection videos from the year 2020. But I'm not able to use tf2 using the same process.
@LazyTech825
Жыл бұрын
Thanks for watching! And yes! I plan on making a video for custom models!
@cb407
Жыл бұрын
@@LazyTech825 Please do!! It will help a lot. Can you please take objects something like previous videos like - people with masks and no masks in a picture, video....
@ajarivas72
Жыл бұрын
Incredible video. I feel my computer skills just gave a quantum leap in other dimension
Hey, thanks a lot for your video. I have a small question, would it be possible to install TF2 as shown here in the video also on a Raspberry Pi 4 with 8GB ? Does anyone have experience with this ? Thanks for the help
@LazyTech825
9 ай бұрын
I believe you’ll have to use tflite, which is a version of tensorflow made for mobile and small devices - thinking of making a video about this
thankyou!
Thanks for putting this together. I tried running detect_from_image with the command "python detect_from_image.py -m ssd_mobilenet_v2_coco_2018_03_29/saved_model/ -l data/mscoco_label_map.pbtxt -i test_images" (seemed to not find the files using your original format, so I ended up changing the \'s and whatnot.) I got an error on the line "output_dict = model(input_tensor)" saying "Autotrackable object is not callable" Any explanation/fix would be much appreciated. Found the fix: "output_dict = model(input_tensor)" --> output_dict = model.signatures['serving_default'](input_tensor)
@teniolatemidayo7438
Жыл бұрын
Question can u help I have like your error too
@SamuelGerardCacnio
Жыл бұрын
@@teniolatemidayo7438 Unfortunately, I ended up reinstalling (found I had version incompatibilities between TF, CUDA, and cuDNN) everything but never ran into this error afterward for some reason even though I didn't put the above change back.
ERROR: Could not build wheels for pycocotools, which is required to install pyproject.toml-based projects I got this error whenever I try to install the setup python program. is there a way to fix this issue?
@LazyTech825
Жыл бұрын
Try running 'pip install pycocotools' - if that doesn't work try 'pip install git+github.com/philferriere/cocoapi.git#egg=pycocotools^&subdirectory=PythonAPI'
@jonascampos3567
Жыл бұрын
@@LazyTech825 I tried to do this, but i got this error "Cannot unpack file" and "cannot detect archive format" and "ERROR: Cannot determine archive format"
Thank you, can you please help me to solve this problem (" ERROR: Cannot install object-detection and object-detection==0.1 because these package versions have conflicting dependencies")
@LazyTech825
Жыл бұрын
what part of the process does this happen? what command did you run where this error comes up?
@abraralharbi6835
Жыл бұрын
@@LazyTech825python -m pip install .
@abraralharbi6835
Жыл бұрын
Thank you for kindness, I fixed the problem 👍
@sailikhith9316
Жыл бұрын
@@abraralharbi6835 how did you solve this error please help
@sailikhith9316
Жыл бұрын
@@LazyTech825 i got the same error and am not able to resolve please help
Hi. Cool video, thx. I keep on getting ERROR: Could not build wheels for pycocotools, which is required to install pyproject.toml-based projects, at 11:48. Could you please help?
@LazyTech825
Жыл бұрын
Thanks for watching! Try running 'pip install pycocotools' - if that doesn't work try 'pip install git+github.com/philferriere/cocoapi.git#egg=pycocotools^&subdirectory=PythonAPI'
@mvjjain5013
Жыл бұрын
@@LazyTech825 Typing pip install pycocotools gives me Building wheel for pycocotools (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [16 lines of output], while pip install git + link returns an ERROR: Cannot unpack file, after it says that pip is being invoked by an old script wrapper. Any advice? Thx.
@mvjjain5013
Жыл бұрын
wait... was I supposed to run these commands inside anaconda, or in a normal command prompt outside it? Because I did the second.
@LazyTech825
Жыл бұрын
Yes do it in conda and see if that works, everything should be done in that conda environment
@mvjjain5013
Жыл бұрын
@@LazyTech825 Hi! Okay, so everything's working now! Your tutorial's have been really helpful. (I subscribed and upvoted both). I still have two questions though - I hope you won't mind me asking. I'm running the TensorFlow Code on an MS Surface, and since I have 2 cameras, do you know how I would choose which one I want to see the webcam-detection on? Also, do you know how I could go about training my own model? Thanks!
Getting requirements to build wheel ... error error: subprocess-exited-with-error × Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> [62 lines of output] i am getting this error can you please tell what can be the fix ?
@enrico_ml95
6 ай бұрын
Got the same issue. Before running setup.py, I installed Cython with a version
I got this error at 13:27, can you please help, thanks! C:\Users\user\models esearch>python object_detection/builders/model_builder_tf2_test.py Traceback (most recent call last): File "C:\Users\user\.conda\envs\tf2\Lib\site-packages\object_detection\models\ssd_efficientnet_bifpn_feature_extractor.py", line 36, in from official.legacy.image_classification.efficientnet import efficientnet_model ModuleNotFoundError: No module named 'official.legacy' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\user\models esearch\object_detection\builders\model_builder_tf2_test.py", line 24, in from object_detection.builders import model_builder File "C:\Users\user\.conda\envs\tf2\Lib\site-packages\object_detection\builders\model_builder.py", line 70, in from object_detection.models import ssd_efficientnet_bifpn_feature_extractor as ssd_efficientnet_bifpn File "C:\Users\user\.conda\envs\tf2\Lib\site-packages\object_detection\models\ssd_efficientnet_bifpn_feature_extractor.py", line 38, in from official.vision.image_classification.efficientnet import efficientnet_model File "C:\Users\user\.conda\envs\tf2\Lib\site-packages\official\vision\image_classification\efficientnet\efficientnet_model.py", line 37, in from official.vision.image_classification import preprocessing File "C:\Users\user\.conda\envs\tf2\Lib\site-packages\official\vision\image_classification\preprocessing.py", line 25, in from official.vision.image_classification import augment File "C:\Users\user\.conda\envs\tf2\Lib\site-packages\official\vision\image_classification\augment.py", line 31, in from tensorflow.python.keras.layers.preprocessing import image_preprocessing as image_ops ModuleNotFoundError: No module named 'tensorflow.python.keras.layers.preprocessing'
@jonhaxhikadrija885
Жыл бұрын
You may need to update the Tensorflow 'pip install --upgrade tensorflow', and try it again. If doesn't work again check if there is a conflict with more than one Tensorflow version with 'pip list | grep tensorflow'. Hope it helps.
@enrico_ml95
6 ай бұрын
Hi, for those who are experiencing the same issue, I tried to create a conda env with a Pyhton version 3.10 and then it worked
Hi Sir, I got an error at this step 24:28, it said: from object_detection.utils import ops as utils_ops ModuleNotFoundError: No module named 'object_detection' and then i found that in these 3 .py files (in object_detection\utils folder) from object_detection.utils import ops as utils_ops from object_detection.utils import label_map_util from object_detection.utils import visualization_utils as vis_util the libraries called "six.moves" and "tensorflow.compat.v1" seems like these libraries didn't install yet. But i do the pip list and conda list, the "six" already installed, but the "tensorflow.compat.v1" doesn't have in the list. I have no idea how to fix this problem. Please help me, thank you.
@LazyTech825
Жыл бұрын
You can try manually installing it with ‘conda install tensorflow.compat.v1’
@jjukjjik
Жыл бұрын
It’s not work…
@LazyTech825
Жыл бұрын
It looks like it can't find object_detection, try starting from the beginning and make sure you do the setup.py steps. If you miss that step it won't recognize the package
@adamdangerfield
Жыл бұрын
I had the same issue trying to run it in py charm, setup like the video. I switched back to the anaconda propt and run the python .\detect_from_image\.... from the object_detection directory and it worked. I'm guessing I've set up something incorrectly py charm.
@teniolatemidayo7438
Жыл бұрын
@@adamdangerfieldsame problem did u fix your yet
Great video! It helped me a lot! THANKS!
@LazyTech825
8 ай бұрын
Glad to hear it!
python -m pip install while doing this one i got a error that, ignored following bcause of different python version
@LazyTech825
Жыл бұрын
You can probably do it with a different python version
@TRENTINATERx2000
21 күн бұрын
For future people I have yet to see or hear of anyone who got object detection working with any python newer than 3.9.x.
could you please increase the font size on cmd, struggled with most commands
@LazyTech825
Жыл бұрын
Thank you for letting me know! I will zoom in next time
@adityarajhonraopatil4453
Жыл бұрын
@@LazyTech825 but cool vid, gthank you so much
There are lot of compatibility issues !
C:\Users\MATSTRIX\anaconda3\envs\tf2\python.exe: can't open file 'C:\Users\MATSTRIX\Projects\tf2\detect_from_images.py': [Errno 2] No such file or directory i'm literally stuck for days in this error.
also in the test one it shows absl modulenotfounderror
@aureydeguzman5361
Жыл бұрын
I have this one as well, did you ever get to fixing it?
does this work on raspberry pi 4?
@LazyTech825
2 ай бұрын
Checkout my video for tensorflow lite on raspberry pi
@maysalsayed2343
2 ай бұрын
@@LazyTech825 yes i tried to use it,but it gives me an error, there's no web camera,i use raspberry pi 4 ,os 64 bit,bookworm,with pi camera module 3
its showing git is not recognised as a command what to do?
@LazyTech825
Жыл бұрын
Do you have git installed?
@kratos_gaming9765
Жыл бұрын
@@LazyTech825 no i didnt but now i did and its working thankss
You should use a larger font size when making videos, 720 quality is still very blurry
is trhere anyone who could do the second part in macOS
This was great, one issue which has made me pause though is CUDA. This didnt work with CUDA out of the box. I played around with cudnn, CUDA, and these commands: print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU'))) print(tf.test.is_built_with_cuda()) Finally after following a guide i found online i was able to get the is built with cuda to return true, only issue is the number of gpu's available was stuck at 0. Absolutely frustrating. I've spent all day getting this to work and big thanks to your tutorial for getting this far (although i still encountered about 3 issues which I had to overcome - not your fault though!), but I dont want to run tensorflow on CPU....so im thrilled to have got this far and disappointed that CUDA is such a pain in the ass to get working. If you could come out with another guide to replace your last 25min video on setting this up, or a way to get it working once its been setup, that would be incredible. I have tried changing cuda versions, using tensorflow-gpu, changing cudnn to align with the cuda versions, and more... Absolute pain in the ass to get working.
Can I do all of this without anaconda ?
@LazyTech825
Жыл бұрын
You can, but it might be harder to do
@efecankaratut9638
Жыл бұрын
@@LazyTech825 Thank you sir, can I ask u some question next time for my project
HOW! PYTHON DOESN"T UNDERSTAND, where it is located (tf_py37) C:\Users\Sarvar\Desktop\ODAPI\models esearch\object_detection>python detect_from_image.py -m ssd_mobilenet_v2_320x320_coco17_tpu-8\saved_model -l .\data\mscoco_label_map.pbtxt -i .\test_images Traceback (most recent call last): File "detect_from_image.py", line 10, in from object_detection.utils import ops as utils_ops ModuleNotFoundError: No module named 'object_detection'
@BharadwajChukkala
7 ай бұрын
try this.. python .\detect_from_image.py -m .\ssd_mobilenet_v2_320x320_coco17_tpu-8\saved_model -l ..\.\data\mscoco_label_map.pbtxt -i ..\.\test_images generally this is due to the argument pointing to a different location. see the difference in directories between where the py file is and the labemap and test images are. i am executing that command from this location in my terminal: \Tensorflow\models esearch\object_detection\utils> my directory structure is like this: object_detection | - data | | - mscoco_label_map.pbtxt | - test_images | - utils | | - ssd_mobilenet_v2_320x320_coco17_tpu-8 | | | - saved_model | | | - checkpoint | | - ssd_mobilenet_v2_320x320_coco17_tpu-8.tar.gz | | - detect_from_image.py | | - model_downloader.py
@maysalsayed2343
4 ай бұрын
@@BharadwajChukkala i tried it , but it doesn't work, does it work with you totally?
@comicnerd9770
4 ай бұрын
Yes Depends on the trees structure u have. Send a git link to ur code and i’ll take a look at it.
@maysalsayed2343
4 ай бұрын
@@comicnerd9770 thank you , i restarted everything from the beginning and it's solved now
PLEASE HELP , STUCK AT THIS FOR 2 DAYS ......................................... Collecting pyyaml=5.1 (from tf-models-official>=2.5.1->object-detection==0.1) Using cached PyYAML-5.4.1.tar.gz (175 kB) Installing build dependencies: started Installing build dependencies: finished with status 'done' Getting requirements to build wheel: started Getting requirements to build wheel: finished with status 'error' error: subprocess-exited-with-error Getting requirements to build wheel did not run successfully. exit code: 1
@RajarshiBangal
3 ай бұрын
i got the same error. did you find any solution, beacuse I really can use the help
@zahranuranisah
2 ай бұрын
I also have the same error:( have you find the solution yet??
@shazmahussain3395
2 ай бұрын
Got the same issue. Before running setup.py, I installed Cython with a version
@shazmahussain3395
2 ай бұрын
@@RajarshiBangal Got the same issue. Before running setup.py, I installed Cython with a version
anyone get error in13min. error - WARNING:tensorflow:From C:\Users\DK\.conda\envs\tf2\Lib\site-packages\keras\src\losses.py:2976: The name tf.losses.sparse_softmax_cross_entropy is deprecated. Please use tf.compat.v1.losses.sparse_softmax_cross_entropy instead.
just watched this tutorial and encountered "ImportError: cannot import name 'builder' from 'google.protobuf.internal'". can i get a fix?
@BharadwajChukkala
7 ай бұрын
add protobuf to path variable
Goodluck if you have an M1 chip, no training for you. Getting " contrib" does not exist at the testing stage because apparently TF2 does not have a tf.contrib equivalent. docs.google.com/spreadsheets/d/1FLFJLzg7WNP6JHODX5q8BDgptKafq_slHpnHVbJIteQ/edit#gid=0