Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

extracting the object detected only#108

Unanswered
AnasAlmana asked this question inQ&A
Apr 28, 2022· 2 comments· 12 replies
Discussion options

Hi, I have created custom object detection model and exported it under saved_model/saved_model.pb
Now, I want to extract the detected object in a new image or in other word how can I get the coordinates of the object.
If you have any script to do that please provide me that.

Thanks.

You must be logged in to vote

Replies: 2 comments 12 replies

Comment options

Have you checked out theExamples section?

You must be logged in to vote
12 replies
@sglvladi
Comment options

So, in the above example, it seems you got 100 detections.

Each row in the above contains the normalised coordinates in the following form[x_min, y_min, x_max, y_max]. To get the actual coordinates, you need to multiplyx_min andx_max of each detection by the width of the image, and, similarly,y_min andy_max by the height of the image.

Also, make sure to convert the results to integer values.

@AnasAlmana
Comment options

well, I have only one object that has been detected but may be it looks like this because of this line>>

The model expects a batch of images, so add an axis withtf.newaxis.

input_tensor = input_tensor[tf.newaxis, ...]

Also, acoording to the comments in the above code we are only intrested in the first num_detection so I took the first array >>

[0.36031908 0.5819093 0.6042158 0.99556196]

and then multiplied it by the width and height then I used the result to cut the detected object by this method you provided:https://www.geeksforgeeks.org/how-to-crop-an-image-using-the-numpy-module/

but the cut is not correct, do you have another cropping method using x_min y_min x_max y_max?

@sglvladi
Comment options

Hmmm, that's interesting.

When you sliced the array, did you do it as follows?

cropped = original[y_min:y_max, x_min:x_max]

Note:x_min, y_min, etc here refer to the unnormalised coordinates.

@sglvladi
Comment options

Ahhh, I just noticed I may have made a mistake. The coordinates returned by the detector are of the form[y_min, x_min, y_max, x_max], and not[x_min, y_min, x_max, y_max]!

@AnasAlmana
Comment options

Thank you so much. Finally I got what I want.

Comment options

Hi, can you help me on this.
I have exported model named saved_model.pb
how can I change the extension of this model?

You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@AnasAlmana@sglvladi

[8]ページ先頭

©2009-2025 Movatter.jp