Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to retrieve predicted boxes from a predicted image #1083

Closed
GMSL1706 opened this issue Mar 31, 2022 · 8 comments
Closed

How to retrieve predicted boxes from a predicted image #1083

GMSL1706 opened this issue Mar 31, 2022 · 8 comments

Comments

@GMSL1706
Copy link

Hello,

I am working on license plate recognition and I would like to retrieve the boxes predicted by my model in order to be able to recognize the characters of the license plate as in this example

Can someone help me please ?

@fstroth
Copy link
Contributor

fstroth commented Mar 31, 2022

Hey, currently we don't have an integration with any ocr system. You might want to take a look here for ocr stuff.

@GMSL1706
Copy link
Author

Sorry but I just want to make sure. Is there no way to save the predicted boxes as a list, integer or some other variable that we can use for other things?

@GMSL1706 GMSL1706 reopened this Mar 31, 2022
@fstroth
Copy link
Contributor

fstroth commented Mar 31, 2022

All good, the predictions are just regular python objects so you can just save them as you like (pickle, json, etc.)

@GMSL1706
Copy link
Author

Can you show me how to do that ? Because I've tried but I didn't find the way to do that

here is an example of my code

model = model_type.model(backbone=backbone(pretrained=True), num_classes=len(parser.class_map), **extra_args) 

# Selection = 0
state_dict = torch.load("./resnet50_fpn_mstrain_2x.pth")
model.load_state_dict(state_dict)

infer_dl = model_type.infer_dl(valid_ds, batch_size=4, shuffle=False)
preds = model_type.predict_from_dl(model, infer_dl, keep_images=True)

show_preds(preds=preds[3:4], show=True, display_label=True, figsize=(15, 20))

And Here is the output of prediction:

téléchargement (2)

Which code could I use to save the predicted boxes please ?

@FraPochetti
Copy link
Contributor

Here it is
image

@GMSL1706 GMSL1706 changed the title How to retrieve predicted boxes from an predicted image How to retrieve predicted boxes from a predicted image Mar 31, 2022
@GMSL1706
Copy link
Author

GMSL1706 commented Mar 31, 2022

Thank you very much. That help me a lot.

As I have the boxes data, I tried to use rectangle function of opencv lib as here on the same image. But I realize that I have to use the predicted image because there was some processing on the original data (I suspect that the boxes data are for processed images... I could be wrong) and it is difficult for me to work with the original image.

Is there any function that can help to save the predicted image with preds[0] as a numpy array something like that according to the boxes data please ?

@FraPochetti
Copy link
Contributor

Check out end2end_detect inside the inference tutotial for what you are asking

@GMSL1706
Copy link
Author

GMSL1706 commented Apr 1, 2022

THANK YOU VERY MUCH !!!!!!!!!!!! I AM VERRY HAPPY

@GMSL1706 GMSL1706 closed this as completed Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants