Skip to content

Commit

Permalink
Update for clarifai to image identification
Browse files Browse the repository at this point in the history
  • Loading branch information
aryaminus committed Mar 2, 2018
1 parent 6ed1ca1 commit 45d07c7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/components/AnswerNotification/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PropTypes from "prop-types";

import styles from "./styles";

const ThingToFind = "Pizza";
//const ThingToFind = "Pizza";

class AnswerNotification extends Component {
constructor(props) {
Expand All @@ -23,7 +23,7 @@ class AnswerNotification extends Component {
}

render() {
const isValid = this.props.answer === ThingToFind;
const isValid = this.props.answer === this.props.answer;
const icon = isValid
? require("../../assets/valid.png")
: require("../../assets/error.png");
Expand Down
15 changes: 6 additions & 9 deletions src/screens/PredictScreen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PredictScreen extends Component {

componentDidMount() {
const clarifai = new Clarifai.App({
apiKey: "b0959ce79c6e4b6eb7af2c91fb561046" //dummy
apiKey: "" //dummy
});

process.nextTick = setImmediate; // RN polyfill
Expand All @@ -41,26 +41,23 @@ class PredictScreen extends Component {
.predict(Clarifai.GENERAL_MODEL, file)
.then(response => {
const { concepts } = response.outputs[0].data;

if (concepts && concepts.length > 0) {
for (const prediction of concepts) {
if (prediction.name === "pizza" && prediction.value >= 0.99) {
return this.setState({ loading: false, result: "Pizza" });
}
this.setState({ result: "Not Pizza" });
return this.setState({ loading: false, result: prediction.name });
}
}

this.setState({ loading: false });
})
.catch(err => alert(err));
/*
.catch(e => {
Alert.alert(
"An error has occurred",
"Sorry, the quota may be exceeded, try again later!",
[{ text: "OK", onPress: () => this._cancel() }],
{ cancelable: false }
);
});
});*/
}

_cancel() {
Expand Down

0 comments on commit 45d07c7

Please sign in to comment.