apple / apple/coremltools

Area interpolation support for Tensorflow (ResizeArea)

Open
#1,333 2 comments 1 reaction 0 assignees View on GitHub
missing layer type tf2.x / tf.keras
Dominant language
Python
Stars
5.4k
Forks
850
Avg merge
4d 5h
Merged PRs (30d)
10

Description

## 🌱 Describe your Feature Request
In my tensorflow model I have a layer where I use Lambda with [**tf.image.resize** ](https://www.tensorflow.org/api_docs/python/tf/image/resize) anti-aliased resampling **with area interpolation**. Unfortunately, this operation (**ResizeArea**) is not supported in the current version of coremltools and I have to do a custom operation wrapper and then implement it on a swift.

## Use cases
Example:
```
ImgResizer = Lambda(lambda x: tf.image.resize(x, pool_size, method='area'),
name='feature_resizer')
pools = [ImgResizer(l.output) for l in feature_layers]
```

## Describe alternatives you've considered
[Custom operation](https://coremltools.readme.io/docs/custom-operators)
I also tried another resizing method: bilinear, but the conversion outputs an error:
```
File "/home/alex/anaconda3/envs/tfgpu/lib/python3.8/site-packages/coremltools/converters/mil/mil/builder.py", line 75, in _add_const
raise ValueError("Cannot add const {}".format(val))
ValueError: Cannot add const 5.0001/is57
```
My pool_size is (5,5), maybe it helps.
Thank you!

Contributor guide

Open the contributing guide

Research direction

Start by tracing the TensorFlow tf.image.resize conversion entry point for method='area' and compare it with the currently supported resize methods. Done means the supplied Lambda example converts without a custom operation and the resulting model performs area interpolation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, tensorflow
Domain
machine-learning
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.