Skip to content

Instantly share code, notes, and snippets.

Avatar

Elvis Rozario Visrozar

View GitHub Profile
@Visrozar
Visrozar / index.js
Created Dec 15, 2018
Clarifai API - Search by Concept
View index.js
app.inputs.search({ concept: { name: 'pug' } }).then(
function (response) {
response.hits.forEach(hit => {
console.log(hit.score);
console.log(hit.input.data.image);
});
},
function (err) {
console.log(err);
}
@Visrozar
Visrozar / index.js
Created Dec 15, 2018
Clarifai API - Input with Concepts
View index.js
app.inputs.create([
{
url: "https://www.pets4homes.co.uk/images/breeds/9/4a7da5efe7121c4e03c417c344306bd0.jpg",
concepts: [
{
id: "golden retriever",
value: true
}
]
},
@Visrozar
Visrozar / index.js
Created Dec 15, 2018
Clarifai API - Create a Model
View index.js
app.models.create(
"golden retriever",
[
{ "id": "golden retriever" }
]
).then(
function (response) {
console.log(response);
},
function (err) {
@Visrozar
Visrozar / index.js
Created Dec 15, 2018
Clarifai API - Train a model
View index.js
app.models.train("golden retriever").then(
function (response) {
console.log(response.rawData);
},
function (err) {
console.log(err);
}
);
@Visrozar
Visrozar / index.js
Created Dec 15, 2018
Clarifai API - Search based on Custom Model
View index.js
app.inputs.search({ concept: { name: 'golden retriever' } }).then(
function (response) {
response.hits.forEach(hit => {
console.log(hit.score);
console.log(hit.input.data.image);
});
},
function (err) {
console.log(err);
}
@Visrozar
Visrozar / index.js
Last active Dec 15, 2018
Clarifai API - Initialize
View index.js
// Require the client
const Clarifai = require('clarifai');
// initialize with your api key. This will also work in your browser via http://browserify.org/
const app = new Clarifai.App({
apiKey: 'YOUR_API_KEY'
});
@Visrozar
Visrozar / index.js
Last active Dec 15, 2018
Clarifai API - Add Images
View index.js
app.inputs.create([
{
url: "https://s3.amazonaws.com/cdn-origin-etr.akc.org/wp-content/uploads/2017/11/12225358/Pug-On-White-01.jpg"
},
{
url: "https://s3.amazonaws.com/cdn-origin-etr.akc.org/wp-content/uploads/2017/11/12121353/GoldenRetriever1_stacked.jpg"
},
{
url: "https://s3.amazonaws.com/cdn-origin-etr.akc.org/wp-content/uploads/2017/11/12130118/Golden-Retriever-Standing1.jpg"
},
@Visrozar
Visrozar / index.js
Last active Dec 15, 2018
Clarifai API - Search by Image
View index.js
app.inputs.search({ input: { url: 'http://healthypets.royalcanin.com.au/assets/Uploads/_resampled/ScaleWidthWyI2MDAiXQ/golden-retriever-getting-to-know.jpg' } }).then(
function (response) {
response.hits.forEach(hit => {
console.log(hit.score);
console.log(hit.input.data.image);
});
},
function (err) {
console.log(err);
}
View Result
[
{
"_id": "2019-1-28",
"count": 2
},
{
"_id": "2019-1-27",
"count": 1
}
]
View sales data
[
{
"time": ISODate("2019-01-28T15:57:41.269Z"),
"product": "MacBook Pro"
},
{
"time": ISODate("2019-01-28T15:57:41.269Z"),
"product": "iPhone 7"
},
{
You can’t perform that action at this time.