How to detect person only instead of whole labeled objects using tensorflow object-detection API?
I want to detect person only in a given picture (with person, cat, bicycle etc on it) using Tensorflow object detection API (and a pre-trained model "ssd_mobilenet_v1_coco_2017_11_17/frozen_inference_graph.pb"). How should I modify the following code? Maybe I should modify this line detection_graph.get_tensor_by_name('detection_classes:0')
, but I have no idea what exactly I should do. Help me my friends, please! Thank you in advance. Or some references will also be great.
def detect_objects(image_np, sess, detection_graph):
# Expand dimensions since the model expects images to have shape: [1, None, None, 3]
image_np_expanded = np.expand_dims(image_np, axis=0)
image_tensor = detection_graph.get_tensor_by_name('image_tensor:0')
# Each box represents a part of the image where a particular object was detected.
boxes = detection_graph.get_tensor_by_name('detection_boxes:0')
# Each score represent how level of confidence for each of the objects.
# Score is shown on the result image, together with the class label.
scores = detection_graph.get_tensor_by_name('detection_scores:0')
classes = detection_graph.get_tensor_by_name('detection_classes:0')
num_detections = detection_graph.get_tensor_by_name('num_detections:0')
# Actual detection.
(boxes, scores, classes, num_detections) = sess.run(
[boxes, scores, classes, num_detections],
feed_dict={image_tensor: image_np_expanded})
# Visualization of the results of a detection.
vis_util.visualize_boxes_and_labels_on_image_array(
image_np,
np.squeeze(boxes),
np.squeeze(classes).astype(np.int32),
np.squeeze(scores),
category_index,
use_normalized_coordinates=True,
line_thickness=8)
return image_np
object tensorflow detection
add a comment |
I want to detect person only in a given picture (with person, cat, bicycle etc on it) using Tensorflow object detection API (and a pre-trained model "ssd_mobilenet_v1_coco_2017_11_17/frozen_inference_graph.pb"). How should I modify the following code? Maybe I should modify this line detection_graph.get_tensor_by_name('detection_classes:0')
, but I have no idea what exactly I should do. Help me my friends, please! Thank you in advance. Or some references will also be great.
def detect_objects(image_np, sess, detection_graph):
# Expand dimensions since the model expects images to have shape: [1, None, None, 3]
image_np_expanded = np.expand_dims(image_np, axis=0)
image_tensor = detection_graph.get_tensor_by_name('image_tensor:0')
# Each box represents a part of the image where a particular object was detected.
boxes = detection_graph.get_tensor_by_name('detection_boxes:0')
# Each score represent how level of confidence for each of the objects.
# Score is shown on the result image, together with the class label.
scores = detection_graph.get_tensor_by_name('detection_scores:0')
classes = detection_graph.get_tensor_by_name('detection_classes:0')
num_detections = detection_graph.get_tensor_by_name('num_detections:0')
# Actual detection.
(boxes, scores, classes, num_detections) = sess.run(
[boxes, scores, classes, num_detections],
feed_dict={image_tensor: image_np_expanded})
# Visualization of the results of a detection.
vis_util.visualize_boxes_and_labels_on_image_array(
image_np,
np.squeeze(boxes),
np.squeeze(classes).astype(np.int32),
np.squeeze(scores),
category_index,
use_normalized_coordinates=True,
line_thickness=8)
return image_np
object tensorflow detection
add a comment |
I want to detect person only in a given picture (with person, cat, bicycle etc on it) using Tensorflow object detection API (and a pre-trained model "ssd_mobilenet_v1_coco_2017_11_17/frozen_inference_graph.pb"). How should I modify the following code? Maybe I should modify this line detection_graph.get_tensor_by_name('detection_classes:0')
, but I have no idea what exactly I should do. Help me my friends, please! Thank you in advance. Or some references will also be great.
def detect_objects(image_np, sess, detection_graph):
# Expand dimensions since the model expects images to have shape: [1, None, None, 3]
image_np_expanded = np.expand_dims(image_np, axis=0)
image_tensor = detection_graph.get_tensor_by_name('image_tensor:0')
# Each box represents a part of the image where a particular object was detected.
boxes = detection_graph.get_tensor_by_name('detection_boxes:0')
# Each score represent how level of confidence for each of the objects.
# Score is shown on the result image, together with the class label.
scores = detection_graph.get_tensor_by_name('detection_scores:0')
classes = detection_graph.get_tensor_by_name('detection_classes:0')
num_detections = detection_graph.get_tensor_by_name('num_detections:0')
# Actual detection.
(boxes, scores, classes, num_detections) = sess.run(
[boxes, scores, classes, num_detections],
feed_dict={image_tensor: image_np_expanded})
# Visualization of the results of a detection.
vis_util.visualize_boxes_and_labels_on_image_array(
image_np,
np.squeeze(boxes),
np.squeeze(classes).astype(np.int32),
np.squeeze(scores),
category_index,
use_normalized_coordinates=True,
line_thickness=8)
return image_np
object tensorflow detection
I want to detect person only in a given picture (with person, cat, bicycle etc on it) using Tensorflow object detection API (and a pre-trained model "ssd_mobilenet_v1_coco_2017_11_17/frozen_inference_graph.pb"). How should I modify the following code? Maybe I should modify this line detection_graph.get_tensor_by_name('detection_classes:0')
, but I have no idea what exactly I should do. Help me my friends, please! Thank you in advance. Or some references will also be great.
def detect_objects(image_np, sess, detection_graph):
# Expand dimensions since the model expects images to have shape: [1, None, None, 3]
image_np_expanded = np.expand_dims(image_np, axis=0)
image_tensor = detection_graph.get_tensor_by_name('image_tensor:0')
# Each box represents a part of the image where a particular object was detected.
boxes = detection_graph.get_tensor_by_name('detection_boxes:0')
# Each score represent how level of confidence for each of the objects.
# Score is shown on the result image, together with the class label.
scores = detection_graph.get_tensor_by_name('detection_scores:0')
classes = detection_graph.get_tensor_by_name('detection_classes:0')
num_detections = detection_graph.get_tensor_by_name('num_detections:0')
# Actual detection.
(boxes, scores, classes, num_detections) = sess.run(
[boxes, scores, classes, num_detections],
feed_dict={image_tensor: image_np_expanded})
# Visualization of the results of a detection.
vis_util.visualize_boxes_and_labels_on_image_array(
image_np,
np.squeeze(boxes),
np.squeeze(classes).astype(np.int32),
np.squeeze(scores),
category_index,
use_normalized_coordinates=True,
line_thickness=8)
return image_np
object tensorflow detection
object tensorflow detection
asked Nov 23 '18 at 3:30
gerygery
5818
5818
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
If I understand it correctly, you have to know the class label for person, then you can select only for that class in the part where you visualize the result of detection. Assuming the classes
and boxes
can be sliced.
Thank you for comment. I feel I've found some useful materials, I'm now trying to understand it. Maybe few days later, I'll solve this problem and post the anwer.
– gery
Nov 26 '18 at 1:09
But still welcome many other possible answers ^_^
– gery
Nov 26 '18 at 1:10
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440338%2fhow-to-detect-person-only-instead-of-whole-labeled-objects-using-tensorflow-obje%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If I understand it correctly, you have to know the class label for person, then you can select only for that class in the part where you visualize the result of detection. Assuming the classes
and boxes
can be sliced.
Thank you for comment. I feel I've found some useful materials, I'm now trying to understand it. Maybe few days later, I'll solve this problem and post the anwer.
– gery
Nov 26 '18 at 1:09
But still welcome many other possible answers ^_^
– gery
Nov 26 '18 at 1:10
add a comment |
If I understand it correctly, you have to know the class label for person, then you can select only for that class in the part where you visualize the result of detection. Assuming the classes
and boxes
can be sliced.
Thank you for comment. I feel I've found some useful materials, I'm now trying to understand it. Maybe few days later, I'll solve this problem and post the anwer.
– gery
Nov 26 '18 at 1:09
But still welcome many other possible answers ^_^
– gery
Nov 26 '18 at 1:10
add a comment |
If I understand it correctly, you have to know the class label for person, then you can select only for that class in the part where you visualize the result of detection. Assuming the classes
and boxes
can be sliced.
If I understand it correctly, you have to know the class label for person, then you can select only for that class in the part where you visualize the result of detection. Assuming the classes
and boxes
can be sliced.
answered Nov 23 '18 at 13:05
D.negnD.negn
9325
9325
Thank you for comment. I feel I've found some useful materials, I'm now trying to understand it. Maybe few days later, I'll solve this problem and post the anwer.
– gery
Nov 26 '18 at 1:09
But still welcome many other possible answers ^_^
– gery
Nov 26 '18 at 1:10
add a comment |
Thank you for comment. I feel I've found some useful materials, I'm now trying to understand it. Maybe few days later, I'll solve this problem and post the anwer.
– gery
Nov 26 '18 at 1:09
But still welcome many other possible answers ^_^
– gery
Nov 26 '18 at 1:10
Thank you for comment. I feel I've found some useful materials, I'm now trying to understand it. Maybe few days later, I'll solve this problem and post the anwer.
– gery
Nov 26 '18 at 1:09
Thank you for comment. I feel I've found some useful materials, I'm now trying to understand it. Maybe few days later, I'll solve this problem and post the anwer.
– gery
Nov 26 '18 at 1:09
But still welcome many other possible answers ^_^
– gery
Nov 26 '18 at 1:10
But still welcome many other possible answers ^_^
– gery
Nov 26 '18 at 1:10
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440338%2fhow-to-detect-person-only-instead-of-whole-labeled-objects-using-tensorflow-obje%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown