Code Monkey home page Code Monkey logo

clarifai-clj's Introduction

clarifai-clj

Clojure wrapper for Clarifai API.

Clojars Project

NOTE: Currently limited to:

  • Predict API (i.e. no Search, Train, etc. APIs) and
  • hosted images and videos (i.e. you must provide an image or video URL).

Usage

Add clarifai-clj to your Leiningen project.clj as a :dependency:

[clarifai-clj "1.0.0"]

Include clarifai-clj in your namespace:

(:require [clarifai-clj.core :as clarifai])

Getting concepts for an image:

(def my-api-key "123456789") ; use your real one :-)

(def model-to-use :general) ; see clarifai-clj.models for supported models list

(def image-to-process "https://samples.clarifai.com/metro-north.jpg")

(clarifai/concepts my-api-key model-to-use image-to-process)
;=> ({:name "train", :value 0.9987074} 
;    {:name "railway", :value 0.9971303} 
;    {:name "transportation system", :value 0.9954438} 
;    {:name "locomotive", :value 0.9914662} 
;     ...)

Getting concepts for a video:

(def video-to-process "https://samples.clarifai.com/beer.mp4")

(def concepts-from-video 
  (clarifai/video-concepts my-api-key model-to-use image-to-process))
  
;; Clarifai provides a list of concepts for each video frame:
(first concepts-from-video)
;=> {:frame {:index 0, :time 0},
;    :concepts ({:name "drink", :value 0.9850012} 
;               {:name "glass", :value 0.9776815} 
;               {:name "alcohol", :value 0.9754255} 
;                ...)}

(second concepts-from-video)
;=> {:frame {:index 1, :time 1000},
;    :concepts ({:name "drink", :value 0.9850012} 
;                ...)}

(last concepts-from-video)
;=> {:frame {:index 8, :time 8000}, 
;    :concepts ({:name "foam", :value 0.9974463} 
;               {:name "beer", :value 0.9749906} 
;               {:name "no person", :value 0.9728426} 
;               {:name "drink", :value 0.96293694}
;                ...)}

Note that, for video, Clarifai only supports a subset of its public models.

Clarifai Predict API documentation

Please visit Clarifai Predict API.

Todo

  • add support for pagination
  • add support for Search, Train, Evaluate, Feedback and Workflow APIs

License

Eclipse License.

clarifai-clj's People

Contributors

pianostringquartet avatar

Watchers

James Cloos avatar

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.