Search code examples
reactjsclarifai

faild to detect faces


I working on an app that can detect images using Clarifai api. I created all the components but anytime i post it will display

api.clarifai.com/v2/models/a403429f2ddf4b49b307e318f00e528b/outputs:1 POST https://api.clarifai.com/v2/models/a403429f2ddf4b49b307e318f00e528b/outputs 400 (Bad Request)

I have tried generating new API's but none posted effectivelyenter code here

import React, {Component} from 'react';
import Clarifai from 'clarifai';



const app = new Clarifai.App({
  apiKey: 'b7712f2f841c4482bb85e68f02cdf4b6'
});




onButtonSubmit = () => {
    this.setState({imageUrl: this.state.input});
    app.models
      .predict(
        Clarifai.FACE_DETECT_MODEL,
        this.state.input)
      .then(response => {
        if (response) {
          fetch('http://localhost:3001/image', {
            method: 'put',
            headers: {'Content-Type': 'application/json'},
            body: JSON.stringify({
              id: this.state.user.id
            })
          })
            .then(response => response.json())
            .then(count => {
              this.setState(Object.assign(this.state.user, { entries: count}))
            })

        }
        this.displayFaceBox(this.calculateFaceLocation(response))
      })
      .catch(err => console.log(err));
  }


}.

Solution

  • Hello Clarifai Support here. Could you please try replacing

    FACE_DETECT_MODEL
    

    with

    FACE_DETECTION_MODEL
    

    It might just be as simple as a syntax error.

    in

    app.models.predict()