diff --git a/src/actions/index.js b/src/actions/index.js
index b9199ef..d5ee098 100644
--- a/src/actions/index.js
+++ b/src/actions/index.js
@@ -91,7 +91,17 @@ export const showNavigation = () => async (dispatch, getState) => {
}
export const downloadModel = () => async (dispatch, getState) => {
- const model = await tf.loadLayersModel('/bai_model/model.json'); // Load Model
+ let options = {
+ onProgress: (p)=>{
+
+ dispatch({
+ type: 'SET_PROGRESS',
+ payload: p.toFixed(2)*100
+ });
+ }
+ }
+
+ const model = await tf.loadLayersModel('/bai_model/model.json', options); // Load Model
dispatch({
type: 'SET_MODEL',
diff --git a/src/components/Bai.js b/src/components/Bai.js
index b8b44da..fa875f1 100644
--- a/src/components/Bai.js
+++ b/src/components/Bai.js
@@ -50,8 +50,9 @@ class Bai extends React.Component {
Would you like to download the model?
By clicking Accept below, you will download the model which may be between 100 mb in size to 1 gb.
-
+
{this.props.loading}
+
{this.props.loading?this.props.downloadProgress+"%":""}
)
:(
@@ -81,7 +82,7 @@ class Bai extends React.Component {
}
}
const mapStateToProps = (state) => {
- return {model: state.model.model, loading: state.model.loading, last_prediction: state.model.last_prediction};
+ return {model: state.model.model, loading: state.model.loading, last_prediction: state.model.last_prediction, downloadProgress: state.model.progress};
}
export default connect(mapStateToProps, {downloadModel, loadingModel, predict})(Bai);
diff --git a/src/components/css/Bai.css b/src/components/css/Bai.css
index 0f07eb5..49d1b9b 100644
--- a/src/components/css/Bai.css
+++ b/src/components/css/Bai.css
@@ -65,4 +65,8 @@
.Bai .content {
display: flex;
flex-direction: column;
+}
+
+.Bai .hide {
+ display: none;
}
\ No newline at end of file
diff --git a/src/reducers/modelReducer.js b/src/reducers/modelReducer.js
index 5c82964..a6a3d7d 100644
--- a/src/reducers/modelReducer.js
+++ b/src/reducers/modelReducer.js
@@ -1,12 +1,15 @@
//SET_MODEL
-let modelReducer = (state={model: null, loading: ""}, action) => {
+let modelReducer = (state={model: null, loading: "", progress: 0}, action) => {
switch(action.type) {
case 'SET_MODEL':
return { ...state, model: action.payload };
case 'SET_LOADING':
return { ...state, loading: action.payload };
case 'SET_LAST_PRED':
- return { ...state, last_prediction: action.payload };
+ return { ...state, last_prediction: action.payload };
+ case 'SET_PROGRESS':
+ return { ...state, progress: action.payload };
+
default:
return state;
}