Coder Social home page Coder Social logo

clarifai / clarifai-javascript Goto Github PK

View Code? Open in Web Editor NEW
352.0 33.0 124.0 1.55 MB

Official Clarifai JavaScript client for browsers and node.js

Home Page: https://docs.clarifai.com

License: Other

JavaScript 97.54% Python 2.46%
clarifai javascript clarifai-javascript javascript-client js-client visual-search computer-vision

clarifai-javascript's People

Contributors

blooies avatar bryanclarifai avatar cmisenas avatar dankantor avatar eddiezane avatar everling-prime avatar harmitminhas96 avatar janvier-wijaya avatar jeckytian avatar jhickey avatar joakimteixeira avatar lukeclarifai avatar moldovan-clarifai avatar robert-clarifai avatar rok-clarifai avatar rok-povsic avatar yangshengbe avatar yvetteclarifai avatar zeiler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clarifai-javascript's Issues

'use strict' required

hi,

using require('clarifai'); throw an exception

/home/ubuntu/workspace/node_modules/clarifai/index.js:1
(function (exports, require, module, __filename, __dirname) { let App = require('./src/App');
                                                              ^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/home/ubuntu/workspace/service/image_moderation.js:3:16)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at /home/ubuntu/workspace/service/index.js:15:27
    at Array.forEach (native)

i got error => Uncaught ReferenceError: process is not defined

i try to use Clarifai in my react project .

const app = new Clarifai.App({
apiKey: "af5a54585af246268c4c47d1cb9bf816",
});

app.models.predicct(Clarifai.FACE_DETECT_MODEL, this.state.input).then(
function (response) {
console.log(response);
},
function (error) {}
);

i got error : Uncaught ReferenceError: process is not defined

Missing `dist` folder when installing 2.3.0 using NPM

Hi guys.

We use Clarifai 2.2.0 in our project:

{
   ...
  "dependencies": {
   ...
    "clarifai": "^2.2.0",
   ...
  }
}

Today we noticed that version 2.3.0 released.

And immediately there was an error:

Error: Can't find npm module 'clarifai'. Did you forget to call 'Npm.depends' in package.js within the 'modules-runtime' package?

We also noticed that there is no dist folder in node_modules:
screen shot 2017-09-01 at 17 03 07
screen shot 2017-09-01 at 17 01 34

should provide a func to query workflows.

I want to get all workflows in current app, but the app.workflow not provide query.
I grab the req and res, the curl data:

curl -X GET \
  https://api.clarifai.com/v2/users/{}/apps/{}/workflows \
  -H 'Cache-Control: no-cache' \
  -H 'authorization: Key {}' \

TypeError: clarifai__WEBPACK_IMPORTED_MODULE_8___default.a.app is not a constructor

Hi,
I installed clarify with npm install clarifai.
However I get the following error in my project.

  • TypeError: clarifai__WEBPACK_IMPORTED_MODULE_8___default.a.app is not a constructor
    image

  • I have these packages installed
    image

  • Also there is type declaration warning.
    image

  • I am on a windows 10 pro intel machine.

I tried putting curly brackets import {Clarifai} from 'clarifai' , I get an app error.
I tried const Clarifai = require('clarifai');, I get the same webpack error.

Any idea how I can solve this issue?

Thanks

clarifai javascript client no longer works as of a couple of hours ago

Just this morning clarifai stopped working for me (specific error was "cannot find module 'clarifai' at ...")

I tried deleting/re-npm-installing my node_modules; same issue; I switched my package.json to install 2.1.6 instead of ^2.1.6 and now everything works again.

So I think something is not quite right with your recent 2.1.7 release.

Error with es2015 preset

Trying to deploy the latest clarifai pulled from npm in my react-native app:
simulator screen shot may 24 2017 9 53 09 pm

(note, the paths shown are not absolute /node_modules, I obscured the root project dir name)

Clarifai app keeps installing without declaration file

I cannot progress with the creation of my React app because the declaration file is not downloading with the package. I tried 'npm install @types/clarifai' but it said that the latest wasn't available which was confusing.

I tried redoing the entire app to make sure but I am having the same issue. It is not installing with everything else or cannot be found by my text editor.

Why would it not be installing and what can I do to resolve this issue?

React Native install issues

I wrote a little consumer for the clarifai API that utilizes this library. Unfortunately, whenever I try to use it, it crashes with a red screen:
screen shot 2017-06-21 at 11 34 46

The client looks like this (currently, which resulted in the red screen, with no implementation):

import Clarifai from "clarifai";

const clarifai = new Clarifai.App(
  "client_id",
  "client_secret",
);

export const verifyPhotoBytes = (base64Photo, tags) => {
  console.log("Verifying bytes");
  return Promise.resolve("Hey");
  // return clarifai.inputs
  //   .create({
  //     base64: base64Photo,
  //   })
  //   .then(
  //     response => {
  //       console.log(response);
  //     },
  //     error => {
  //       console.log(error);
  //     },
  //   );
};

The crash seems to happen if I try to create a new instance of Clarifai.App. I'm on version 2.1.8 using yarn 0.24.6

I can't use angular 7 or ionic project

When i add clarifai in my angular project give me the this error

index.js:8 Uncaught ReferenceError: global is not defined at Object../node_modules/clarifai/dist/index.js (index.js:8) at webpack_require (bootstrap:78) at Module../src/app/home/home.component.ts (main.js:231) at webpack_require (bootstrap:78) at Module../src/app/app.module.ts (app.component.ts:8) at webpack_require (bootstrap:78) at Module../src/main.ts (main.ts:1) at webpack_require (bootstrap:78) at Object.0 (main.ts:12) at webpack_require (bootstrap:78)

i try clarifai version: 2.9.0 , 2.0.9

ionic project's error =>

cannot read property 'App' of undefined

I tried to define it in various ways but allways different error.

How can i use clarifa in ionic project ?? pls help me

Default Language Option is not working at javascript api

Hello. I am so glad to use your amazing service in Korea.
I have adapted your api to my humanoid robot's vision system.
I have changed the default language english to korean, but results from javascript api have shown just english. How can I resolve this problem?

Initial 400 error: 11103 Method Not Allowed before face recognition api runs normally

I have an issue in which the first image or two URL address is not accepted and I am met with the following:

Failed to load resource: the server responded with a status of 400 (Bad Request)

When I click on the link provided, it leads to a page with this on a single line.

{"status":{"code":11103,"description":"Method not allowed","details":"Method Not Allowed"}}

However, if I try another image and then go back to the original image used the server accepts the image.

Why is my request not accepted until I try enough images?

Remove Concepts From A Model

how is the removal example from here: https://developer.clarifai.com/guide/models#models
supposed to work?
shouldn't:

update(obj) {
let url = ${this._config.apiEndpoint}${MODELS_PATH};
let modelData = [obj];
let data = {models: modelData.map(formatModel)};
if (data.concepts) {
data['action'] = obj.action || 'merge';
}

in Model.js be changed to:

update(obj) {
obj.id = this.id;
let url = ${this._config.apiEndpoint}${MODELS_PATH};
let modelData = [obj];
let data = {models: modelData.map(formatModel)};
if (data.models) {
data['action'] = obj.action || 'merge';
}
?

app.inputs.create single object argument does not work correctly.

Hello,

I was doing a POC work to use clarifai in my personal project. And found that if I pass a single object argument to app.inputs.create, then the concepts are not tied to the image correctly. However, when I tried array argument to the method, it worked perfectly. Below is my code sample.

// Image is uploaded, but concepts are missing.
app.inputs.create({
 url: 'url-for-image',
 concepts: [{
  id: 'cat',
  value: true,
 }],
});

// Image is uploaded with concepts as expected
app.inputs.create([
 {
  url: 'url-for-image',
  concepts: [{
   id: 'cat',
   value: true,
  }],
 }
]);

Handling Responses

Each of the examples concludes with something like this:

handleResponse,
handleError

However, it is not very clear how we handle a response. There are no response parameters in the getTags requests. How do we see a response/error?

Wrong path for package import

I'm getting this error.

[ 'Error: Cannot find module \'./../package.json\'',
     '    at Function.Module._resolveFilename (module.js:472:15)',
     '    at Function.Module._load (module.js:420:25)',
     '    at Module.require (module.js:500:17)',
     '    at require (internal/module.js:20:19)',
     '    at Object.<anonymous> (/Users/Chance/Development/cosmunity/backend/node_modules/clarifai/dist/node/utils.js:15:17)'

The path referencing package.json is correct in /src/utils.js, but is incorrect in /dist/node/utils.js because the file is 1 level deeper. I think this was introduced in 080e0ba. @zeiler

This bug breaks any package depending on Clarifai

Cannot use application because of dupes

When trying to list my applications, i receive the error
"Object has a duplicate ID; another object with same ID already exist.","details":"Object has a duplicate ID; another object with same ID already exist"
and i cannot list my applications on the platform.
And i cannot remove the duplicateds too, because i dont know what is the duplicated resource
https://imgur.com/a/9gW72FV

Any idea when color will be added?

I'd like to use color in a project and I'm already using this client, is there any timing of when this will be added or any ideas how I can easily integrate color with this client without having to do authentication myself.

Thanks!

TypeError: _$$_REQUIRE(_dependencyMap[4], "axios").post is not a function (it is undefined)

I'm using Clarifai in my React Native project. Essentially, I'm using react-native-camera to take a picture and then passing it to the Clarifai model to predict/identify objects in the picture. The picture is successfully taken and passed to the Clarifai model, but an error occurred in the following portion of the code.

    const Clarifai = require('clarifai');
    const app = new Clarifai.App({
      apiKey: 'my clarifai apiKey',
    });
    app.models
      .predict(Clarifai.GENERAL_MODEL, {base64: imageData})
      .then((response: any) =>
        displayAnswer(response.outputs[0].data.concepts[0].name),
      )
      .catch((err: any) => {
        alert(err);
        console.log('error:', err);
        setLoading(false);
      });

An error was caught in the .catch() statement. It seems like Axios is not imported correctly or the Axios package is not installed, but I have already installed the package. Below is my project's package.json dependencies:

    "axios": "^1.6.5",
    "clarifai": "^2.9.1",
    "react": "18.2.0",
    "react-native": "0.73.1",
    "react-native-camera": "^4.2.1"

Promise always polyfilled (Incompatible with Angular 2)

Hi, I'm implementing clarifai-javascript in an app with NativeScript and Angular 2.

It actually breaks the app with this error message:

Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.
Most likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)

I'm seeing that you are always using the es6-promise polyfill

var Promise = require('es6-promise').Promise;) 

disregarding if an implementation (custom one in this case) is already available.

See this similar issue Stuk/jszip#303 (comment) and it's fix: Stuk/jszip#321

Cheers!

Node dependency issue

I had an issue with version 2.1.4dev (which is currently the default module on npm). I'm using Clarifai with react native; following import, I got this error:

UnableToResolveError: Unable to resolve module domain from /Users/user/Documents/projectname/node_modules/asap/raw.js: Module does not exist in the module map or in these directories:
/Users/user/Documents/projectname/node_modules
, /Users/user/node_modules
This might be related to facebook/react-native#4968
To resolve try the following:

  1. Clear watchman watches: watchman watch-del-all.
  2. Delete the node_modules folder: rm -rf node_modules && npm install.
  3. Reset packager cache: rm -fr $TMPDIR/react-* or npm start --reset-cache

The problem here is domain has been deprecated in node.js but is used in [email protected] (a dependency of [email protected], which itself is a dependency of clarifai @2.1.4-dev). I was able to get around this issue by using [email protected], which uses a different promise library (I'm using yarn, the command was: yarn add [email protected]).

Here's a screenshot of the old dependency tree
screen shot 2017-03-21 at 3 14 04 pm

and the new dependency tree:
screen shot 2017-03-22 at 9 58 26 am

Summary: most recent clarifai release uses a library which uses a deprecated node module

Axios Error 400

I kept experiencing this error:
Error: Request failed with status code 400

const Clarifai = require('clarifai')

const clarifai = new Clarifai.App({
  apiKey: "[]"
});

function log(d) {
  try {
    console.log(JSON.stringify(d, null, 2));
  } catch (e) {
    console.log(d);
  }
}

// Prediction on general model using video API
clarifai.models.predict(Clarifai.GENERAL_MODEL, 'https://gblobscdn.gitbook.com/spaces%2F-LisemUaXxC3S7Kk9xFz%2Favatar.png')
  .then(log)
  .catch(log);

Version: 2.9.1
Node.js: v14.13.1

process.nextTick is not a function

I try import clarifai to my react native project , when I try

const ClarifaiApp = new Clarifai.App({
  apiKey: 'xxxx'
 });

ClarifaiApp.models.predict(Clarifai.GENERAL_MODEL, "https://samples.clarifai.com/metro-north.jpg").then(
      function(response) {
        // do something with response
        console.log(response);
      },
      function(err) {
        console.log(err);
        // there was an error
      }
    );
  }

I get error process.nextTick is not a function

Protecting my keys

Hi, I have just started using the Clarifai API and it works great.

One thing I was wondering though is how to protect my application key/secret from being stolen / used by anyone who uses the app? It seems I cannot regenerate those and putting them in the javascript source does not feel right to me.

Any thoughts ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.