Code Monkey home page Code Monkey logo

Comments (11)

jkjung-avt avatar jkjung-avt commented on June 9, 2024

Did you notice any error when you export the model?

$ CUDA_VISIBLE_DEVICES=0 ./export.sh ssdlite_mobilenet_v2_egohands

from hand-detection-tutorial.

DilaraAlbayrak avatar DilaraAlbayrak commented on June 9, 2024

Yes I have below output, also i am aware that model_exported directory is empty

InvalidArgumentError (see above for traceback): Unsuccessful TensorSliceReader constructor: Failed to get matching files on ssdlite_mobilenet_v2_egohands/model.ckpt-20000: Not found: ssdlite_mobilenet_v2_egohands; No such file or directory [[Node: save/RestoreV2_139 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2_139/tensor_names, save/RestoreV2_139/shape_and_slices)]] [[Node: save/RestoreV2_108/_767 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_1582_save/RestoreV2_108", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]]

from hand-detection-tutorial.

jkjung-avt avatar jkjung-avt commented on June 9, 2024

The error message says it could not find the model checkpoint file: 'ssdlite_mobilenet_v2_egohands/model.ckpt-20000'. Have you trained this 'ssdlite_mobilenet_v2_egohands' model by yourself? In case you are using a different model, say 'ssd_mobilenet_v1_egohands', be sure to use the correct model name for your own model.

from hand-detection-tutorial.

DilaraAlbayrak avatar DilaraAlbayrak commented on June 9, 2024

Thanks I thought I have trained few days ago, probably something I have missed.

Than, for now is it possible to use some other data with checkpoint files? for instance 'ssd_inception_v2_coco' has checkpoints, can the code be run with this dataset?

from hand-detection-tutorial.

jkjung-avt avatar jkjung-avt commented on June 9, 2024

The code would require some modification if you are not using egohands trained model for inferencing.

More specifically, if you want to use 'ssd_inception_v2_coco' for testing, you'd, for example, need to modify this line in detect_image.py to read the COCO label map file.

from hand-detection-tutorial.

DilaraAlbayrak avatar DilaraAlbayrak commented on June 9, 2024

Thanks for your help, now I can make the code work, I have one more question I did not bother to open issue I can open, if necessary? Is the code not working on GPU?

from hand-detection-tutorial.

jkjung-avt avatar jkjung-avt commented on June 9, 2024

The code does work for GPU. When you specify CUDA_VISIBLE_DEVICES=0 you are essentially asking tensorflow to use GPU #0 for the training or inferencing task.

from hand-detection-tutorial.

DilaraAlbayrak avatar DilaraAlbayrak commented on June 9, 2024

Thanks for your quick reply. Actually I have successfully got output for the image. Now I would like to call the code without using bash script, I have directly write CUDA_VISIBLE_DEVICES=0 just before detect_image method and make command python detect_image.py, in that case no activity appears on GPU and FPS is ~1. That is why I think it does not run on GPU, obviously I make something wrong.

from hand-detection-tutorial.

jkjung-avt avatar jkjung-avt commented on June 9, 2024

According to official documentation, tensorflow should prioritize and use the gpu unless requested otherwise.

If you'd like to specifically control which gpu or cpu to use for inferencing, you might try to modify this line of code: https://github.com/jkjung-avt/hand-detection-tutorial/blob/master/detect_image.py#L53

from hand-detection-tutorial.

DilaraAlbayrak avatar DilaraAlbayrak commented on June 9, 2024

Hi again,
What I was trying to do is to run the code with video input. I see that when the session is created in while loop constantly, the implementation gets really slow. I guess model is reloaded for every session create. That is why I thought gpu is not used (I am still clueless about why GPU utility was very low as 1-2%).

Anyhow, long story short, I get below part outside of while and now everything is ok, FPS ~25. Thanks for your work and help!

# load label map
category_index = label_map_util.create_category_index_from_labelmap(
    PATH_TO_LABELS)

# load detection graph
detection_graph = tf.Graph()
with detection_graph.as_default():
    od_graph_def = tf.GraphDef()
    with tf.gfile.GFile(PATH_TO_FROZEN_GRAPH, 'rb') as fid:
        serialized_graph = fid.read()
        od_graph_def.ParseFromString(serialized_graph)
        tf.import_graph_def(od_graph_def, name='')

# define input/output tensors
image_tensor = detection_graph.get_tensor_by_name('image_tensor:0')
detection_boxes = detection_graph.get_tensor_by_name('detection_boxes:0')
detection_scores = detection_graph.get_tensor_by_name('detection_scores:0')
detection_classes = detection_graph.get_tensor_by_name('detection_classes:0')
num_detections = detection_graph.get_tensor_by_name('num_detections:0')

config = tf.ConfigProto(log_device_placement=True)
config.gpu_options.allow_growth = True
config.gpu_options.visible_device_list= '0'
config.log_device_placement=True
config.allow_soft_placement = True
sess = tf.Session(config=config, graph=detection_graph)

from hand-detection-tutorial.

jkjung-avt avatar jkjung-avt commented on June 9, 2024

Good to hear this. And you are very welcome.

from hand-detection-tutorial.

Related Issues (20)

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.