Skip to content

Commit 1401b37

Browse files
author
Jo Kristian Bergum
committed
upgrade to onnx-runtime 1.11
1 parent 0fde865 commit 1401b37

File tree

8 files changed

+7980
-6550
lines changed

8 files changed

+7980
-6550
lines changed

package-lock.json

Lines changed: 7971 additions & 6540 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
"@testing-library/jest-dom": "^5.16.1",
1010
"@testing-library/react": "^12.1.2",
1111
"@testing-library/user-event": "^13.5.0",
12-
"onnxruntime-web": "^1.10.0",
12+
"onnxruntime-web": "^1.11.0",
1313
"react": "^17.0.2",
1414
"react-dom": "^17.0.2",
1515
"react-google-charts": "^3.0.15",
16-
"react-scripts": "5.0.0",
16+
"react-scripts": "^5.0.1",
1717
"typescript": "^4.5.4",
1818
"web-vitals": "^2.1.2"
1919
},
1.3 MB
Binary file not shown.
540 KB
Binary file not shown.
1.13 MB
Binary file not shown.

public/static/js/ort-wasm.wasm

323 KB
Binary file not shown.

src/App.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class TextInputArea extends React.Component {
1212
constructor(props) {
1313
super(props);
1414
this.state = {
15-
text: 'Enter text to classify emotion, model trained on English text',
15+
text: 'Enter text to classify emotion, model trained on English text.',
1616
data:columnNames,
1717
latency:0.0,
1818
downloading:modelDownloadInProgress()
@@ -23,7 +23,7 @@ class TextInputArea extends React.Component {
2323
componentDidMount() {
2424
this.timerID = setInterval(
2525
() => this.checkModelStatus(),
26-
2000
26+
1000
2727
);
2828
}
2929

@@ -53,7 +53,7 @@ class TextInputArea extends React.Component {
5353
return (
5454
<div className="App">
5555
<header className="App-header">
56-
<em>In-Browser NLP Inference</em>
56+
<em>In-Browser Transformer Inference</em>
5757
<Chart
5858
width={'400px'}
5959
height={'200px'}
@@ -95,7 +95,8 @@ class TextInputArea extends React.Component {
9595
placeholder={this.state.text} autoFocus onChange={this.handleChange}>
9696
</textarea>
9797
<div><font size="3">Inference Latency {this.state.latency} ms</font></div>
98-
<div><font size="3"><a href="https://github.com/jobergum/browser-ml-inference">Github browser-ml-inference </a></font></div>
98+
<div><font size="3">GitHub Repo: <a href="https://github.com/jobergum/browser-ml-inference">browser-ml-inference</a></font></div>
99+
<div><font size="3">Model was trained on the <a href="https://ai.googleblog.com/2021/10/goemotions-dataset-for-fine-grained.html">GoEmotions</a> dataset.</font></div>
99100
</header>
100101
</div>
101102
);

src/inference.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const model = "./xtremedistill-go-emotion-int8.onnx";
2121
const session = ort.InferenceSession.create(model, options);
2222
session.then(t => {
2323
downLoadingModel = false;
24-
//warmup the Virtual Machine tata
24+
//warmup the VM
2525
for(var i = 0; i < 10; i++) {
2626
lm_inference("this is a warmup inference");
2727
}
@@ -122,12 +122,10 @@ async function lm_inference(text) {
122122
if(encoded_ids.length === 0) {
123123
return [0.0, EMOJI_DEFAULT_DISPLAY];
124124
}
125-
const model_input = create_model_input(encoded_ids);
126125
const start = performance.now();
126+
const model_input = create_model_input(encoded_ids);
127127
const output = await session.then(s => { return s.run(model_input,['output_0'])});
128128
const duration = (performance.now() - start).toFixed(1);
129-
//const sequence_length = model_input['input_ids'].size;
130-
//console.log("Inference latency = " + duration + "ms, sequence_length=" + sequence_length);
131129
const probs = output['output_0'].data.map(sigmoid).map( t => Math.floor(t*100));
132130

133131
const result = [];

0 commit comments

Comments
 (0)