{"id":21812213,"url":"https://github.com/jolibrain/deepdetect-js","last_synced_at":"2025-04-13T23:11:32.677Z","repository":{"id":38238833,"uuid":"132460969","full_name":"jolibrain/deepdetect-js","owner":"jolibrain","description":"DeepDetect javascript client","archived":false,"fork":false,"pushed_at":"2024-03-21T16:30:15.000Z","size":976,"stargazers_count":8,"open_issues_count":1,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-31T19:46:43.880Z","etag":null,"topics":["browser","deepdetect","javascript","machine-learning","nodejs"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jolibrain.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-05-07T12:59:13.000Z","updated_at":"2021-10-19T09:33:31.000Z","dependencies_parsed_at":"2023-01-23T23:02:19.321Z","dependency_job_id":"977c7275-2963-465f-a187-aa1b27fb986f","html_url":"https://github.com/jolibrain/deepdetect-js","commit_stats":{"total_commits":167,"total_committers":3,"mean_commits":"55.666666666666664","dds":0.05988023952095811,"last_synced_commit":"aee0b73ac04b105a5c5e436c250c03686b064832"},"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jolibrain%2Fdeepdetect-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jolibrain%2Fdeepdetect-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jolibrain%2Fdeepdetect-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jolibrain%2Fdeepdetect-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jolibrain","download_url":"https://codeload.github.com/jolibrain/deepdetect-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226761344,"owners_count":17677742,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browser","deepdetect","javascript","machine-learning","nodejs"],"created_at":"2024-11-27T14:15:02.522Z","updated_at":"2024-11-27T14:15:03.115Z","avatar_url":"https://github.com/jolibrain.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# deepdetect-js\n\u003c!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --\u003e\n[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-)\n\u003c!-- ALL-CONTRIBUTORS-BADGE:END --\u003e\n\n\u003e DeepDetect JS client\n\n## Files\n\n* ```src/index.js``` - client source code\n* ```src/index.test.js``` - client methods tests\n\n* ```doc/web-example/server.js``` - simple webserver to serve web-example index.html and proxy api calls to a deepdetect server\n* ```doc/web-example/index.html``` - deepdetect-js web integration demo\n\n## Usage\n\n### Web integration\n\nDeepDetect-JS can be used on a webpage, you probably should run deepdetect server behind a http-proxy to avoid same-origin policy issues.\n\nA simple webserver demo is available on ```http://localhost:3000``` when running the following command:\n\n```sh\nyarn run web-example\n```\n\nHere is the simple ```/info``` api call on a DeepDetect server.\nNote the ```{path: 'api'}``` parameter when initializing ```DD``` object.\n\n```html\n...\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/deepdetect-js@0.0.0-development/dist/deepdetect-browser.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  async function fetchInfo() {\n    const dd = new deepdetect.DD({path: 'api'});\n    const info = await dd.info();\n    document.getElementById('infoResult').innerHTML = JSON.stringify(info);\n  }\n\n  fetchInfo();\n\u003c/script\u003e\n...\n```\n\n### NodeJS integration\n\nFollowing usage examples will use nodejs, install it with this command:\n\n```sh\nnpm install --save deepdetect-js\n```\n\n### Connect to DeepDetect server, and fetch informations\n\nHere is the simplest way to get information about a DeepDetect server:\n\n```js\nimport DD from 'deepdetect-js';\n\nasync () =\u003e {\n\n  const dd = new DD()\n\n  // Get DeepDetect server info\n  const info = await dd.info()\n  console.log(info);\n\n}\n```\n\nYou can also specified the DeepDetect server host and port options:\n\n```js\nimport DD from 'deepdetect-js';\n\nasync () =\u003e {\n\n  const dd = new DD('10.10.10.1', 8580)\n\n  // Get DeepDetect server info\n  const info = await dd.info()\n  console.log(info);\n\n}\n```\n\n### Service API\n\nOnce connected to a DeepDetect server, the Service API allows to:\n\n* create a service\n* fetch informations about a service\n* delete a service\n\n```js\nimport DD from 'deepdetect-js';\n\nasync () =\u003e {\n\n  const dd = new DD()\n\n  // Create a service\n  const serviceName = 'myserv';\n\n  const serviceConfig = {\n    description: 'example classification service',\n    model: {\n      repository: '/home/me/models/example',\n      templates: '../templates/caffe'\n    },\n    mllib: 'caffe',\n    parameters: {\n      input: { connector: 'txt' },\n      mllib: { nclasses: 20 },\n      output: {},\n    },\n  };\n\n  const createService = await dd.putService(serviceName, serviceConfig)\n\n  // Fetch service information\n  const service = await dd.getService(serviceName);\n  console.log(service);\n\n  // Delete service\n  const deleteService = await dd.deleteService(serviceName, {clear: 'full'});\n}\n```\n\n### Train API\n\nOnce connected to a DeepDetect server, the Train API allows to:\n\n* Create a training job\n* Get information on a non-blocking training job\n* Kills a non-blocking training job\n\n```js\nimport DD from 'deepdetect-js';\n\nasync () =\u003e {\n\n  const dd = new DD()\n  const serviceName = 'myserv';\n\n  // Create a training job\n  const train = await dd.postTrain(\n    serviceName,\n    [ '/home/me/deepdetect/examples/all/n20/news20' ],\n    {\n      test_split: 0.2,\n      shuffle: true,\n      min_count: 10,\n      min_word_length: 3,\n      count: false,\n    },\n    {\n      gpu: false,\n      solver: {\n        iterations: iterationsN20,\n        test_interval: 200,\n        base_lr: 0.05,\n        snapshot: 2000,\n        test_initialization: true,\n      },\n      net: {\n        batch_size: 100,\n      },\n    },\n    { measure: ['acc', 'mcll', 'f1'] },\n    false\n  );\n\n  // Get information on a non-blocking training job\n  const trainingJob = await dd.getTrain(serviceName);\n  console.log(trainingJob);\n\n  // Kills a non-blocking training job\n  const deletedTrainingJob = await dd.deleteTrain(serviceName);\n  console.log(deletedTrainingJob);\n\n}\n```\n\n### Predict API\n\nOnce connected to a DeepDetect server, the Predict API allows\nto makes prediction from data and model\n\n```js\nimport DD from 'deepdetect-js';\n\nasync () =\u003e {\n\n  const dd = new DD()\n  const serviceName = 'myserv';\n\n  // Predict with measures\n  const postData = {\n    service: serviceName,\n    data: [ '/home/me/deepdetect/examples/all/n20/news20' ],\n    parameters: {\n      input: {},\n      mllib: {\n        gpu: false,\n        net: {\n          test_batch_size: 10,\n        },\n      },\n      output: {\n        measure: ['f1']\n      }\n    }\n  };\n\n  const predict = await dd.postPredict(postData)\n  console.log(predict);\n\n}\n```\n\n## Build and release\n\n1. Modify version number in `package.json`\n2. `npm run build`\n3. `npm publish` - [documentation](https://www.freecodecamp.org/news/how-to-create-and-publish-your-first-npm-package/)\n\n## Testing\n\nIn order to run the test, you first need to run a deepdetect server loccaly on port 8080. To do so, you can use the following docker command:\n\n``` sh\ndocker run -d -p 8080:8080 docker.jolibrain.com/deepdetect_cpu\n```\n\nThen you can run the test suite:\n\n```sh\nyarn test\n```\n\nIf you find and issue with your tests, please check the header parameters available in ```src/index.test.js```.\n\n## Changelog\n\n* 1.8.12 - 21/03/2024 - return !response.ok error from http requests\n* 1.8.11 - 19/10/2023 - Add missing process lib\n* 1.8.10 - 19/10/2023 - Review dependabot alerts\n* 1.8.9  - 17/10/2023 - Update dependencies\n* 1.8.8  - 19/10/2021 - Add option to enable/disable Accept-Encoding gzip request header\n* 1.8.7  - 05/01/2020 - Replace NaN values in returned json from deepdetect server\n* 1.8.4  - 16/10/2020 - [Fix conditional check of options.sameOrigin](https://github.com/jolibrain/deepdetect-js/pull/13) by [eh-dub](https://github.com/eh-dub)\n\n## Contributors\n\nThanks goes to these people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"http://alexgirard.com/\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/373?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAlexandre Girard\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/jolibrain/deepdetect-js/commits?author=alx\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://ehdub.substack.com/\"\u003e\u003cimg src=\"https://avatars2.githubusercontent.com/u/846035?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAriel Weingarten\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/jolibrain/deepdetect-js/commits?author=eh-dub\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!\n\n## License\n\nMIT \u0026copy; [Jolibrain](http://jolibrain.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjolibrain%2Fdeepdetect-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjolibrain%2Fdeepdetect-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjolibrain%2Fdeepdetect-js/lists"}