Skip to content

Commit 45d07c7

Browse files
committed
Update for clarifai to image identification
1 parent 6ed1ca1 commit 45d07c7

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

src/components/AnswerNotification/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import PropTypes from "prop-types";
44

55
import styles from "./styles";
66

7-
const ThingToFind = "Pizza";
7+
//const ThingToFind = "Pizza";
88

99
class AnswerNotification extends Component {
1010
constructor(props) {
@@ -23,7 +23,7 @@ class AnswerNotification extends Component {
2323
}
2424

2525
render() {
26-
const isValid = this.props.answer === ThingToFind;
26+
const isValid = this.props.answer === this.props.answer;
2727
const icon = isValid
2828
? require("../../assets/valid.png")
2929
: require("../../assets/error.png");

src/screens/PredictScreen/index.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class PredictScreen extends Component {
2929

3030
componentDidMount() {
3131
const clarifai = new Clarifai.App({
32-
apiKey: "b0959ce79c6e4b6eb7af2c91fb561046" //dummy
32+
apiKey: "" //dummy
3333
});
3434

3535
process.nextTick = setImmediate; // RN polyfill
@@ -41,26 +41,23 @@ class PredictScreen extends Component {
4141
.predict(Clarifai.GENERAL_MODEL, file)
4242
.then(response => {
4343
const { concepts } = response.outputs[0].data;
44-
44+
4545
if (concepts && concepts.length > 0) {
4646
for (const prediction of concepts) {
47-
if (prediction.name === "pizza" && prediction.value >= 0.99) {
48-
return this.setState({ loading: false, result: "Pizza" });
49-
}
50-
this.setState({ result: "Not Pizza" });
47+
return this.setState({ loading: false, result: prediction.name });
5148
}
5249
}
53-
54-
this.setState({ loading: false });
5550
})
51+
.catch(err => alert(err));
52+
/*
5653
.catch(e => {
5754
Alert.alert(
5855
"An error has occurred",
5956
"Sorry, the quota may be exceeded, try again later!",
6057
[{ text: "OK", onPress: () => this._cancel() }],
6158
{ cancelable: false }
6259
);
63-
});
60+
});*/
6461
}
6562

6663
_cancel() {

0 commit comments

Comments
 (0)