public detect()

in src/js/server/automl.ts [47:81]


    public detect(base64Img: string, callback: Function) {
        this.sessionClient = new sdk.v1beta1.PredictionServiceClient({
            projectId: this.projectId
        });

        const formattedName = this.sessionClient.modelPath(
            this.projectId,
            this.location,
            this.model
        );
        
        base64Img = base64Img.replace('data:image/png;base64,', '');

        let payload: Payload = {
            image:  {imageBytes: base64Img}
        };
        const params = {};

        const request = {
          name: formattedName,
          payload: payload,
          params: params
        };

        this.sessionClient.predict(request)
        .then(function(responses: any){
            const response = responses[0];
            callback(response);
          })
          .catch(function(err: any){
            console.error(err);
            callback(err);
          });

    }