希望大家一天(或晚上)进展顺利。
我一直在玩我遇到的Caffe模型,而且我在使用输出数组时遇到了一些麻烦。我没有合作过……
看起来我能够弄清楚这一点。这不是数组顺序的问题,而是值和数据类型。这是我放在一起从输出中获取正确图像的代码。
predictions = model.predict({'data_55': image} , useCPUOnly = True) # Run the prediction map_final = predictions['fc8_seg'][0,0,:,:] # fc8_seg is the output of the neural network map_final = map_final.reshape((50,50)) # Reshape the output from shape (2500) to (50, 50) map_final = numpy.flip(map_final, 1) # Flip axis 1 to unmirror the image # Scale the values in the array to a range between 0 and 255 map_final -= map_final.min() map_final /= map_final.max() map_final = numpy.ceil(map_final*255) map_final_unint8 = map_final.astype(numpy.uint8) # Convert the data type to an uint8 pil_image = Image.fromarray(map_final_unint8, mode = 'L') # Create the PIL image
并输出:
一切看起来都应该如此!