{"id":13576980,"url":"https://github.com/lucleray/tensorflow-lambda","last_synced_at":"2025-04-30T11:44:32.594Z","repository":{"id":41125098,"uuid":"175384029","full_name":"lucleray/tensorflow-lambda","owner":"lucleray","description":"run tensorflow on lambdas (aws, vercel, ...)","archived":false,"fork":false,"pushed_at":"2021-09-01T02:53:38.000Z","size":20389,"stargazers_count":47,"open_issues_count":12,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-29T19:38:54.687Z","etag":null,"topics":["aws","aws-lambda","lambda","nodejs","serverless","tensorflow","tfjs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lucleray.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-13T09:03:44.000Z","updated_at":"2024-08-08T15:15:54.000Z","dependencies_parsed_at":"2022-09-07T20:21:26.869Z","dependency_job_id":null,"html_url":"https://github.com/lucleray/tensorflow-lambda","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucleray%2Ftensorflow-lambda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucleray%2Ftensorflow-lambda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucleray%2Ftensorflow-lambda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucleray%2Ftensorflow-lambda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucleray","download_url":"https://codeload.github.com/lucleray/tensorflow-lambda/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229082279,"owners_count":18017251,"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":["aws","aws-lambda","lambda","nodejs","serverless","tensorflow","tfjs"],"created_at":"2024-08-01T15:01:16.509Z","updated_at":"2024-12-10T14:59:24.516Z","avatar_url":"https://github.com/lucleray.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# tensorflow-lambda\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"logo.png\" width=\"380\" /\u003e\n\u003c/div\u003e\n\n## Usage\n\nFirst, install the package:\n\n```\nyarn add tensorflow-lambda\n```\n\nYou can then use it like this:\n\n```js\nconst loadTf = require('tensorflow-lambda')\n\nconst tf = await loadTf()\n\n// you get the same `tf` object that would get if you were doing:\n// const tf = require('@tensorflow/tfjs')\n\ntf.tensor([1, 2, 3, 4]).print()\n```\n\nHave a look at these examples :\n\n- [object-detection](https://github.com/lucleray/object-detection) (deployed with Vercel)\n\n## Local usage\n\nWhen not used in a lambda environment (for example, locally on your computer when you're developing), `tensorflow-lambda` will require `@tensorflow/tfjs-node` instead of deflating a pre-compiled version in `/tmp`.\n\nTherefore, you need to install `@tensorflow/tfjs-node` to use this package locally:\n\n```\nyarn add @tensorflow/tfjs-node --dev\n```\n\nYou can then use the package the same way you would use it in a lambda environment locally.\n\nHave a look at [these lines](https://github.com/lucleray/tensorflow-lambda/blob/c056a3959c117d40cc69a1e76572c856b5d23cd6/index.js#L10-L16) to understand how it detects if it runs in a lambda environement.\n\n## How it works ?\n\nThe package contains a zipped and compressed version of all the dependencies and binaries needed to run `@tensorflow/tfjs-node` on AWS Lambda (these dependencies are built with Github Actions).\n\nDuring cold start, the files are deflated in `/tmp` and required in your node program.\n\n## Motivation\n\n`@tensorflow/tfjs` works with AWS Lambda but the main problem is that it is slow very slow when used in node. On the other hand, `@tensorflow/tfjs-node` is fast when used with node but it is \u003e140mo and it does not fit under AWS Lambda's size limit (50mo) and it needs to be pre-compiled for lambda for it to work in a lambda environment.\n\nI was looking for an easy way to use tensorflowjs with lambda and I couldn't find any, so I made this package.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucleray%2Ftensorflow-lambda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucleray%2Ftensorflow-lambda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucleray%2Ftensorflow-lambda/lists"}