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

Always got 'None' using g = gpu_worker.get_result_queue(). #17

Open
kitlien opened this issue May 23, 2018 · 3 comments
Open

Always got 'None' using g = gpu_worker.get_result_queue(). #17

kitlien opened this issue May 23, 2018 · 3 comments

Comments

@kitlien
Copy link

kitlien commented May 23, 2018

@gustavz Hey, When I implement the ' object_detection.py' on Tx2, I Always got 'None' using g = gpu_worker.get_result_queue(). And no detection results comes out, what's the reason of this problem?

@kitlien kitlien changed the title Always got Always got 'None' using g = gpu_worker.get_result_queue(). May 23, 2018
@gustavz
Copy link
Owner

gustavz commented May 24, 2018

@kitlien please specify exactly what you do and what output you get, i am not able to understand the question

@kitlien
Copy link
Author

kitlien commented May 25, 2018

@gustavz I run the object detection python file "object_detection.py" with split_model. When the program run into the function:def detection(detection_graph, category_index, score, expand), the function g = gpu_worker.get_result_queue() and c = cpu_worker.get_result_queue(), alway return 'None'.

Then there is no results for boxes, scores, classes, num, image.

Here is the code for this problem:

           if split_model:
                # split model in seperate gpu and cpu session threads
                if gpu_worker.is_sess_empty():
                    # read video frame, expand dimensions and convert to rgb
                   image = cv2.imread(images[i])
                    image_expanded = np.expand_dims(cv2.cvtColor(image, cv2.COLOR_BGR2RGB), axis=0)
                    # put new queue
                    gpu_feeds = {image_tensor: image_expanded}
                    if visualize:
                        gpu_extras = image # for visualization frame
                    else:
                        gpu_extras = None
                    gpu_worker.put_sess_queue(gpu_opts,gpu_feeds,gpu_extras)

                g = gpu_worker.get_result_queue()
                if g is None:
                    # gpu thread has no output queue. ok skip, let's check cpu thread.
                    gpu_counter += 1
                else:
                    # gpu thread has output queue.
                    gpu_counter = 0
                    score,expand,image = g["results"][0],g["results"][1],g["extras"]

                    if cpu_worker.is_sess_empty():
                        # When cpu thread has no next queue, put new queue.
                        # else, drop gpu queue.
                        cpu_feeds = {score_in: score, expand_in: expand}
                        cpu_extras = image
                        cpu_worker.put_sess_queue(cpu_opts,cpu_feeds,cpu_extras)

                c = cpu_worker.get_result_queue()
                if c is None:
                    # cpu thread has no output queue. ok, nothing to do. continue
                    cpu_counter += 1
                    time.sleep(0.005)
                    continue # If CPU RESULT has not been set yet, no fps update
                else:
                    cpu_counter = 0
                    boxes, scores, classes, num, image = c["results"][0],c["results"][1],c["results"][2],c["results"][3],c["extras"]

Wish your help,Thanks~

@gustavz
Copy link
Owner

gustavz commented May 25, 2018

I dont know where you got this code from, but this is totally messed up.
If you want to use my inital release, make sure to checkout branch r1.0
Or better use my new release, so checkout master or r2.0.

This part here is strange:

                   image = cv2.imread(images[i])
                    image_expanded = np.expand_dims(cv2.cvtColor(image, cv2.COLOR_BGR2RGB), axis=0)

So you wrote your own code / modified the original one. Furthermore this is an Indentation Error.
So probably you made some mistakes here...
As i said, pull my newest version or checkout to one of the two releases and you should be fine

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

2 participants