Mask R-CNN on Custom Dataset | Practical Implementation
Vložit
- čas přidán 29. 08. 2024
- Mask RCNN with Tensorflow2 video link: • Instance Segmentation ...
In this video, I have explained step by step how to train Mask R-CNN on Custom Dataset.
Github link: github.com/Aar...
Download mrcnn folder from this repository: github.com/mat...
Download coco weights : github.com/mat...
If you have any questions with what we covered in this video then feel free to ask in the comment section below & I'll do my best to answer your queries.
Please consider clicking the SUBSCRIBE button to be notified for future videos & thank you all for watching.
Channel: www.youtube.co....
Support my channel 🙏 by LIKE ,SHARE & SUBSCRIBE
Contact: aarohisingla1987@gmail.com
Instance Segmentation with Mask R-CNN:
Mask RCNN is a deep neural network aimed to solve instance segmentation problem in machine learning or computer vision. In other words, it can separate different objects in a image or a video. You give it a image, it gives you the object bounding boxes, classes and masks.
There are two stages of Mask RCNN. First, it generates proposals about the regions where there might be an object based on the input image. Second, it predicts the class of the object, refines the bounding box and generates a mask in pixel level of the object based on the first stage proposal. Both stages are connected to the backbone structure.
What is backbone? Backbone is a FPN style deep neural network. It consists of a bottom-up pathway , a top-bottom pathway and lateral connections. Bottom-up pathway can be any ConvNet, usually ResNet or VGG, which extracts features from raw images. Top-bottom pathway generates feature pyramid map which is similar in size to bottom-up pathway. Lateral connections are convolution and adding operations between two corresponding levels of the two pathways. FPN outperforms other single ConvNets mainly for the reason that it maintains strong semantically features at various resolution scales.
Now let’s look at the first stage. A light weight neural network called RPN scans all FPN top-bottom pathway( hereinafter referred to feature map) and proposes regions which may contain objects. That’s all it is. While scaning feature map is an efficient way, we need a method to bind features to its raw image location. Here come the anchors. Anchors are a set of boxes with predefined locations and scales relative to images. Ground-truth classes( only object or background binary classified at this stage) and bounding boxes are assigned to individual anchors according to some IoU value. As anchors with different scales bind to different levels of feature map, RPN uses these anchors to figure out where of the feature map ‘should’ get an object and what size of its bounding box is. Here we may agree that convolving, downsampling and upsampling would keep features staying the same relative locations as the objects in original image, and wouldn’t mess them around.
At the second stage, another neural network takes proposed regions by the first stage and assign them to several specific areas of a feature map level, scans these areas, and generates objects classes(multi-categorical classified), bounding boxes and masks. The procedure looks similar to RPN. Differences are that without the help of anchors, stage-two used a trick called ROIAlign to locate the relevant areas of feature map, and there is a branch generating masks for each objects in pixel level. Work completed.
#maskrcnn #objectdetection #deeplearning #ai #artificialintelligence #ml #computervision #cnn #convolutionalneuralnetwork
Your videos are so well "architected". It takes us to the depths never taken by others. THANK YOU!!!!!
Glad you like them!
I looked up the Walled Abdulla blog post. The customData Class had me stuck for rwo days, this explanation solves it all. Thanks a many, Aarohi.
This is the 2nd time your efforts are helping me, first one I guess FPN pyramid using CNN.
Glad to hear that. Keep watching and learning 😊
Thank you maam. Most of the other tutorials dont explain in such way. Your explaination helps me to understand code in deep. Thank u very much
You are welcome 😊
Thank you very much ma'am. It is my first time watching a clear cut example with step by step explanation for mask-rcnn training on Custom Dataset.
You are most welcome
thank you for your answer, the problem is solved but it gives me the high loss rate which implies a bad detection, so please what should I do to correct it.
Epoch 30/30
100/100 [==============================] - 784s 8s/step - batch: 49.5000 - size: 1.0000 - loss: 0.3552 - rpn_class_loss: 0.0052 - rpn_bbox_loss: 0.1705 - mrcnn_class_loss: 0.0218 - mrcnn_bbox_loss: 0.0532 - mrcnn_mask_loss: 0.1044 - val_loss: 3.8523 - val_rpn_class_loss: 0.1956 - val_rpn_bbox_loss: 2.3940 - val_mrcnn_class_loss: 0.3829 - val_mrcnn_bbox_loss: 0.3561 - val_mrcnn_mask_loss: 0.5238
PLEASE HELP ME
Thank you so much Ma'am. Your explanation is really Amazing. It has helped us alot. It is very knowledge full. Thank you Again Madam
Glad to hear that
polygons = [r['shape_attributes'] for r in a['regions']]
22 objects = [s['region_attributes']['name'] for s in a['regions']]
23 print("objects:",objects)
TypeError: string indices must be integers
why am i getting this error
Madam
We are using only one annotations1 = json.load(open('D:/MaskRCNN-main/Dataset/train/via_project.json'))
and while preparing datset we are sending two train and val but using only one annotations
pl. clarify
Thanks a lot ma'am, You have done a great Job. Thank you so much
Welcome
Really Amazing explanation by Ma’am
Thanks a lot
This is great, thanks! :D
It really helped me
Glad it helped!
I tried to do this project on colab but it's not moving beyond step9/10 of epoch 1. I also have a doubt about where do we use the val json file as you didn't mention it anywhere
Rakesh Yacharam
hi can you help in with this error
I got error as "----> 1 model.train(dataset_train, dataset_val,
2 learning_rate=config.LEARNING_RATE,
3 epochs=10,
4 layers='heads')
5
NameError: name 'model' is not defined" ....
how to over come this error
Thank you so much for this video. Really helpful.
Glad it was helpful!
@@CodeWithAarohi I have one question. maskRCNN requires tensorflow 1.3.0 as per the documentation but some methods don’t work anymore so I installed Tensorflow 1.5.0 and the model is training well but my GPU is not working. Because I installed CUDA and cuDNN for TF version 1.3.0 before. If I reinstall the CUDA versions compatible for TF1.5 it should work right? Or would you suggest the most stable version of tensorflow? Expecting your response ma‘am. Thank you in advance.
@@sushantparajuli611 Use python 3.6.8 , tensorflow 1.15.0, h5py 2.10.0, keras 2.2.4 and my numpy version is 1.19.5
These versions are working well for me
@@CodeWithAarohi Thank you so much for your quick response ma‘am. Really appreciate.😊😊😊
Great demonstration.
Kindly share the idea to annotating the brain tumor ROIs in MRI images dataset I have downloaded from kaggle.
Want to segment the tumor portion and draw bounding box.
Already done classification part using VGG-16.
hello , I have tried to test the detection on my own dataset.
There is no error but I got this message : "NO INSTANCE TO DISPLAY"
I see instances but the detection are not good
BEST WOMAN IN THE WORLD!!! THANK YOU!!!!!!!!! AAAAAAAAAA
:)
Great explanation, ma'am
Thanks for liking
very informative video.
many thanks madam
Glad my video helped
Thanks a lot Aarohi !!!
welcome
Mam Thank you so much for the detailed explanation and analysis. You have explained everything very precisely without missing any step. It has helped me a lot as I am making a project on mask rcnn in my college. Mam, at the last I am facing issues like ValueError:
The following Variables were created within a Lambda layer (anchors)
but are not tracked by said layer:
The layer cannot safely ensure proper Variable reuse across multiple
calls, and consquently this behavior is disallowed for safety. Lambda
layers are not well suited to stateful computation; instead, writing a
subclassed Layer is the recommend way to define layers with
Variables.
I did this in Jupyter notebook and i am getting this.
If possible can you please tell all the things that you installed before executing python code in cmd prompt.
Thank you
This code is working on python 3.6.8, tensorflow 1.14.1 and keras 2.3.0
The way explaining is cute
Thanks a lot mam..
Most welcome 😊
Hi, I have question. I implemented everything as you said; however, no h5 files are being created in the logs folder. How to fix? (I have tf= 1.13.1, python=3.7, keras=2.3.0)
RemoveStackStridedSliceSameAxis node proposal_targets….. is the errror
Hello. Thank you for your video. It helps me a lot.
1 little question about the annotation section tho.
Q) you said we need to change the annotation directory to the training folder so that the json file or training folder can be used. However, we actually labeled training folder AND validation folder as well. What about the json file of val folder?? We are not going to use it?
Please answer my question when you are available.. ! Thank you once again for the helps!
Really a gem Mam
Thanks a lot
@@CodeWithAarohi Mam, after having the trained .h5 weights, can you please help me to get the code of how to load the weight in a model? I am not getting it. Thanks in advance
@@CodeWithAarohi Mam please help me with the prediction code. Need it urgently. Thanks
@@9433778142 WEIGHTS_PATH = "logs/object20210626T2237/mask_rcnn_object_0010.h5" # change it
# Load weights
print("Loading weights ", WEIGHTS_PATH)
model.load_weights(weights_path, by_name=True)
# Run detections
image_id = random.choice(dataset.image_ids)
#image_id = 'D:\env_with_tensorflow1.14\jerry_maskrcnn\test.png'
print("image id is :",image_id)
image, image_meta, gt_class_id, gt_bbox, gt_mask =modellib.load_image_gt(dataset, config, image_id, use_mini_mask=False)
info = dataset.image_info[image_id]
print("image ID: {}.{} ({}) {}".format(info["source"], info["id"], image_id,dataset.image_reference(image_id)))
# Run object detection
results = model.detect([image], verbose=1)
Thank you for this tutorial mam
Most welcome
Awesome 👌
thankyou
please give me solution of this error FutureWarning: Input image dtype is bool. Interpolation is not defined with bool data type. Please set order to 0 or explicitely cast input image to another data type. Starting from version 0.19 a ValueError will be raised instead of this warning.
order = _validate_interpolation_order(image.dtype, order)
thank you maam for the explaination. Could you please help why im getting this error when i run this on my dataset AttributeError: 'str' object has no attribute 'decode'
thank you for this video, please in the training phase I got the following error:
ResourceExhaustedError: OOM when allocating tensor of shape [] and type float
[[{{node mul/y}}]]
PLEASE HELP ME
memory is not sufficient. To solve this issue, you can Reduce the batch size of your model
@@CodeWithAarohi How i do it ,in which file I find it,
please another error: ValueError: Error when checking input: expected input_image_meta to have shape (14,) but got array with shape (16,)
@@CodeWithAarohi thank you for your answer, the problem is solved but it gives me the high loss rate which implies a bad detection, so please what should I do to correct it.
Epoch 30/30
100/100 [==============================] - 784s 8s/step - batch: 49.5000 - size: 1.0000 - loss: 0.3552 - rpn_class_loss: 0.0052 - rpn_bbox_loss: 0.1705 - mrcnn_class_loss: 0.0218 - mrcnn_bbox_loss: 0.0532 - mrcnn_mask_loss: 0.1044 - val_loss: 3.8523 - val_rpn_class_loss: 0.1956 - val_rpn_bbox_loss: 2.3940 - val_mrcnn_class_loss: 0.3829 - val_mrcnn_bbox_loss: 0.3561 - val_mrcnn_mask_loss: 0.5238
PLEASE HELP ME
thanks, ma'am .. Please upload one video on DetectoRS: Detecting Objects with Recursive Feature Pyramid and Switchable Atrous Convolution for a custom dataset
Sure, Will try to upload soon
amazing
Thanks
Thanks for such a clear explanation. Which python, tensorflow and keras version are you using.
Python 3.6.8, tensorflow 1.14
Thank you for the explanation, I want to know if I have a big dataset (more than 1000 images) should I annotate all the images ?
Yes you need to annotate all the images
@@CodeWithAarohi it will be so much time consuming.
Helpful Videos
Glad to hear that
Hello Aarohi. Thank you for the kind explanation. But I am encountering an error when executing. In my dataset, I have 21 training data and 09 validation data. At the time of execution, an error appears like 'No such File' giving the path of validation folder. The file, program is looking for, is in the training folder. But it searches for that particular file in the validation folder as well. How can I solve this?. Hope this is clear to you
Hi I've got a same problem. Can you fix it? If so can you tell me pls
@@vajirastanley5216 even I have the same issue. did you get a solution? :(
I was facing same problem
1. Place Json file in val and train folder with "same name"
2. Give json file path like this:
annotations=json.load(open(os.path.join(dataset_dir, 'Json file name')))
I hope it helps
@@harinderkaur8320 this work. Thanks !
@@richasharma5949 Hi... Can you please tell what exactly did you do? I didn't understood.
Thank you for this video, I'm implementing RCNN on satellite images, but I'm not getting the desired accuracy score. After considering Augmentation techniques, I was wondering if there is a way to choose the best Augmentation technique. Please Help! Thanks in advance!
You can try simulated atmospheric effects or geometric transformations to simulate different angles and perspectives.
i could not run the same python code in the command prompt
may I ask you ?
as far as I understood in log folder we'll get trained weights, not full model, won't we ?
And could you help me ? how can I convert this output to JS model.
I should train model and load this weights (which I got after your tutorial) to my new model ?
Dear mam ,
I tried as you said .. Initially some errors came i cleared all those errors, now it is in FIRST EPOCH for nearly more than 3 hours ... i have only 10 images ... Kindly help pls
Thank you for the explanation, but please , How we can convert json file into images to be trained or tested with CNN in another program?
Hello mam, thanks for the implementation, very clear !
Do you think that counting number of objects in a dense scene is possible through mask rcnn, for exemple in wood logs ?
AttributeError: module 'keras.engine' has no attribute 'Layer' while running the code python custom.py. Could you please help me ?
Use keras 2.2.4
Dear Aarohi ,
for validation I have three images, then why it is showing error that 4.jpg is not found?
FileNotFoundError: No such file: 'C:\Users\HP\Desktop\Aarohi\MASK_RCNN\env\venv36\mask_rcnn\dataset\val\4.jpg'
Actually, Val folder have three images named 1.jpg, 2.jpg, and 3.jpg; so why is it asking for 4.jpg?
The projection is many time blurry and hard to see, I suggest to record videos for youtube separately by screen-recording
sure
Mam,how to use this code in python Jupyter notebook.
This mrcnn repository code from github where to place , while running this code in python Jupyter notebook.
Paste the whole code in jupyter notebook
@@CodeWithAarohi ok mam.
Thank you so much for your reply ....
Video is very helpful for me to do my project.
@@ragisimon4069 welcome
@@CodeWithAarohi eagerly waiting for test video of maskrcnn algorithm....
ma'am How can i resolve this error:- *TypeError: unhashable type: 'ListWrapper'*
The "unhashable type: 'ListWrapper'" error typically occurs when you are trying to use a list as a key in a dictionary. In Python, dictionaries are data structures that store key-value pairs, where the keys must be unique and immutable. Since a list is a mutable data type, it cannot be used as a dictionary key.
To resolve this error, you will need to convert the list to an immutable data type, such as a tuple, before using it as a dictionary key. For example, you could use the following code to convert the list to a tuple and then use it as a dictionary key:
Copy code
list_key = ["hello", "world"]
tuple_key = tuple(list_key)
my_dict = {tuple_key: "value"}
Alternatively, you could use the list as the value in the dictionary, rather than the key. This would allow you to store multiple values for each list, as long as the lists themselves are unique:
Copy code
list_key = ["hello", "world"]
my_dict = {list_key: "value"}
Maam im trying to train my model in colab but its using CPU rather than GPU provided by colab, and because of that training is taking much more time to complete what could be the issue?
Hi, How to configure Gpu while running offline? What should be the value of GPU_COUNT while using GPU?
if your system has four GPUs and you want to utilize all of them, you would set GPU_COUNT to 4. On the other hand, if you only want to use a single GPU, you would set GPU_COUNT to 1.
@@CodeWithAarohi I am running your code using 600 images and each epoch is taking around 18 mins. I feel the model is not training through GPU. How to check it? I am running my code on a laptop with 16 GB RTX 3080ti.
@@devavratpro7061have u run it on gpu
thank you very much!!!
Do you think that counting number of objects possible through mask RCNN?
mam how to resize the custom data as the model is not accepting the images
Hey Aarohi, in real life deep learning study one can have thousands of images, so annotation has to be done manually or any special tool is available ?
You have to annotation yourself. There are Organizations who provide annotation services but those are paid services
Very nice and detailed , maybe next video how to run it on Colab ?
Will try to do that.
assert LooseVersion(keras.__version__) >= LooseVersion('2.0.8')
^^^^^^^^^^^^^^^^^
AttributeError: module 'tensorflow.keras' has no attribute '__version__'
Mam i am getting this error i have seen all resources but unable to rectify it please once look at this error please mam...................This error is occuring in model.py file
I think its better to share the screen than presenting using a projector
Yeah... Redo of this same video: czcams.com/video/t1MrzuAUdoE/video.html
Hope this helps
this is very nice tutorial mam. I have some questions, actually i m working on a project, in which i want to segment a particular object with the help of mask rcnn, opencv and raspberry pi 4, please guide me how to do it. i m new in the deep learing . thank you in advance
you can mail me at aarohisingla1987@gmail.com . I will try to help you
My annotation git other format of json and etch image has a his file json .. do how i Can use R-cnn with this ? Thanks dear
For Mask-RCNN , you need 1 json file which will have data of all the images in your training set. You can combine the data of all json files into 1 and can try.
How to do this if we have very large dataset ?
You have to annotate the entire dataset and follow the same steps which I mentioned in this video.
hello maam, thanks for the implementation. but, can you tell me the name of annotation aplication?
VGG Annotator
Getting an error-
TypeError: Could not build a TypeSpec for with type KerasTensor
Can you please help?
share your code on my emailid
same here mam, I got exactly the same error. 😔" TypeError: Could not build a TypeSpec for with type KerasTensor "
what was the reason for this? and I really love your tutorial series btw🧡
@@CodeWithAarohi ok ma'am
i changed tensorflow_version to 1.x and now its working
@@lalinduwenasara2515 Oh! Ok! I'll try that.
I'm getting this error while training the model.
I've been trying to go through the code step by step but errors keep popping up
OperatorNotAllowedInGraphError: using a `tf.Tensor` as a Python `bool` is not allowed in Graph execution. Use Eager execution or decorate this function with @tf.function.
which tensorflow version and keras version you are using?
having error on load_custom() missing 1 required positional argument: 'subset'
please share the whole error message
Nicely explained! Great job. Could I know wether we can just test this example on a computer with no GPU? Can run a simple maskrcnn algorithm on CPU?
Yes you can run on CPU
@@CodeWithAarohi thank you so much for your prompt response. Should I change anything in the code if I use only CPU? Like "images per GPU" or "GPU count"
@@nishshankas.rodrigo335 was you able to run it on CPU? if yes, what changes have you made?
@@vikashkumar-cr7ee No. It didn't work and I gave up the attempt 😭
Hello maam.....I am getting error in tensorflow that no attribute placeholder . The version I am using is tensorflow 1.14.0 and keras is 2.0.5
Try to use keras 2.3.0
Is this mask rcnn method is suitable to segment spine from spine xray image?
Hello Mam, what if we have our dataset huge. we cannot annotate each image in VGG tool, any other option for that ?.
Annotation required on all the images. You can use any annotation tool. There are organizations who provide AI powered annotation tools
Madam I got error as "----> 1 model.train(dataset_train, dataset_val,
2 learning_rate=config.LEARNING_RATE,
3 epochs=10,
4 layers='heads')
5
NameError: name 'model' is not defined" ....
how to over come this error
you have to check the last 8-10 lines of your custom.py file. This error says that model is not defined.
Madam first I thank you for clearly explaining MRCNN...when I tried to excuit I have got errors...then after seeing comment section...then I started installing python 3.6.8, tensor flow 1.14 and keras 2.2.5...and started executing...then I got error w.r.t to skimage...I tried pip install skimage...again got error... version not supporting...go for scikit image install...but even with that it is not working..so could you tell me how can I over come with this issue... trying to execute it from a week after I am sending this message... thanks in advance..
scikit-image 0.17.2
scikit-learn 0.24.2
!pip uninstall scikit-image
!pip install scikit-image==0.16.2
The idea was to train with own dataset (laptop, phone, tab) but you trained with other dataset (horse, man) , why?
I am a bit confused, are the validation images the same as the train images ? or a different set of annotated images? thank you.
Different set of images
Hello Ma'am.... Thank you soo much for this detailed explanation.
But ma'am I have a doubt that we are annotating the train and Val images both and making separate json file for both of them but in this code you are using only the train json file.
So do we have to copy the train json file in the Val folder or we have to make different json file with same name?
Ma'am please respond as soon as possible... Its urgent.
Yes, correct
thank u for the explanation, mam i want to know whether we can load the mask of images if its available in dataset . rather than generating the mask using the certain function in code
while doing with the code given , its showing the error : warning : you are using default load mask,may you need to define ur own one..................
what to do for this kind
@@nezlana3475 this is just warning .. You can ignore this. This will not effect your code
@@CodeWithAarohi no mam, training results are not being shown ....its continuosly showing this error
@@nezlana3475 I am facing same problem...your problem is resolved or not ? If resolved plz help
hello Aarohi, I have tried to test the detection on my own dataset.
There is no error but I got this message : "NO INSTANCE TO DISPLAY"
I see instances but the detection are not good
This error means Algorithm is not detection anything . Increase the number of Epochs.
@@CodeWithAarohi ok i will try,
thanks so much.
Thank you for the video. How do you convert the Mask RCNN model to TFLite and then deploy it on android device?
Welcome and I never tried on android device so right now no idea
You can use converter= tflite.TFLiteConverter.from_keras_model(keras_model)
keras_model=model.keras_model
tfmodel=converter.convert()
To convert model to tflite.
Hi Aarohi, what is the size in json file? We try to getting custom json with code but we couldn't understand what refer to 'size' info
Getting an Error:
I'm working on my own dataset, and i followed same steps but got an error
Traceback (most recent call last):
File "custom.py", line 201, in
train(model)
File "custom.py", line 167, in train
dataset_train.load_custom(r"D:/Rammohan/AI ML Projects/Mask RCNN/dataset","train")
File "custom.py", line 97, in load_custom
polygons = [r['shape_attributes'] for r in a['regions']]
File "custom.py", line 97, in
polygons = [r['shape_attributes'] for r in a['regions']]
TypeError: string indices must be integers
Can I get dataset which you have have prepared???
provide me your email id. I will send
Excellent video! Is there a way to save the masks encountered by the model in any vector or raster formats?
thanks in advance :)
I think we can store that but never tried it
If we got the pre-trained COCO weight , can we use already COCO labels plus with our custom labels ??? Thank you
yes you can do that.
@@CodeWithAarohi sorry but how we can add classes of COCO dataset in testing code ?
we add to by
self.add_classes ???
Ex:
self.add_class("object", 1, "laptop")
self.add_class("object", 2, "phone")
self.add_class("object", 3, "tab")
self.add_class("object", 4, "bag")
Is it right
Thank you
Hello Ma'am, I followed the image annotation process as it was shown, in my case though I have only one type of object to identify but after downloading the json file , the name of id isn't showing up for the region_attributes, for eg looks like this: "region_attributes":{}}, though the shape attributes are coming as shown, what could be the reason for this?
your json file is blank. There must be some problem while doing the annotation. try to do it again. You might have missed something. Check the process in the video properly and try again. If you still gets blank file after that then I will help you
Mam , when I try to run this code I am getting error. I tried different versions of tensorflow and keras but didn't find any solution. I also tried tensorflow==1.14.0 and keras ==2.0.8 but getting too many errors. could you please make a environment setup video? it will be very helpful .
You can try with tensorflow 1.14.1 and keras 2.3.0
prerequisites:
1)Tensorflow 1.15.2
2)Keras 2.3.1
3)h5py < 3.0.0 so 1.21.5 (!pip install 'h5py
Can you make some videos on mmdetection toolbox ?
It's has good collection of detection models.
Noted! Will try to do after finishing my pipelined videos
I've tried tf version 1.14.0 and keras==2.3.0 but come up with this error when I run the custom.py file
AttributeError: module 'tensorflow._api.v1.compat.v2.compat' has no attribute 'v1'
I tried installing tf 1.14.1 as you are using but it said only 1.14.0 or 1.14.0rc1 exists.
Can you tell what might be wrong? I have changed the GPU count to 0 in config file as well as I don't have a GPU in my machine.
would appreciate any help
Create a separate environment. And the python version I am using python 3.6.8, tensorflow 1.15.0, keras 2.2.5 and h5py version 2.10.0 . This mask rcnn code will work with these versions
@@CodeWithAarohi thanks it resolved the issue that I posted above. However now i'm facing this error:
objects = [s['region_attributes']['names'] for s in a['regions']]
KeyError: 'names'
line 98 of cutom.py file, Previously I set it as 'name' as in your video but the same error came. I changed it to names as in the VGG annotator tools you had defined 'names' in region attributes and not 'name'. Can you tell what might be the possible reason of this error :(
Thank you for your efforts. I have made my custom dataset and run the code successfully.
I have almost 12 images altogether, but the training process get stuck in the first epoch. After waiting for more than 2 hours, a folder got created in the "logs" directory but it contains a file with a really weird name and extension. "events.out.tfevents.1659180925.dfd413d54739" is the file. I have tried different methods to somehow convert it to .h5 but failed.
Any kind of help will be highly appreciated.
We are working using tensorflow and this file is created by FileWriters and are generally used to store summary output. You can later delete it. But this is not your stored model. Start your training again and wait until you get the .h5 file. You will get the .h5 file when training starts ( you will see epochs execution on your screen).
@@CodeWithAarohi Thank you so much ma'am.
Hellow, I ran the program on an anaconda environment (Vscode), but I don't know how to get the final image of my program, can you show me how?
please explain me the problem which you are facing.
@@CodeWithAarohi taking your example on jupyter, at the end of the running of the program, at the bottom, you have the image of the phone + laptob +tab, how can we have this final image with anaconda on VS code
Hi may I know which python version are you running on
python 3.6.8 and tensorflow 1.14
Thank you for the explanation. Whne I am trying mask rcnn on custom dataset I am getting th error: class ProposalLayer(KE.Layer):
AttributeError: module 'keras.engine' has no attribute
try to use keras version 2.3.0
@@CodeWithAarohi AttributeError: module 'tensorflow._api.v1.compat.v2.compat' has no attribute 'v1' when using keras 2.3.0
@@seetharamnageshappe5013 any luck resolving this problem? I am facing the same issue
@@shahzebimtiaz1849Yes, I am able to resolve it by installing !pip install keras==2.1.0
%tensorflow_version 1.x
!pip install h5py==2.10.0
and then started cloning git repository.
Try with this.
@@seetharamnageshappe5013 are you running it on colab?
madam do I have to take same images for 'val' which i have taken in 'train'...or it should be different...i have taken different images i got error .....then i have taken some of images in val same as train.... for then it is not showing error........but now again it show error........
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\MaskRCNN\\Dataset\\val\\bu103.jpg'.....because this bu103 is there in train but not in val.....thanks in advance madam.
This error is because it is only reading images of train folder because we have mention the json file path of train folder. Make few changes in custom.py so that it will read all the images from train and val folder 1 by 1.
Thank you madam
@@CodeWithAarohi madam do we have to add json file of validation in annotations1
"dataset_dir = os.path.join(dataset_dir, subset)
annotations1 = json.load(open".....
i have followed your both MRCNN videos but in that both codes no where mentioned about validation json file.....pls help help me in this regard thank you
@@rakeshgnits yes right. Use if else statement and read both the annotation files one by one in annotation1 variable
@@rakeshgnits were you able to resolve the issue?
Is there no need of jupitor notebook to run our mask rcnn code?
No need of jupyter
Where can I find the next video for testing?
You explained very deeply super. Mam we can run this code in colab as it is, because I don't have gup. To run in colab let me know how to do. Please
Yes you can run this code on colab. There are steps available. You can follow the steps given here: www.analyticsvidhya.com/blog/2020/03/google-colab-machine-learning-deep-learning/
Thank u
@@geethaneya2452 Hi did the code work for you on Collab??
ImportError: cannot import name 'get_config' from 'tensorflow.python.eager.context' (/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/context.py). im getting this error when running mask rcnn in colab
this code will work on tensorflow 1.13 or 1.14 . Check your tensorflow version
@@CodeWithAarohi thank you
21 from mrcnn.visualize import display_images
22 from mrcnn.visualize import display_instances
---> 23 import mrcnn.model as modellib
24 from mrcnn.model import log
25 from mrcnn.config import Config
/content/Mask_RCNN/mrcnn/model.py in ()
253
254
--> 255 class ProposalLayer(KE.Layer):
256 """Receives anchor scores and selects a subset to pass as proposals
257 to the second stage. Filtering is done based on anchor scores and
AttributeError: module 'keras.engine' has no attribute 'Layer'
Hello Ma'am
I have 7 category but the JSON file is seperat for each class how should we train the data in such case?
Ma'am and each category have 1000 -1000 images in it??
Ma'am and at NUM_CLASSES= 1+ a
a=7 if I have 7 category right??
And ma'am do we need to create logs file ?
Or it will be created automatically while running??
Hi, Log file will get created itself. And you are right about class concept. Good Keep it up
@@CodeWithAarohi Thank You Ma'am
Ma'am I had one more question regarding which version of tensor flow and keras is required
@@CodeWithAarohi And ma'am I have 7 category but in 7 different JSON files so do I need to combine them?
Which Tensorflow, Kerasa, Python version is suitable ?
Tensorflow 1.14.1, keras 2.3.0 and python 3.6.8
I want to create a model which identifies whether a car is damaged or not... I have got a dataset which contains separate folders of damaged cars and cars which are not damaged. So is the initial annotation necessary for this dataset? because, here every photo contains only one object.
Yes you need to annotate for single object also.
@@CodeWithAarohi oh okay... Thankyou! I had few more doubts... Can I contact you via some way? Your video is a saviour ...! Thanks a lot for this!
@@siddhichaukade sure you can mail me aarohisingla1987@gmail.com
@@CodeWithAarohi ok thankyou once again...!
@@siddhichaukade welcome
TypeError: Could not build a TypeSpec for with type KerasTensor
Can you solve me this error......
Use tensorflow 1.14.1 and keras 2.3.0
@@CodeWithAarohi error resolved... Thanq ☺️
@@sharathchandra4727 HI
I am getting same error. How it is resolved?please help me
MAdam How to calculate Accuracy and Confusion matrix for mask rcnn
You need to write a separate function for calculating confusion matrix and MAP. Will cover this in my next video of Mask RCNN
@@CodeWithAarohi Thank you. When you are going to post the next video to calculate accuracy
it's not moving beyond step1/10 of epoch
sometime it takes time. It is due to to resources you are using for training. What is your PC Configuration
l changed the keras and tensorflow versiyons and l rewrote the code because l guess l made mistakes in the code . Then the training started. Yes , it tooked time . As you said , it is due to the PC configuration l am using.
Ram 8GB
Process Intel i5
GPU NIVIDA GeForce GTX 1650 Ti
I am using gpu for training . Thank you for your time hocam .
numpy version ?
numpy version 1.19.5
Can we implement this if we have no GPU in our machine?
yes, you can use it. For more details: you can check config.py file under mrcnn folder. See line number 27 and 28.
@@CodeWithAarohi thanks Aarohi for your prompt reply.