Tensor Flow Object detection API notifications










1















Tensorflow 1.12.0
Python 3.5.0
Windows 10



Hello all, I've created my own object detection model based on tensorflows object detection tutorial. I want to notify by SMS (via a service like twilio) when a object is detected, but I don't want to be notified by every frame of the same object class, instead I'd like to have a delay between text messages of objects i.e. every 5 seconds (at least) between every call. I've looked at threading and timer, but I fear that I'll restart the threading and timer every for call and was wondering if their is a more efficient way via the object detection API to accomplish this task. I know that I can print the actual class detected via



print [category_index.get(value) for index,value in enumerate(classes[0]) if scores[0,index] > 0.5]


in the code



with detection_graph.as_default():
with tf.Session(graph=detection_graph) as sess:
while True:
ret, image_np = cap.read()
# 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)

cv2.imshow('object detection', cv2.resize(image_np, (800,600)))
if cv2.waitKey(25) & 0xFF == ord('q'):
cv2.destroyAllWindows()
break


but again, I don't want an overflow of text messages to my phone, and I don't want my script to pause neither.. if any suggestions can be given, I'd appreciate it. Thank you all.










share|improve this question


























    1















    Tensorflow 1.12.0
    Python 3.5.0
    Windows 10



    Hello all, I've created my own object detection model based on tensorflows object detection tutorial. I want to notify by SMS (via a service like twilio) when a object is detected, but I don't want to be notified by every frame of the same object class, instead I'd like to have a delay between text messages of objects i.e. every 5 seconds (at least) between every call. I've looked at threading and timer, but I fear that I'll restart the threading and timer every for call and was wondering if their is a more efficient way via the object detection API to accomplish this task. I know that I can print the actual class detected via



    print [category_index.get(value) for index,value in enumerate(classes[0]) if scores[0,index] > 0.5]


    in the code



    with detection_graph.as_default():
    with tf.Session(graph=detection_graph) as sess:
    while True:
    ret, image_np = cap.read()
    # 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)

    cv2.imshow('object detection', cv2.resize(image_np, (800,600)))
    if cv2.waitKey(25) & 0xFF == ord('q'):
    cv2.destroyAllWindows()
    break


    but again, I don't want an overflow of text messages to my phone, and I don't want my script to pause neither.. if any suggestions can be given, I'd appreciate it. Thank you all.










    share|improve this question
























      1












      1








      1








      Tensorflow 1.12.0
      Python 3.5.0
      Windows 10



      Hello all, I've created my own object detection model based on tensorflows object detection tutorial. I want to notify by SMS (via a service like twilio) when a object is detected, but I don't want to be notified by every frame of the same object class, instead I'd like to have a delay between text messages of objects i.e. every 5 seconds (at least) between every call. I've looked at threading and timer, but I fear that I'll restart the threading and timer every for call and was wondering if their is a more efficient way via the object detection API to accomplish this task. I know that I can print the actual class detected via



      print [category_index.get(value) for index,value in enumerate(classes[0]) if scores[0,index] > 0.5]


      in the code



      with detection_graph.as_default():
      with tf.Session(graph=detection_graph) as sess:
      while True:
      ret, image_np = cap.read()
      # 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)

      cv2.imshow('object detection', cv2.resize(image_np, (800,600)))
      if cv2.waitKey(25) & 0xFF == ord('q'):
      cv2.destroyAllWindows()
      break


      but again, I don't want an overflow of text messages to my phone, and I don't want my script to pause neither.. if any suggestions can be given, I'd appreciate it. Thank you all.










      share|improve this question














      Tensorflow 1.12.0
      Python 3.5.0
      Windows 10



      Hello all, I've created my own object detection model based on tensorflows object detection tutorial. I want to notify by SMS (via a service like twilio) when a object is detected, but I don't want to be notified by every frame of the same object class, instead I'd like to have a delay between text messages of objects i.e. every 5 seconds (at least) between every call. I've looked at threading and timer, but I fear that I'll restart the threading and timer every for call and was wondering if their is a more efficient way via the object detection API to accomplish this task. I know that I can print the actual class detected via



      print [category_index.get(value) for index,value in enumerate(classes[0]) if scores[0,index] > 0.5]


      in the code



      with detection_graph.as_default():
      with tf.Session(graph=detection_graph) as sess:
      while True:
      ret, image_np = cap.read()
      # 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)

      cv2.imshow('object detection', cv2.resize(image_np, (800,600)))
      if cv2.waitKey(25) & 0xFF == ord('q'):
      cv2.destroyAllWindows()
      break


      but again, I don't want an overflow of text messages to my phone, and I don't want my script to pause neither.. if any suggestions can be given, I'd appreciate it. Thank you all.







      tensorflow timer object-detection






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 15 '18 at 18:51









      carlgausscarlgauss

      163




      163






















          0






          active

          oldest

          votes











          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
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53326133%2ftensor-flow-object-detection-api-notifications%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53326133%2ftensor-flow-object-detection-api-notifications%23new-answer', 'question_page');

          );

          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







          Popular posts from this blog

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          ReactJS Fetched API data displays live - need Data displayed static

          政党