Если вы хотите попробовать это, но с учетом вашей кредитной карты, вы можете использовать Google Vision, Amazon Rekognition, Microsoft и другие ML, связанные с рынком. Но если вы не хотите или у вас есть номер кредитной карты, в моем случае я использую https://clarifai.com/.
Для пакета API, npm install --save clarifai
и для реализации, я получил его,
const Clarifai = require('clarifai')
const app = new Clarifai.App({
apiKey: 'dac044d841bb40f6bc6a79e5d1a65fcf'
})
sendToClarifai(encoded_image) {
let vm = this
app.models.predict(Clarifai.GENERAL_MODEL, { base64: encoded_image }).then(
function (response) {
// do something with response
var concepts = response['outputs'][0]['data']['concepts']
console.log('CONCEPTS', concepts)
vm.isLoading = false
let isDetectedEyeRelated = false
//loop through items
concepts.forEach(obj => {
if (['disease', 'animal', 'pet', 'cat', 'cataract', 'cataracts', 'eye', 'conjunctivitis'].includes(obj.name)) {
isDetectedEyeRelated = true
}
//more to improve here but very inaccurate
})
//show message
let message = ""
let firstQuestionArray = []
if (isDetectedEyeRelated) {
message = "Your cat might have some eye problems."
firstQuestionArray = ["Do you see redness or discharge?", "Does your cat squinting or the emergence of the third eyelid?"]
} else {
message = "Our classification model cannot identify the subject.\nCheck camera settings and proper position."
firstQuestionArray = ["Does your cat has bright, clear evenly focused eyes?", "Do you see redness or discharge?", "Does your cat squinting or the emergence of the third eyelid?"]
}
//follow up questions
action({
message: message + '\n\nBelow are follow up questions:',
cancelButtonText: "Cancel",
actions: firstQuestionArray,
cancelable: false
})
.then(result => {
if (result.includes("redness") || result.includes("emergence")) { //A
action({
message: "Please select any of these symptoms to know what seems could be the problem",
cancelButtonText: "Cancel",
actions: ["Do you see any familiar pink or reddish color, sticky eye discharge and swelling?", "Did you notice any cloudiness in their eyes, change of iris color and unusual meowing?"],
cancelable: false
})
.then(result => {
if (result.includes("reddish")) { //A
alert({
title: "Identify",
message: "This could be a sign that your cat has conjunctivitis.",
okButtonText: "See Early Treatment"
}).then(() => {
vm.setTreatmentType('eye_conjunctivitis')
vm.setTreatmentTitle('Eye Conjunctivitis Identification and Treatment')
vm.$router.replace({
path: '/pdf-treatment'
})
})
} else if (result.includes("cloudiness")) { //b
alert({
title: "Identify",
message: "This could be a sign that your cat has cataract.",
okButtonText: "See Early Treatment"
}).then(() => {
vm.setTreatmentType('eye_cataract')
vm.setTreatmentTitle('Eye Cataract Identification and Treatment')
vm.$router.replace({
path: '/pdf-treatment'
})
})
}
})
} else if (result.includes("bright")) { //b
const user_data = LS.getItem(vm.loggedUsername)
const obj = JSON.parse(user_data)
obj.progress.eye = 'good condition'
//update the user data
LS.removeItem(vm.loggedUsername)
LS.setItem(vm.loggedUsername, JSON.stringify(obj))
alert({
title: "Congratulations",
message: "Your cat's eye is in good condition.",
okButtonText: "Done"
}).then(() => {
console.log("Alert dialog closed");
})
vm.$router.push({
path: '/categories'
})
}
})
},
function (err) {
// there was an error
console.log('CLARIFAI ERROR', err)
}
)
Или что-то похожее с моей реализацией.