Это видео недоступно.
Сожалеем об этом.
How to Train a Custom Model for Object Detection (Local and Google Colab!)
HTML-код
- Опубликовано: 17 авг 2024
- Hey welcome back, Ben again! Today's video is the last part of my object detection tutorial series. This video goes over how to train your custom model using either your local computer, or by utilizing the free GPUs on Google Colab. I also make sure to go over how to fix errors such as 'no module named nets/deployment' as I see people trip on that one often. As I said in the video, support for object detection with TensorFlow 2 just recently dropped so expect an update video at some time in the future. TensorFlow has stated that they will keep support for tf1 so don't worry if you want to keep following this tutorial.
NEW: Tensorflow 2 custom model tutorial • Tensorflow 2 Custom Ob...
Commands Used:
o python train.py --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v1_pets.config --logtostderr
o python export_inference_graph.py --input_type image_tensor --pipeline_config_path training/ssd_mobilenet_v1_pets.config --trained_checkpoint_prefix training/model.ckpt-3207 --output_directory new_graph
Useful Links:
My GitHub: github.com/Ben...
sentdex's RUclips: / @sentdex
TensorFlow Models: github.com/ten...
Hey!! I have a new tutorial for making a custom object detection model for tensorflow 2 here: ruclips.net/video/8ktcGQ-XreQ/видео.html
This is going to be the next big tech channel, Ben gives credits to the rightful owner and shows the way around, awesome! Thanks man, You are good at engaging the audience.
Thank you!
LOVE YOU
finally I have found a video which, shows how to do it visually on custom data sets, damn I was looking for such a video for long time now
I definitely subscribed to this channel . Actually I was trying to do the same step with tensorflow 2.X , I didn't notice the version of Tensorflow API. Thanks champp ! Can't wait for the API 2 .
instablaster...
Nice job!! Very easy to follow :) one small change I had to make since I didn't make an Oject_Detection_Files folder (don't think it was mentioned in video but shows up in your Google Colab code and Google drive) --> "%cd /content/gdrive/My Drive/models/research/"
hey u mean change
%cd /content/drive/MyDrive/Object_Detection_Files/models/research/
this path as %cd /content/gdrive/My Drive/models/research/ this rty?
do a tensorflow 2 with colab (object Detection) tutorial ,plz
Excellent tutorial with detailed explanation, thanks Ben!!! Really helpful
Finally I got it. Amazing tutorial and teacher, you know the right way to teach Bro. Thanks a lot.
thank you for your content, you are saving my life
Really good tutorial! Please do a tensorflow 2 with colab (custom object Detection) tutorial
Great content man i m sure you re gonna be the next sentdex way to go ❤
great video! thanks for showing both ways - train the model offline and with google colab.
Why did I get this error when training in Google colab.
" python3: can't open file 'setup.py': [Errno 2] No such file or directory "
Does the 'Object_Detection_Files' necessary to be created inside google drive? Hope you can guide me to perform the training for my final year project. Thank you so much
I notice you created a little cheap sheet for yourself (8:16). That is a real good idea!
Thanks man ...it works perfectly for me
It was a very good education 💪💪. I will find a small request. It would be nice if you enlarge the text on your computer a little in the videos from now on. I find it very difficult to read. Thank you.
@LazyTech, thanks Ben. Despite some technical/code issues I'm facing, your video series is helping me get farther along vs. following Sentdex's outdated version. (To be sure, I do love all his other videos nevertheless.) I think you, too, will build a large fan base very quickly if you can regularly post such videos with examples of real-life applications. Anyway, as a genuine suggestion, would you please consider better organizing your files and folders before recording future videos? It's hard to follow some of the file/folder movements you're making on the fly while recording. Other movements however, such as those in response to run-time errors, are good for learning. Also, for future videos would you please zoom into your display screen more so it's easier to watch your screen while also following along on a large laptop screen or an external monitor's split screen? Hope you'll take my well-meaning suggestions in the right spirit. Looking forward to your future videos. Thanks again and best wishes.
thanks for the support and suggestions! Making videos is still new to me so I try to improve on something every time. I saw your other comment - make sure you're on tensorflow 1.15 or to make sure that your version is consistent wherever you set it. I plan on making a video that goes over questions that people leave in the comments that hopefully i will be able to solve
@@LazyTech825 Thx for taking the time to respond. Yes, I used TF 1.15 and mimicked the virtual environment as described in your video. I even switched to the ssd_mobilenet_v1_pets.config to eliminate the last potential source of error. I'm able to run most of the code except the most important final two python commands! Would greatly appreciate your addressing the execution challenges shared by the users. (I even painstakingly went through 1k+ images and settled on 650+ images with boxed object identifiers and was eagerly looking forward to seeing it through.) Cheers
Thanks man!! This helped me with my college project
This is pretty cool and quite useful
Recently found you through sentdex and thanks a lot for these tutorials! I was also wondering if you will be uploading a video/tutorial in the future to be able to use our model to classify objects in images rather than through a webcam. I'm fairly new to all of this, so maybe it's not 100% apparent to me as to how I would feed some new images to the model to test it. Thanks again by the way!
Thanks! Glad I could help! I’m not sure if I’ll make a whole video on it but I can upload a script to my github. It’s very similar to the webcam version. I’ll leave comments in it so hopefully you can see what’s going on
@@LazyTech825 A script also works as well! Thanks a bunch!
Just uploaded the script to the github under the 'scripts' folder. Its pretty rough but works lol
Thank you for a tutorial I’ve been looking everywhere and nothing could be found
the correct command for -> set PYTHONPATH=$PYTHONPATH...........
is -> set PYTHONPATH=%PYTHONPATH%;path to models folder ; path to research folder ; path to slim folder that is in research folder
so if models folder in desktop the command will be and change 'iP' to your computer name ->
set PYTHONPATH=%PYTHONPATH%;C:\Users\iP\Desktop\models;C:\Users\iP\Desktop\models
esearch;C:\Users\iP\Desktop\models
esearch\slim
you dont need to copy deployment , slim , nets folders
good channel and thank you for bringing these contents here, one suggestion is to try to zoom in so that we can se clearly what you are doing, the code are very small in font size
Thanks for the tip!
when i try to run "python train.py --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v1_pets.config --logtostderr", i am getting an error named "ValueError: ssd_mobilenet_v1 is not supported. See `model_builder.py` for features extractors compatible with different versions of Tensorflow". What should i do?
hi i have the same error did you find a solution?
I believe, if you specifically go through that file 'model_builder.py' it will give you an overview about what version of tensorflow will support which model of the config file . Unless you can create a config file from scratch. That would be interesting.
If you get a work around please do share your experience. thanks :-)
As it seems the model py uses the tensorflow 2 version that we have installed instead of version 1
if you change the ssd_mobilnet_v1 in pets.config to ssd_mobilnet_v1_keras (tf2 module) the error will stop
So I think to solve this you should make sure you use only the version 1
@@panosmallioris3346 In this exercise we're working with TF1, not TF2 (not the other way around). Either way, the model_builder.py can handle both TF1 and TF2.
I have this error :
ImportError: cannot import name 'input_reader_pb2' from 'object_detection.protos' (D:\Anaconda\lib\site-packages\object_detection\protos\__init__.py)
:(
I know that I am probably too late here. When you make protoc object_detection/protos/*.proto --python_out=. in models/research it will generate py files in models
esearch\object_detection\protos. Copy them to D:\anaconda3\envs\object\Lib\site-packages\object_detection\protos\ where your anaconda locate This will solve your issue.
Or just go straight to Google Colab. Much less pain in ass.
where are those files in your google drive coming from? setup.py isn't anywhere in your github and it's essential to the google collab notebook???
Wow This is so amazing Actually my Prof. asking me to do it like this. You may save me
i am following the same tutorial but i keep getting the tensorflow doesnt have the contrib attribute any way can fix that ?
Thank you very much for this tutorial
worked like a charm.. thanks for the video.. :)
hello ben, I'm trying to run my model in google collab, when training is done the file model.ckpt, in a training folder is not updated(in my google drive of course)
but some file like this appear "events.out.tfevents.1613859072.493383e7542e" is that weird files is checkpoint or nor ?
my tensorflow model is training only one step and loss is 11.38 and it is not doing further step and not reducing loss and saving model to disk, what should i do??
I have the same problem .. did you solve it already??
I have read that its a memory issue, but i still can't fix it
@@omarmarie7802 Yes bro the actual problem was with memory, it was taking more memory bcoz of my mistake and mistake was I had given few images in training whose size was greater than 40mb and another mistake was that I changed the name of few images in training folder but in XML I didn't change any name, so these two were mistakes which was leading that problem so if you can check if you have done the same
You are helping me accomplish my Ph.D. work. Thank you!!
Hello, I have a question: I have a question, could this process be considered as transfer learning?
Greetings from México.
@LazyTech, Hi Ben, any suggestions to solve the following issue? A few others also encountered the same issue.
> python train.py --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v1_pets.config --logtostderr
"ValueError: ssd_mobilenet_v1 is not supported. See `model_builder.py` for features extractors compatible with different versions of Tensorflow"
'tensorflow' has no attribute 'contrib' how to fix it
Hi Ben!
The video series is awesome, I am able to train the model but during the testing I ain't getting the boxes around my objects which are basically leaves for which I am not able to get the any detection in the images, do you have any suggestion for this?
Also this custom model file is at the level of object-detection folder along with training and data
Were you able to solve this issue? Because my object detection doesn't work either
Great content. Adjust the screen size, hard to follow if we can't see the content
I am getting this error while try to train the model'
Requirement already satisfied: tf_slim in /usr/local/lib/python3.6/dist-packages (1.1.0)
Requirement already satisfied: absl-py>=0.2.2 in /usr/local/lib/python3.6/dist-packages (from tf_slim) (0.10.0)
Requirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (from absl-py>=0.2.2->tf_slim) (1.15.0)
/content/gdrive/My Drive/models/research/object_detection
WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/absl/app.py:251: main (from __main__) is deprecated and will be removed in a future version.
Instructions for updating:
Use object_detection/model_main.py.
W1008 12:06:57.928218 139622818539392 deprecation.py:323] From /usr/local/lib/python3.6/dist-packages/absl/app.py:251: main (from __main__) is deprecated and will be removed in a future version.
Instructions for updating:
Use object_detection/model_main.py.
Traceback (most recent call last):
File "train.py", line 186, in
tf.app.run()
File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/platform/app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/usr/local/lib/python3.6/dist-packages/absl/app.py", line 300, in run
_run_main(main, args)
File "/usr/local/lib/python3.6/dist-packages/absl/app.py", line 251, in _run_main
sys.exit(main(argv))
File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/util/deprecation.py", line 324, in new_func
return func(*args, **kwargs)
File "train.py", line 110, in main
overwrite=True)
File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/lib/io/file_io.py", line 469, in copy
copy_v2(oldpath, newpath, overwrite)
File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/lib/io/file_io.py", line 486, in copy_v2
compat.as_bytes(src), compat.as_bytes(dst), overwrite)
tensorflow.python.framework.errors_impl.NotFoundError: ; No such file or directory
Hi.. awesome tutorial. I would like to print out mAP or meanIOU metrics while training ? Please help me out to do this.
Hi, when I tried to train the model the following error showed up:
from object_detection.builders import dataset_builder
ModuleNotFoundError: No module named 'object_detection'
Do you have any idea about fixing that?!
where can I configure to save the checkpoints in training/ folder (like you did), I successed train the model but the checkpoints save in "/tmp/tmpvuy1ghi1/" folder
@Lazy Tech
Hi Ben!
I am getting an error while performing the 'python train.py ... ' step,
It is saying
InvalidArgumentError: Shape mismatch in tuple component 20, Expected [1,?,?, 3] got [1, 482,339,1]
What shall I do?
Hi Ben, great tutorial. Can you please upload the command notepad? or any link where have you already uploaded it?
thank you for your content!
What would be nice step once an object is detected to do some sort of output?
Hi, you didnt posted those commands i nthe descrptiion below.
Excuse me, tensorflow object detection 2. X
How to export
freeze_ graph
Model
Hi Ben, what a great tutorial thanks a lot.
but i have a question how if i want to add the tensorboard into the google colab while training?
Very well explained and everything works!!!!
hey, thanks for the video! I wanted to know how to use the downloded model(saved_model or model.pb file) from colab as locally on jupyter and what files and dependencies I need to be sure of that should be present to support the model?
Awesome! Work perfectly!
But. I have a question, can i load keras (h5) model with that code?
You saved my life!!
Finally, a tutorial that works! Thank you.(just a side note: Is it normal for my steps to take 15-25 seconds each? the loss is decreasing, just the step time is a little long.)
Depends on your system
Excellent tutorial Lazy. I have a question regarding what to do if I want to train the model further after already training it once. Since I'm using colab to train my model, I guessed I would just re-run the cell where it trains the model (@18:13) thinking it would pick up from the last checkpoint and improve on the loss from there. But it seems the model forgets everything and starts learning from the beginning with high loss values.
i believe you can add the flag --trained_checkpoint_prefix and give it the path to your most recent model.ckpt file
Thanks for the great tutorial, can you please make a video on evaluation metrics for object detection?
Can this be used for developing an object detection mobile app as well please?
cannot import name 'string_int_label_map_pb2' from 'object_detection.protos' (C:\Anaconda3\envs\spyder\lib\site-packages\object_detection\protos\__init__.py)
I hope there are tensorflow 2 with colab tutorial
Can I ask what algorithms is being use here? Thank you for answering!
Can you upload the object detection folder of tensorflow 1 as its updated to tensoflow 2 and the old one is not visible
Awesome tutorial- I'm working on the same problem in my research at the moment. Question- do you have that nifty word doc you're using available? I found one on your GitHub but it only goes through "First time setup". Thanks!
I've been editing it over time while trying to fix up, I will upload a more "complete" version of it soon
@@LazyTech825 Great, thanks.
I'm not sure whether you're still working on this in your research and / or have the spirit to wrestle with tf2.x, but I found that one of the tf2.x object detection colab tutorials covers this exact issue of fine tuning a tf object detection model to identify custom objects. It's: 'models/research/object_detection/colab_tutorials/eager_few_shot_od_training_tf2_colab.ipynb'. Thought you might find it useful! Thanks again.
What's the final step to detect object in images instead of webcam?
Great video BTW
I use the other file i have on my github to do this
Your font size is too small. Please next time use large fonts. All over superb video
Bro, why am I having ModuleNotFoundError:No module named 'TensorFlow' even though I installed it in anaconda environment and inside the anaconda prompt?
hello bro i am working on garbage detection ;i follow all your steps but at end while training it show only "saving checkpoint to path training" what should i do please reply
I got this error when I was training:
RuntimeError: Did not find any input files matching the glob pattern ['/content/gdrive/MyDrive/models/research/object_detection/train.record']
Can you please help
Hi.., where have you mentioned images path but you only entered the image name?
What if I want to do something like, if it detects mask then just maybe print out something and if there's no mask worn by the person in cam, print out something else?
I mean how can I access the results which are shown?
I'm an utter noob please help me 🙏🏻
I successfull trained but the object can't detect anything??? can anyone tell me if I missed any steps??
Hey !!
I am too facing the same problems!!
Any suggestions!
great video man, you should open a Discord server to have some discussion :) thank you
I would like to keep training my CNN with new data, when I finish to train my model I can reuse it to update the weights with the new data?
Hey bro !
I have a little-big question jajaja The size of the images for training the model are important for the perfomance (speed) of te CV ? I give you a example, I trained a YOLO model but the first time I didn't care the size of the images when I put the bbox using labelimg and then I had a slow answer when I ran the model on OPENCV and in my second training I changed the size of the images to 96*96 px and the model continue slowly but not like the first time,
Pdt: Sorry if my syntax or redaction is bad I'm not a native english speaker
Size of the images to train will usually make the training slower, i'd expect it would probaly make the actual detection slower too if you're actually able to train the model with the large images (some times you run out of memory doing this)
I created a custom model of 7 classes, It works good but it also detects humans, computers, paintings, even dogs. Which I never trained my model for. Do you know why is it doing this?
Bro....my tensorflow model is ready...but the thing is how am I supposed to convert it into tflite model?
Hello :D I just wanted to know if can I use the same method to detect cracks in concrete.
Hi Ben! When I run the train.py file, I get the following error: AttributeError: module 'tensorflow.python.framework.ops' has no attribute 'RegisterShape'
Any idea how to solve it?
Hi guys. I trained model as Ben showed. But when i want to test model on pictures that model didn`t see, model can`t recognize them. Can it be because of bad quality of photos that i used for training? Thanks.
Excellent video! Would love to see a tf2 version
This is great to see! And how to calculate the mAP value and FPS for the custom model we've trained?
I’m unsure on how to find the fps, you could probably actually just use a third party fps counter. Getting the coordinate values is something I will be doing in the future
@@LazyTech825 hey Ben! Thanks for this great series, can you suggest some videos or websites that explain the code and the mathematics that goes behind all of this, Thanks in advance!
@@waitwhat3547 Andrew Ng's (Standford Prof.) famous Machine Learning class on RUclips and/or Coursera. For bite-size lessons on Statistics, look at Josh Starmer's StatQuest series.
I'm getting this error "module 'google.protobuf.descriptor' has no attribute '_internal_create_key' " when I run the script for testing the model, I searched for this error and updated the protoc version and libprotobuf as 3.11.2. Still I am getting this error, can you suggest a solution?
i dont have models y1 folder and idk what you have in research folder
Should we change no of classes in ssd config file also?
hi all, i always get the error when i run the train.py: AttributeError: module 'tensorflow._api.v1.compat.v1.compat' has no attribute 'v2'. please help me :(
Hello , I tried to work on the project , while training i got this issue please help with this UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 57: invalid start byte
Thank you
A friendly suggestion - You should lower your display resolution .. It's because the folders and codes are a little bit tiny and not clearly visible in x768px display. And in mobile it would be much worse.
Just the sticky note on top right of your screen :)))
hello, my project is detecting red balls. so i want this to the only red masks, what should i do? can you help me pls?
Instead of training the model on masks, just use images of red balls!
How to evaluate the trained models? Also is there yolo model?
how to create the slim folder!
Hey Ben! Superb Video really helped me a lot to develop my custom model. But I wanted to know how to find the input and output array of our frozen model so that I can convert it into tflite model. Plz Help
Hi Ben, these videos are so helpful. I'm new to working with software and you are so clear and instructive. I'm getting inspired to pursue a career change after following your ML tutorials.. I'd love to send you a gift card or buy you a coffee over Venmo if possible!
how to export custom model in tflite format so we can use it on android ?
how do you make it work with an image rather than a video?
I exported the graph and the variables folder is empty. Can someone help?
How long did the training process take you? After 1 hr im still at step 0 :( pls help
Impressive video... can you please guide me with this error...
return bytes_or_text.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xaa in position 0: invalid start byte
mee too
did you solve it?
thanks very much to you
Hello sir , I want to know number epoch, accuracy, batch in ssd mobilenet v1.config. Please , Can you give me the way to resolve the problem ?
Hi Ben,
I am thankful with your tutorial and now im currently in the phase of making my own model. However, i want to use tflite since i want to use it in raspberry pi. I did everything the same as you did but only change the config file to ssd_mobilenet_v2_quantized. Upon running the training code i discovered that it always giving me an error. Is it becuase it has a different way of working than the v1_mobilenet? I kindly ask for your help thanks!
hey, do you have the solution for this?