dlstreamer / pipeline-server

Home of Intel(R) Deep Learning Streamer Pipeline Server (formerly Video Analytics Serving)
BSD 3-Clause "New" or "Revised" License
125 stars 51 forks source link

Not able to use stored gallery folder while running gstreamer with gvapython #47

Closed divdaisymuffin closed 3 years ago

divdaisymuffin commented 3 years ago

Hi @nnshah1

Referring to our previous conversation Updated Object Identification Sample, I need help in related issue, where I am doing face recognition with live camera streaming, When running with enrolling True in the vas_identify.py, the gallery folder gets created into the analytics_docker environment, so its able to create new gallery folder, but When I am giving a prebuilt gallery folder (and copied it to the docker environment by making changes into the Dockerfile) which contains features folder and gallery.json with manual labels to the faces, somehow its not reaching to the location of gallery folder, because in the GUI view of smart city I am getting UNKNOWN label even for the faces which have labels.

But the same thing works fine with Video-analytics -serving, there its able to generate images with given labels to the faces enrolled. I think the vas_identify.py somehow missing that part which object identification.py is taking care of in VAserving.

Please help me with the issue.

nnshah1 commented 3 years ago

@divdaisymuffin can you share where you are storing the gallery? The location of the gallery for VA Serving (standalone) and as embedded in Smart Cities will be slightly different. The Smart City analytics container has a different layout then VAS layout - so first is just to check where the gallery is being stored and referenced.

divdaisymuffin commented 3 years ago

@nnshah1 The steps I followed for making gallery folder available to the Smart city docker environment are:

  1. Created a enrolling with a given video. a. The gallery folder contains, Features folder and gallery.json file. b. Then That is been copied to Smart-City-Sample/analytics/object folder, which is home directory to smtc_analytics_object_xeon_gst container. c. Made changes to Smart-City-Sample/analytics/object/Xeon/gst/Dockerfile, added a line COPY gallery /home/gallery which copies the gallery folder to docker home directory. d. To check if it is present in docker home directory used docker exec -it b5ac6a0f53fc bash So, gallery folder is there and contains gallery.json and features folder.

I am also attaching the screenshot of the same. Please have a look and help me. screen1

nnshah1 commented 3 years ago

By default the object identification sample loads the gallery from the pipeline directory:

def __init__(self,
                 enroll = False,
                 gallery = "/home/video-analytics-serving/pipelines/object_identification/gallery",
                 threshold = 0.6,
                 label = None,
                 index = None,
                 max_enrolled = 10,
                 max_enrolled_tensors = 10):

this can be changed either directly in the gvapython code or via a parameter passed into the pipeline request:

parameters = {"identify":{"enroll":args.enroll,
                                      "threshold":args.threshold,
                                      "max_enrolled_tensors":args.max_enrolled_tensors,
                                      "max_enrolled":args.max_enrolled,
                                      "gallery": args.gallery}}

Can you confirm the gvapython code is looking for the gallery in the right place?

divdaisymuffin commented 3 years ago

yes @nnshah1 , I have already changed the location into gvapython code def __init__(self, enroll = False, gallery = "/home/gallery", threshold = 0.45, label = None, index = None, max_enrolled = 10, max_enrolled_tensors = 10):

divdaisymuffin commented 3 years ago

Hi @nnshah1 Please help me with this.

nnshah1 commented 3 years ago

Can you add instrumentation into this method to print out information on the:

1) gallery_path 2) and exception caught, (i.e. error) 3) the final gallery length print len(self._gallery.items())

def _load_gallery(self, gallery_path):

        try:

            self._gallery=defaultdict(list)

            with open(gallery_path, 'r') as f:
                gallery = json.load(f)

            for feature_map in gallery:
                tensors = []
                for feature_path in feature_map['features']:
                    feature_path = os.path.join(os.path.dirname(gallery_path),feature_path)
                    tensor = numpy.fromfile(feature_path,dtype=numpy.float32)
                    tensors.append(tensor)
                self._gallery[feature_map['name']].extend(tensors)
        except Exception as error:
            self._gallery=defaultdict(list)

My guess is either a malformed file, a file in a different location, or maybe a permissions issue - though I would think that all the files would be world readable -

divdaisymuffin commented 3 years ago

okay @nnshah1 Thank you, I will try this and let you know.

nnshah1 commented 3 years ago

@divdaisymuffin Were you able to get it working?

akwrobel commented 3 years ago

Please let us know if you continue to have problems, or if the priority on this issue raises.