Skip to content

Commit

Permalink
Merge branch 'master' into time
Browse files Browse the repository at this point in the history
  • Loading branch information
yoyota committed Feb 10, 2020
2 parents 467c72c + de3cfb4 commit 45678bd
Show file tree
Hide file tree
Showing 17 changed files with 337 additions and 64 deletions.
7 changes: 6 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"plugins": [
["transform-react-remove-prop-types", {
"removeImport": true
}]
],
"presets": ["@babel/preset-env", "@babel/preset-react"]
}
}
13 changes: 11 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
jest: true,
browser: true
},
plugins: ["jest", "promise", "prettier", "react", "react-hooks"],
plugins: ["jest", "markdown", "promise", "prettier", "react", "react-hooks"],
rules: {
"import/no-extraneous-dependencies": "off",
"no-alert": "error",
Expand All @@ -33,5 +33,14 @@ module.exports = {
"react/jsx-filename-extension": "off",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
}
},
overrides: [{
"files": ["**/*.md"],
"rules": {
"react/jsx-no-undef": "off",
"import/no-unresolved": "off",
"no-unused-expressions": "off",
"react/react-in-jsx-scope": "off"
}
}]
}
23 changes: 23 additions & 0 deletions .github/workflows/github-pages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: github pages

on:
release:
types: [created]

jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12.x
- run: npm ci
- run: npm run docs:build
- run: echo "react-posenet.yoyota.dev" > ./dist-docs/CNAME
- name: deploy
uses: peaceiris/actions-gh-pages@v2
env:
PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: ./dist-docs
1 change: 0 additions & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- run: echo $NPM_TOKEN
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ yarn-debug.log*
yarn-error.log*

# dist
dist
dist
dist-docs
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
# React PoseNet

React PoseNet is a handy wrapper component for [tfjs-models/posenet](https://github.com/tensorflow/tfjs-models/tree/master/posenet)

## Documentation

https://react-posenet.yoyota.dev

## Example

[pull up counter](https://github.com/yoyota/react-posenet-pull-up)
<img src="https://i.imgur.com/xTP8Otx.gif" width=300 height=300 />

## Installation

```bash
npm install --save react-posenet
```

### Usage

```jsx
import PoseNet from "react-posenet"

export default function App() {
return <PoseNet />
}
```

## Core Feautres

### [onEstimate](https://react-posenet.yoyota.dev/#/Props%20examples?id=section-onestimate)

gets called after estimation. [poses](https://github.com/tensorflow/tfjs-models/tree/master/posenet#keypoints) is a passed parameter

### [input](https://react-posenet.yoyota.dev/#/Props%20examples?id=section-input)
the input image to feed through the network. see
[tfjs-posenet document](https://github.com/tensorflow/tfjs-models/tree/master/posenet#params-in-estimatesinglepose)
If input is not specified react-posenet try to [getUserMedia](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia)
9 changes: 9 additions & 0 deletions docs/Documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- [Github repository](https://github.com/yoyota/react-posenet)

React PoseNet is a handy wrapper component for [tfjs-models/posenet](https://github.com/tensorflow/tfjs-models/tree/master/posenet)

## Installation

```bash
npm install --save react-posenet
```
13 changes: 13 additions & 0 deletions docs/input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
```jsx
import { useMemo } from "react"
import PoseNet from "react-posenet"

const input = useMemo(() => {
const image = new Image()
image.crossOrigin = ""
image.src = "https://i.imgur.com/oV2ZNuD.jpg"
return image
}, [])

;<PoseNet input={input} />
```
19 changes: 19 additions & 0 deletions docs/onEstimate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
If your device dose not have camera, you will see error message like
<font color="red">Requested device not found</font>

```jsx
import { useState } from "react"
import PoseNet from "react-posenet"

const [posesString, setPosesString] = useState([])

;<>
<PoseNet
inferenceConfig={{ decodingMethod: "single-person" }}
onEstimate={poses => {
setPosesString(JSON.stringify(poses))
}}
/>
<p>{posesString}</p>
</>
```
1 change: 1 addition & 0 deletions docs/test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Test3
100 changes: 97 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"main": "dist/index.js",
"scripts": {
"build": "rollup --config",
"lint": "eslint --fix-dry-run src",
"lint": "eslint --ext md --ext js --fix-dry-run src docs",
"start": "styleguidist server",
"styleguide:build": "styleguidist build"
"docs:build": "styleguidist build"
},
"repository": {
"type": "git",
Expand All @@ -22,23 +22,27 @@
"@tensorflow-models/posenet": "^2.2.1",
"@tensorflow/tfjs": "^1.3.2",
"@tensorflow/tfjs-core": "^1.4.0",
"await-to-js": "^2.1.1"
"await-to-js": "^2.1.1",
"regenerator-runtime": "^0.13.3"
},
"peerDependencies": {
"react": "^16.12.0",
"react-dom": "^16.12.0"
},
"devDependencies": {
"prop-types": "^15.7.2",
"@babel/core": "^7.7.5",
"@babel/preset-env": "^7.7.5",
"@babel/preset-react": "^7.7.4",
"babel-loader": "^8.0.6",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"eslint": "^6.7.2",
"eslint-config-airbnb": "^17.1.1",
"eslint-config-prettier": "^6.7.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jest": "^22.21.0",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-markdown": "^1.0.1",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.17.0",
Expand All @@ -55,4 +59,4 @@
"rollup-plugin-terser": "^5.1.3",
"webpack": "^4.41.2"
}
}
}
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ export default [
},
external: ["react", "react-dom"],
plugins: [
resolve(),
babel({
exclude: "node_modules/**"
}),
external(),
resolve(),
terser()
]
}
Expand Down
Loading

0 comments on commit 45678bd

Please sign in to comment.