python - Implementation of image pre-processing methods on android -




could please suggest library (or snippet) implement pre-processing python methods (e.g. numpy.expand_dims() or img_to_array) on android api 18 (to deploy app based on tensorflow mobile)? there analogous libraries python on java (e.g. nd4j), require device or emulator runs api level 21 or higher.

from keras.preprocessing.image import img_to_array import numpy np      image = img_to_array(image)     image = np.expand_dims(image, axis=0)     image /= 255. 

i interactive session:

in [168]: np.source(np.expand_dims) in file: /usr/local/lib/python3.5/dist-packages/numpy/lib/shape_base.py  def expand_dims(a, axis):     """     .... docs     """     = asarray(a)     shape = a.shape     if axis > a.ndim or axis < -a.ndim - 1:         # 2017-05-17, 1.13.0         warnings.warn("both axis > a.ndim , axis < -a.ndim - 1 "                       "deprecated , raise axiserror in future.",                       deprecationwarning, stacklevel=2)     # when deprecation period expires, delete if block,     if axis < 0:         axis = axis + a.ndim + 1     # , uncomment following line.     # axis = normalize_axis_index(axis, a.ndim + 1)     return a.reshape(shape[:axis] + (1,) + shape[axis:]) 

so uses reshape, shape includes size 1 dimension in right place. have been done [:,:,np.newaxis,...] syntax.

whether of portable java depends on array implementation in language.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -