{"id":40277963,"url":"https://github.com/luoxuhai/react-native-classify-image","last_synced_at":"2026-01-20T03:10:18.483Z","repository":{"id":57336073,"uuid":"447794862","full_name":"luoxuhai/react-native-classify-image","owner":"luoxuhai","description":"🏞 react-native library to classify images using Vision | 对图像进行分类的 react-native 库","archived":false,"fork":false,"pushed_at":"2023-10-21T00:49:08.000Z","size":1732,"stargazers_count":29,"open_issues_count":3,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-25T16:26:15.073Z","etag":null,"topics":["classify-images","ios","react-native","vision"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/react-native-classify-image","language":"Swift","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/luoxuhai.png","metadata":{"files":{"readme":"README-zh_CN.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}},"created_at":"2022-01-14T00:31:11.000Z","updated_at":"2024-12-26T02:35:08.000Z","dependencies_parsed_at":"2023-02-18T14:01:09.016Z","dependency_job_id":null,"html_url":"https://github.com/luoxuhai/react-native-classify-image","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/luoxuhai/react-native-classify-image","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luoxuhai%2Freact-native-classify-image","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luoxuhai%2Freact-native-classify-image/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luoxuhai%2Freact-native-classify-image/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luoxuhai%2Freact-native-classify-image/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luoxuhai","download_url":"https://codeload.github.com/luoxuhai/react-native-classify-image/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luoxuhai%2Freact-native-classify-image/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28594958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T02:08:49.799Z","status":"ssl_error","status_checked_at":"2026-01-20T02:08:44.148Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["classify-images","ios","react-native","vision"],"created_at":"2026-01-20T03:10:17.013Z","updated_at":"2026-01-20T03:10:18.476Z","avatar_url":"https://github.com/luoxuhai.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1 align=\"center\"\u003e🏞 React Native Classify Image\u003c/h1\u003e\n  \u003ch3 align=\"center\"\u003e使用 Vision 对图像进行分类的 react-native 库\u003c/h3\u003e\n\u003c/div\u003e\n\n[English](./README.md) | 简体中文\n\n\u003cimg style=\"width: 50%;margin: 0 auto;\" src=\"https://s4.ax1x.com/2022/01/15/7JJaDI.png\" /\u003e\n\n识别结果，`confidence`（置信度，[0 - 1]区间内的小数）的值越大可信度越高。\n\n```js\n[\n  {\n    identifier: {\n      en: \"animal\",\n      zh_cn: \"动物\"\n    },\n    confidence: 0.848;\n  },\n  {\n    identifier: {\n      en:  \"cat\",\n      zh_cn: \"猫\"\n    },\n    confidence: 0.848;\n  },\n  {\n    identifier: {\n      en: \"clothing\",\n      zh_cn: \"衣服\"\n    },\n    confidence: 0.676;\n  },\n  {\n    identifier: {\n      en: \"hat\",\n      zh_cn: \"帽子\"\n    },\n    confidence: 0.631;\n  },\n  ...\n]\n```\n\n## ❗️ :warning:\n\n目前仅支持 iOS 13.0+\n\n## Installation\n\n`$ npm install react-native-classify-image --save`\n\nor\n\n`$ yarn add react-native-classify-image`\n\n### React Native\n\n```sh\n# RN \u003e= 0.60\ncd ios \u0026\u0026 pod install\n# RN \u003c 0.60\nreact-native link react-native-classify-image\n```\n\n### Expo\n\n```sh\nexpo prebuild\n```\n\n## Usage\n\n### 简单使用\n\n```js\nimport * as ClassifyImage from 'react-native-classify-image';\n\n// 本地路径\nconst path =\n  '/var/mobile/Containers/Data/Library/Caches/E5FA7C16-9E74-4C38-A7BA-FC2180D20DE9.jpg';\nClassifyImage.request(path)\n  .then((result) =\u003e {\n    // success\n  })\n  .catch((error) =\u003e {\n    // error\n  });\n```\n\n### 高级使用\n\n```js\nimport * as ClassifyImage from 'react-native-classify-image';\nimport RNFS from 'react-native-fs';\n\nconst path = `${RNFS.TemporaryDirectoryPath}/IMG_1234.jpg`;\n\n// https://github.com/itinance/react-native-fs\nRNFS.downloadFile({\n  fromUrl: 'https://s4.ax1x.com/2022/01/15/7JJaDI.png',\n  toFile: path,\n}).promise.then((res) =\u003e {\n  ClassifyImage.request(path, {\n    minConfidence: 0.6,\n    orientation: ClassifyImage.Orientation.Up,\n  })\n    .then((result) =\u003e {\n      // success\n    })\n    .catch((error) =\u003e {\n      // error\n    });\n});\n```\n\n## API\n\n### `request(path: string, options?: Object): Promise\u003cResult[]\u003e`\n\n| 参数               | 类型   | 描述                                                                                                                   |\n| ------------------ | ------ | ---------------------------------------------------------------------------------------------------------------------- |\n| **path**           | string | 图像文件的本地绝对路径. 可使用 [react-native-fs constants](https://github.com/itinance/react-native-fs#constants) 获取 |\n| **options** (可选) | object | 可选项，见下 `Options`                                                                                                 |\n\n### `supportedIdentifiers(): Promise\u003cstring[]\u003e`\n\n### Options\n\n| 参数                                  | 类型    | 描述                                                                                                   | 默认值           |\n| ------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------ | ---------------- |\n| **minConfidence** (可选)              | string  | 最小置信度，仅返回大于等于该值的数据。取值范围:[0-1]                                                   | 0.1              |\n| **preferBackgroundProcessing** (可选) | boolean | 如果设置为 `true`，则此属性会减少请求的内存占用、处理占用和 CPU/GPU 争用，但可能会花费更长的执行时间。 | false            |\n| **usesCPUOnly** (可选)                | boolean | 仅在 CPU 上执行。设置 `false` 表示可以自由地利用 GPU 来加速其处理。                                    | false            |\n| **orientation** (可选)                | number  | 图像的方向                                                                                             | `Orientation.Up` |\n\n### Result - 识别结果\n\n| 名称           | 类型   | 描述            |\n| -------------- | ------ | --------------- |\n| **identifier** | object | 分类标签名      |\n| **confidence** | number | 置信度，[0 - 1] |\n\n### Orientation\n\n- `Orientation.Up`: `1` - 默认方向\n- `Orientation.UpMirrored`: `2` - 水平翻转\n- `Orientation.Down`: `3` - 旋转 180°\n- `Orientation.DownMirrored`: `4` - 垂直翻转\n- `Orientation.Left`: `5` - 水平翻转并逆时针旋转 90°\n- `Orientation.LeftMirrored`: `6` - 顺时针旋转 90°\n- `Orientation.Right`: `7` - 水平翻转并顺时针旋转 90°\n- `Orientation.RightMirrored`: `8` - 顺时针旋转 90°\n\n## Troubleshooting\n\n1. 检查您的最低 iOS 版本。react-native-classify-image 要求最低 iOS 版本为 11.0（目前仅支持 iOS 13.0+ 使用）。\n   - 打开你的 Podfile\n   - 确保 `platform :ios` 设置为 11.0 或更高\n   - 确保 `iOS Deployment Target` 设置为 11.0 或更高\n2. 确保您在项目中创建了 Swift 桥接头。\n   - 使用 Xcode 打开你的项目（**xxx.xcworkspace**）\n   - 按照以下步骤创建 Swift 文件 **File \u003e New \u003e File (⌘+N)**\n   - 选择 **Swift File** 并点击 **Next**\n   - 输入文件名 **BridgingFile.swift**，然后点击创建，提示时点击 **Create Bridging Header**\n\n## TODO\n\n- [ ] 支持 Android\n- [ ] 支持识别指定区域\n- [ ] 支持网络图像\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluoxuhai%2Freact-native-classify-image","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluoxuhai%2Freact-native-classify-image","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluoxuhai%2Freact-native-classify-image/lists"}