【发布时间】:2019-12-09 11:37:57
【问题描述】:
我正在创建一个使用 TensorFlow Lite 模型的图像超分辨率应用程序。该模型以 ByteBuffer 的形式给出输出图像,我将 ByteBuffer 转换为位图。接下来,我显示此位图,但没有显示任何内容。我正在使用的代码如下所示:
ByteBuffer out = ByteBuffer.allocate(4 * 384 * 384 * 3);
tflite.run(byteBuffer,out);
byte[] imageBytes= new byte[out.remaining()];
out.get(imageBytes);
final Bitmap outPut_Image = BitmapFactory.decodeByteArray(imageBytes,0,imageBytes.length);
//Toast.makeText(this,tflite.toString(),Toast.LENGTH_LONG).show();
Toast.makeText(this, "Working",Toast.LENGTH_LONG).show();
ImageView imageView = (ImageView) this.findViewById(R.id.imageView2);
imageView.setImageBitmap(outPut_Image);
请告诉我我在这里做错了什么。
【问题讨论】:
-
Toast.makeText(this, "Working",Toast.LENGTH_LONG).show();???在职的?你什么都没检查! -
if ( outPut_Image==null ) { toast bitmap would become too big for available memory and return}. -
Toast 只是为了检查 try 块是否有效。
-
嗯……位图是空的吗?为什么不反应?
-
有什么解决办法吗?
标签: java android tensorflow tensorflow-lite