0

enter image description here

This error shown when I capture image and there are didnt have any result provided by clarifai also any prediction answer. Is show error "[Unhandled promise rejection: TypeError: undefined is not an object (evaluating 'clarifai.GENERAL.MODEL')]". Please help me on this, thanks.

const Clarifai = require('clarifai');

const clarifai = new Clarifai.App({
  apiKey: '851f7efad90241fc807252f3da705d6d'
});
process.nextTick = setImmediate;

state = {
    hasCameraPermission: null,
    predictions: [],
  };

async componentWillMount() {
    const { status } = await Permissions.askAsync(Permissions.CAMERA);
    this.setState({ hasCameraPermission: status === 'granted' });
  }

capturePhoto = async () => {
    if (this.camera) {
      var photo = await this.camera.takePictureAsync();
      return photo.uri;
    }
  };

resize = async photo => {
    let manipulatedImage = await ImageManipulator.manipulateAsync(
      photo,
      [{ resize: { height: 300, width: 300 } }],
      { base64: true }
    );
    return manipulatedImage.base64;
  };

predict = async image => {
    let predictions = await clarifai.models.predict(
      clarifai.GENERAL.MODEL, // model need to get prediction from
      image
    );
    return predictions;
  };

objectDetection = async () => {
    let photo = await this.capturePhoto();
    let resized = await this.resize(photo);
    let predictions = await this.predict(resized);
    this.setState({ predictions: predictions.outputs[0].data.concepts });
    console.log(this.state.predictions)
  };
DeC
  • 2,226
  • 22
  • 42

1 Answers1

1

You should use this instead.

 clarifai.GENERAL.MODEL  ==> clarifai.GENERAL_MODEL
hong developer
  • 13,291
  • 4
  • 38
  • 68