Beispiel #1
0
    def pop(self):
        # Wait for finish signal
        out_slot = self.out_index % self.n_streams
        self.fpgaRT.get_result(out_slot)

        # Read output
        response = self.output_buffers[out_slot]

        fcOutput = np.empty((response["fc1000/Reshape_output"].shape[0], 1000),
                            dtype=np.float32,
                            order='C')
        xdnn.computeFC(self.fcWeight, self.fcBias,
                       response["fc1000/Reshape_output"], fcOutput)
        response = request_wrapper.dictToProto(
            {"fc1000/Reshape_output": fcOutput})
        self.out_index += 1
        return response
Beispiel #2
0
def imagenet_request_generator(file_name, n):
    try:
        i = 0
        data = []
        for image in imagenet_image_generator(file_name, n):
            data.append(image)
            i += 1

            if i == BATCH_SIZE:
                request = {INPUT_NODE_NAME: np.array(data, dtype=np.float32)}
                yield request_wrapper.dictToProto(request)

                i = 0
                data = []
    except Exception as e:
        import traceback
        traceback.print_exc()
        raise e
def empty_image_generator(n):
    '''
    Generate empty images

    n: number of images
    '''
    for _ in range(n // BATCH_SIZE):
        if STACK:
            request = {
                INPUT_NODE_NAME: np.zeros((BATCH_SIZE, 224, 224),
                                          dtype=np.float32)
            }
        else:
            request = {
                INPUT_NODE_NAME:
                np.zeros((BATCH_SIZE, 3, 224, 224), dtype=np.float32)
            }
        request = request_wrapper.dictToProto(request)
        yield request