Code Monkey home page Code Monkey logo

Comments (5)

z-mahmud22 avatar z-mahmud22 commented on July 25, 2024

Hi @nicejava, could you please elaborate on what you mean by it predicts wrong class by sharing the results you are getting?

from mask-rcnn_tf2.14.0.

nicejava avatar nicejava commented on July 25, 2024

Thank for reply

ok i try train 5 class CLASS_NAMES = ['A', 'B', 'C', 'D', 'E']

# Number of classes (including background)
NUM_CLASSES = 1 + 5  # Background + object

And I have image for testing 5 class too like this

01.jpg = class A
02.jpg = class B
03.jpg = class C
04.jpg = class D
05.jpg = class E

So after trained i try testing each image but result display first always is 'A'
No matter where I use it, the results are the same, which is A

such as i try testing 03.jpg which should have received the answer C, but instead received the answer A

r = model.detect([image], verbose=0)
r = r[0]
result r['class_ids'] is 1 every time testing ( [1 1] : [0.97279286 0.9367134 ] )

from mask-rcnn_tf2.14.0.

z-mahmud22 avatar z-mahmud22 commented on July 25, 2024

You would also need to register these class names and assign class_id in your Dataset class when training using the add_class function here. Without this, the model will not learn the specific classes during training and would produce random results during inference.

Please follow this tutorial as it gives you a proper walkthrough on how to train mask-rcnn using your own dataset.

from mask-rcnn_tf2.14.0.

nicejava avatar nicejava commented on July 25, 2024

I try added class like this, draw mask correct predict shape very good. But label show first always it's incorrect result label

image

I used mrcnn-prediction.py code for predict

model.detect return 1 always

.. thanks

from mask-rcnn_tf2.14.0.

z-mahmud22 avatar z-mahmud22 commented on July 25, 2024

It's NOT incorrect class labels that your model is returning. In fact, your model is always returning 1 as the class label. I think you are directly copying the BalloonDataset class which is particularly designed for 1 class. Notice that the load_mask() function is always returning an array of ones (as class IDs) along with the masks.

However, in your case, there are 5 different classes. You'd also need to return particular class indices when returning the masks. You can follow the solution suggested in this issue to fix your problem and retrain the network again.

Particularly, you would need to pass the list of your class_ids when loading image with add_image() here and update the return from load_mask() with this return mask, info['class_ids'].

Additionally, you can follow the notebook that illustrates how to train Mask R-CNN on the Shapes dataset which happens to be a multiclass dataset similar to yours. I hope this answers your question.

from mask-rcnn_tf2.14.0.

Related Issues (13)

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.