frankfliu opened a new issue #12855: mxnet.image.image.imdecode() should support bytearray input URL: https://github.com/apache/incubator-mxnet/issues/12855 ## Description In commit d4991a0e324b53d8d6e84decbd237ff6a5a3ab08 python/mxnet/image/image.py added following checking: + if sys.version_info[0] == 3 and not isinstance(buf, (bytes, np.ndarray)): + raise ValueError('buf must be of type bytes or numpy.ndarray,' + 'if you would like to input type str, please convert to bytes') This broke backward compatibility. The old implementation support bytearray as input, not it only support: 1. str (python2) 2. bytes 3. np.ndarray 4. nd.NDArray We should bring bytearray support back. ## Environment info (Required) ----------Python Info---------- Version : 3.7.0 Compiler : Clang 9.0.0 (clang-900.0.39.2) Build : ('default', 'Oct 2 2018 09:19:48') Arch : ('64bit', '') ------------Pip Info----------- Version : 18.0 Directory : /usr/local/lib/python3.7/site-packages/pip ----------MXNet Info----------- Version : 1.3.1 Directory : /Users/lufen/source/mxnet/python/mxnet Hashtag not found. Not installed from pre-built package. ----------System Info---------- Platform : Darwin-16.7.0-x86_64-i386-64bit system : Darwin node : f45c89cb5707.ant.amazon.com release : 16.7.0 version : Darwin Kernel Version 16.7.0: Thu Jun 21 20:07:39 PDT 2018; root:xnu-3789.73.14~1/RELEASE_X86_64 ----------Hardware Info---------- machine : x86_64 processor : i386 b'machdep.cpu.extfeatures: SYSCALL XD 1GBPAGE EM64T LAHF LZCNT PREFETCHW RDTSCP TSCI' b'machdep.cpu.leaf7_features: SMEP ERMS RDWRFSGS TSC_THREAD_OFFSET BMI1 AVX2 BMI2 INVPCID SMAP RDSEED ADX IPT FPU_CSDS' b'machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX EST TM2 SSSE3 FMA CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC MOVBE POPCNT AES PCID XSAVE OSXSAVE SEGLIM64 TSCTMR AVX1.0 RDRAND F16C' b'machdep.cpu.brand_string: Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz' ----------Network Test---------- Setting timeout: 10 Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.0165 sec, LOAD: 0.6083 sec. Timing for Gluon Tutorial(en): http://gluon.mxnet.io, DNS: 0.0189 sec, LOAD: 0.0970 sec. Timing for Gluon Tutorial(cn): https://zh.gluon.ai, DNS: 0.0192 sec, LOAD: 0.0694 sec. Timing for FashionMNIST: https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, DNS: 0.0254 sec, LOAD: 0.1204 sec. Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0145 sec, LOAD: 1.3885 sec. Timing for Conda: https://repo.continuum.io/pkgs/free/, DNS: 0.0007 sec, LOAD: 0.0617 sec. ## Build info (Required if built from source) MXNet commit hash: 815f36ce8b4ed16fe27d500f5c8c930cd10cee5c Build config: # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. #------------------------------------------------------------------------------- # Template configuration for compiling mxnet # # If you want to change the configuration, please use the following # steps. Assume you are on the root directory of mxnet. First copy the this # file so that any local changes will be ignored by git # # $ cp make/config.mk . # # Next modify the according entries, and then compile by # # $ make # # or build in parallel with 8 threads # # $ make -j8 #------------------------------------------------------------------------------- #--------------------- # choice of compiler #-------------------- export CC = gcc export CXX = g++ export NVCC = nvcc # whether compile with options for MXNet developer DEV = 0 # whether compile with debug DEBUG = 1 # the additional link flags you want to add ADD_LDFLAGS = # the additional compile flags you want to add ADD_CFLAGS = #--------------------------------------------- # matrix computation libraries for CPU/GPU #--------------------------------------------- # whether use CUDA during compile USE_CUDA = 0 # add the path to CUDA library to link and compile flag # if you have already add them to environment variable, leave it as NONE # USE_CUDA_PATH = /usr/local/cuda USE_CUDA_PATH = NONE # whether to enable CUDA runtime compilation ENABLE_CUDA_RTC = 1 # whether use CUDNN R3 library USE_CUDNN = 0 # whether use opencv during compilation # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 # use openmp for parallelization USE_OPENMP = 0 # choose the version of blas you want to use # can be: mkl, blas, atlas, openblas USE_BLAS = apple # whether use lapack during compilation # only effective when compiled with blas versions openblas/apple/atlas/mkl USE_LAPACK = 1 # by default, disable lapack when using MKL # switch on when there is a full installation of MKL available (not just MKL_ML) ifeq ($(USE_BLAS), mkl) USE_LAPACK = 0 endif # add path to intel library, you may need it for MKL, if you did not add the path # to environment variable USE_INTEL_PATH = NONE #---------------------------- # distributed computing #---------------------------- # whether or not to enable multi-machine supporting USE_DIST_KVSTORE = 0 # whether or not allow to read and write HDFS directly. If yes, then hadoop is # required USE_HDFS = 0 # path to libjvm.so. required if USE_HDFS=1 LIBJVM=$(JAVA_HOME)/jre/lib/amd64/server # whether or not allow to read and write AWS S3 directly. If yes, then # libcurl4-openssl-dev is required, it can be installed on Ubuntu by # sudo apt-get install -y libcurl4-openssl-dev USE_S3 = 0 #---------------------------- # additional operators #---------------------------- # path to folders containing projects specific operators that you don't want to put in src/operators EXTRA_OPERATORS = #---------------------------- # other features #---------------------------- # Create C++ interface package USE_CPP_PACKAGE = 0 #---------------------------- # plugins #---------------------------- # whether to use torch integration. This requires installing torch. # TORCH_PATH = $(HOME)/torch # MXNET_PLUGINS += plugin/torch/torch.mk USE_BLAS = openblas ADD_CFLAGS += -I/usr/local/opt/openblas/include ADD_LDFLAGS += -L/usr/local/opt/openblas/lib ADD_LDFLAGS += -L/usr/local/lib/graphviz/ ## Error Message: ValueError: buf must be of type bytes or numpy.ndarray,if you would like to input type str, please convert to bytes ## Minimum reproducible example >>> from mxnet import image as img >>> buf = bytearray("111", "utf-8") >>> img.imdecode(buf, 1, True, None) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/lufen/source/mxnet/python/mxnet/image/image.py", line 139, in imdecode raise ValueError('buf must be of type bytes or numpy.ndarray,' ValueError: buf must be of type bytes or numpy.ndarray,if you would like to input type str, please convert to bytes ## What have you tried to solve it? I have to manually convert bytearray to bytes.
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
