Skip to content

custom models #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/mlkit-core/typings/objc!MLKitObjectDetection.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ declare class MLKObjectDetectorOptions extends MLKCommonObjectDetectorOptions {
static alloc(): MLKObjectDetectorOptions; // inherited from NSObject

static new(): MLKObjectDetectorOptions; // inherited from NSObject
loadCustomModel(path: string) {
return MLKLocalModel *localModel =
[[MLKLocalModel alloc] initWithPath:path];
}
}
18 changes: 18 additions & 0 deletions packages/mlkit-custom-image-labeling/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*", "node_modules/**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
37 changes: 37 additions & 0 deletions packages/mlkit-custom-image-labeling/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# @nativescript/mlkit-image-labeling

A plugin that is used with [@nativescript/mlkit-core](../mlkit-core/) to enable Image Labeling and provide the [ImageLabelingResult](#imagelabelingresult) type for the image labeling event data.

## Contents
* [Installation](#installation)
* [Use @nativescript/mlkit-image-labeling](#use-nativescriptmlkit-image-labeling)
* [API](#api)
* [ImageLabelingResult](#imagelabelingresult)
* [License](#license)

## Installation

```cli
npm install @nativescript/mlkit-image-labeling
```

## Use @nativescript/mlkit-image-labeling

For an example, read [Use @nativescript/mlkit-core](../mlkit-core#use-nativescriptmlkit-core) and [Image Labeling](../mlkit-core#image-labeling)

## API

### ImageLabelingResult

The Image Labeling event data type.

```ts
interface ImageLabelingResult {
text?: string
confidence?: number;
index?: number;
}
```
## License

Apache License Version 2.0
5 changes: 5 additions & 0 deletions packages/mlkit-custom-image-labeling/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface ImageLabelingResult {
text?: string
confidence?: number;
index?: number;
}
35 changes: 35 additions & 0 deletions packages/mlkit-custom-image-labeling/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "@nativescript/mlkit-image-labeling",
"version": "2.0.0",
"description": "NativeScript MLKit Image Labeling module",
"main": "index",
"typings": "index.d.ts",
"nativescript": {
"platforms": {
"ios": "6.0.0",
"android": "6.0.0"
}
},
"repository": {
"type": "git",
"url": "https://github.com/NativeScript/mlkit.git"
},
"keywords": [
"NativeScript",
"JavaScript",
"TypeScript",
"iOS",
"Android"
],
"author": {
"name": "NativeScript",
"email": "oss@nativescript.org"
},
"bugs": {
"url": "https://github.com/NativeScript/mlkit/issues"
},
"license": "Apache-2.0",
"homepage": "https://github.com/NativeScript/mlkit",
"readmeFilename": "README.md",
"bootstrapper": "@nativescript/plugin-seed"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dependencies {
implementation 'com.google.mlkit:object-detection-custom:17.0.0'
implementation 'com.google.mlkit:linkfirebase:17.0.0'
}
2 changes: 2 additions & 0 deletions packages/mlkit-custom-image-labeling/platforms/ios/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
platform :ios, '11.0'
pod 'GoogleMLKit/ImageLabeling', '4.0.0'
63 changes: 63 additions & 0 deletions packages/mlkit-custom-image-labeling/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"name": "mlkit-image-labeling",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "library",
"sourceRoot": "packages/mlkit-image-labeling",
"targets": {
"build": {
"executor": "@nrwl/js:tsc",
"options": {
"outputPath": "dist/packages/mlkit-image-labeling",
"tsConfig": "packages/mlkit-image-labeling/tsconfig.json",
"packageJson": "packages/mlkit-image-labeling/package.json",
"main": "packages/mlkit-image-labeling/index.ts",
"assets": [
"packages/mlkit-image-labeling/*.md",
"LICENSE",
{
"glob": "**/*",
"input": "packages/mlkit-image-labeling/platforms/",
"output": "./platforms/"
}
]
},
"dependsOn": [
{
"target": "build.all",
"projects": "dependencies"
}
]
},
"build.all": {
"executor": "nx:run-commands",
"options": {
"commands": ["node tools/scripts/build-finish.ts mlkit-image-labeling"],
"parallel": false
},
"outputs": ["{workspaceRoot}/dist/packages/mlkit-image-labeling"],
"dependsOn": [
{
"target": "build.all",
"projects": "dependencies"
},
{
"target": "build",
"projects": "self"
}
]
},
"focus": {
"executor": "nx:run-commands",
"options": {
"commands": ["nx g @nativescript/plugin-tools:focus-packages mlkit-image-labeling"],
"parallel": false
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": ["packages/mlkit-image-labeling/**/*.ts"]
}
}
}
}
1 change: 1 addition & 0 deletions packages/mlkit-custom-image-labeling/references.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference path="../../references.d.ts" />
9 changes: 9 additions & 0 deletions packages/mlkit-custom-image-labeling/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"rootDir": "."
},
"exclude": ["**/*.spec.ts", "angular"],
"include": ["**/*.ts", "references.d.ts"]
}
18 changes: 18 additions & 0 deletions packages/mlkit-custom-object-detection/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*", "node_modules/**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
73 changes: 73 additions & 0 deletions packages/mlkit-custom-object-detection/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# @nativescript/mlkit-custom-object-detection

A plugin that is used with [@nativescript/mlkit-core](../mlkit-core/) to enable Custom Object Detection and provide the [ObjectResult](#objectresult) type for the object detection event data.

## Contents
* [Installation](#installation)
* [Use @nativescript/mlkit-custom-object-detection](#use-nativescriptmlkit-custom-object-detection)
* [CustomObjectResult](#customobjectresult)
* [API](#api)
* [CustomObjectResult]

## Installation

Install `@nativescript/mlkit-custom-object-detection` by running the following command:

```cli
npm install @nativescript/mlkit-custom-object-detection
```

## Use @nativescript/mlkit-custom-object-detection

For an example, read [Use @nativescript/mlkit-core](../mlkit-core#use-nativescriptmlkit-core) and [Custom Object Detection](../mlkit-core#custom-object-detection).

## API

### ObjectResult

The type of object detection event data.

```ts
interface CustomObjectResult {
trackingId?: number
bounds: Bounds
labels: CustomObjectLabeling[]
}
```
#### CustomObjectLabeling

```ts
interface CustomObjectLabeling {
text?: string
confidence?: number
index?: number
}
```
#### Bounds

```ts
interface Bounds {
origin: Origin;
size: Size;
}
```
#### Origin

```ts
export interface Origin {
x: number;
y: number;
}
```
#### Size

```ts
interface Size {
width: number;
height: number;
}
```

## License

Apache License Version 2.0
28 changes: 28 additions & 0 deletions packages/mlkit-custom-object-detection/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export interface CustomObjectLabeling {
text?: string
confidence?: number
index?: number
}


export interface Origin {
x: number;
y: number;
}

export interface Size {
width: number;
height: number;
}

export interface Bounds {
origin: Origin;
size: Size;
}


export interface CustomObjectResult {
trackingId?: number
bounds: Bounds
labels: CustomObjectLabeling[]
}
35 changes: 35 additions & 0 deletions packages/mlkit-custom-object-detection/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "@nativescript/mlkit-object-detection",
"version": "2.0.0",
"description": "NativeScript MLKit Object Detection module",
"main": "index",
"typings": "index.d.ts",
"nativescript": {
"platforms": {
"ios": "6.0.0",
"android": "6.0.0"
}
},
"repository": {
"type": "git",
"url": "https://github.com/NativeScript/mlkit.git"
},
"keywords": [
"NativeScript",
"JavaScript",
"TypeScript",
"iOS",
"Android"
],
"author": {
"name": "NativeScript",
"email": "oss@nativescript.org"
},
"bugs": {
"url": "https://github.com/NativeScript/mlkit/issues"
},
"license": "Apache-2.0",
"homepage": "https://github.com/NativeScript/mlkit",
"readmeFilename": "README.md",
"bootstrapper": "@nativescript/plugin-seed"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dependencies {
implementation 'com.google.mlkit:object-detection-custom:17.0.0'
implementation 'com.google.mlkit:linkfirebase:17.0.0'
}
3 changes: 3 additions & 0 deletions packages/mlkit-custom-object-detection/platforms/ios/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
platform :ios, '11.0'
pod 'GoogleMLKit/ObjectDetectionCustom', '3.2.0'
pod 'GoogleMLKit/LinkFirebase', '3.2.0'
Loading