• Sasha Illarionov's avatar
    Add DeepLab (#229)
    · 08c57d7d
    Sasha Illarionov создал
    This PR adds the DeepLab model together with a demo.
    
    ~~There are several issues with the implementation at the moment.~~ Here is the todo list:
    
    - [x] **Fix the grayscale-only segmentation maps**
    
    ~~The culprit might be [here](https://github.com/tensorflow/tfjs-models/blob/5fa0787a968799f0a614c663f83afb09b7e8f2cb/deeplab/src/utils.ts#L86).~~
    
    **UPDATE 05/06**: The problem was resolved by constructing a single buffer for the translated segmentation map, instead of building the tensor by stacking three separate channel buffers (see [here](https://github.com/tensorflow/tfjs-models/commit/218383a59dd84072dfb9e0d2ad6ec83e8b3d45d4)). I do not quite understand why this solves the problem.
    
    - [x] **Show performance stats in the demo**
    
    - [x] **Add loader for improved UX**
    
    - [x] **~~Fix~~ ~~Disable~~ Reserve `tf` to make mangling work**
    
    The code uses ES6 features, so I have picked [`rollup-plugin-terser`](https://github.com/TrySound/rollup-plugin-terser) instead of uglify, which breaks on the compilation of the esm module. ~~Terser, however, is pestered with bugs when mangling is enabled: the demo fails to recognise the minified `tf.tidy` function (the error is, say, `t.tidy is not a function`). I might as well revert to uglify after refactoring the code.~~
    
    **UPDATE 06/06**: ~~The problem persists even after playing with the mangling options, with the model missing `predict` method in the debugging mode. I have disabled mangling altogether and reported the issue (https://github.com/terser-js/terser/issues/364).~~
    
    **UPDATE 29/06**: Mangling works well when `tf` is reserved. See the awesome [explanation](https://github.com/terser-js/terser/issues/364#issuecomment-506958587) by @fabiosantoscode why this might be the case.
    
    - [x] **Improve docs**
    
    - [x] **Add tests**
    
    - [x] **Explore quantisation**
    
    **UPDATE 07/06**: The models are quantized by default.
    
    - [x] Add Cityscapes and ADE20K Labelling Schemes
    - [x] Change the gif demo to show all models with updated color mappings
    
    Please let me know if I am missing anything.
    
    cc: @manrajgrover
    08c57d7d