全部产品
云市场

PAI图像特征抽取

更新时间:2020-05-11 14:26:12

PAI-EasyVision提供强大的图像特征抽取的能力,支持多机分布式运行。利用PAI-EasyVision,你可以方便的从图片中抽取特征,支持从oss读取图片,结果写回oss文件, 同样支持读表获取图片、结果写回表中

下面我们以oss IO通路为例介绍一下图片特征抽取的过程。

数据说明

详细参考数据格式说明

PAI命令示例

基于上面产生的文件列表,你可以执行pai命令来进行特征抽取

  1. pai -name ev_predict_ext
  2. -Dmodel_path='oss://pai-vision-data-sh/pretrained_models/saved_models/resnet_v1_50/'
  3. -Dmodel_type='feature_extractor'
  4. -Dinput_oss_file='oss://path/to/your/filelist.txt'
  5. -Doutput_oss_file='oss://path/to/your/result.txt'
  6. -Dimage_type='url'
  7. -Dfeature_name='resnet_v1_50/block4'
  8. -Dnum_worker=2
  9. -DcpuRequired=800
  10. -DgpuRequired=100
  11. -Dbuckets='oss://pai-vision-data-sh/'
  12. -Darn='your_role_arn'
  13. -DossHost='oss-cn-shanghai-internal.aliyuncs.com'

输出结果

结果文件中每一行是一个图片的特征结果, 由文件路径和json字符串构成,示例如下:

  1. oss://path/to/your/image1.jpg, {"feature": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.4583122730255127, 0.0]}
  2. oss://path/to/your/image1.jpg, {"feature": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.4583122730255127, 0.0]}
  3. oss://path/to/your/image1.jpg, {"feature": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.4583122730255127, 0.0]}

其中json字符串中只有一个k-v对,feature对应的value表示图像特征,由一个list构成,是一个一维向量

模型地址和模型输出说明

resnet_v1_50地址: oss://pai-vision-data-sh/pretrained_models/saved_models/resnet_v1_50

输出说明

  1. resnet_v1_50/block1 shape: [None, 56, 56, 256] type: <dtype: 'float32'>
  2. resnet_v1_50/block2 shape: [None, 28, 28, 512] type: <dtype: 'float32'>
  3. resnet_v1_50/block3 shape: [None, 14, 14, 1024] type: <dtype: 'float32'>
  4. resnet_v1_50/block4 shape: [None, 7, 7, 2048] type: <dtype: 'float32'>
  5. AvgPool_1a shape: [None, 1, 1, 2048] type: <dtype: 'float32'>
  6. resnet_v1_50/logits shape: [None, 1, 1, 1000] type: <dtype: 'float32'>
  7. predictions shape: [None] type: <dtype: 'int32'>
  8. class shape: [None] type: <dtype: 'int32'>
  9. preprocessed_images shape: [None, 224, 224, 3] type: <dtype: 'float32'>
  10. resnet_v1_50/conv1 shape: [None, 112, 112, 64] type: <dtype: 'float32'>
  11. logits shape: [None, 1000] type: <dtype: 'float32'>
  12. probs shape: [None, 1001] type: <dtype: 'float32'>
  13. resnet_v1_50/spatial_squeeze shape: [None, 1000] type: <dtype: 'float32'>

resnet_v1_101地址: oss://pai-vision-data-sh/pretrained_models/saved_models/resnet_v1_101输出说明

  1. resnet_v1_101/block4 shape: [None, 7, 7, 2048] type: <dtype: 'float32'>
  2. resnet_v1_101/logits shape: [None, 1, 1, 1000] type: <dtype: 'float32'>
  3. resnet_v1_101/block2 shape: [None, 28, 28, 512] type: <dtype: 'float32'>
  4. resnet_v1_101/conv1 shape: [None, 112, 112, 64] type: <dtype: 'float32'>
  5. resnet_v1_101/block1 shape: [None, 56, 56, 256] type: <dtype: 'float32'>
  6. class shape: [None] type: <dtype: 'int32'>
  7. resnet_v1_101/spatial_squeeze shape: [None, 1000] type: <dtype: 'float32'>
  8. predictions shape: [None] type: <dtype: 'int32'>
  9. preprocessed_images shape: [None, 224, 224, 3] type: <dtype: 'float32'>
  10. logits shape: [None, 1000] type: <dtype: 'float32'>
  11. resnet_v1_101/block3 shape: [None, 14, 14, 1024] type: <dtype: 'float32'>
  12. probs shape: [None, 1001] type: <dtype: 'float32'>
  13. AvgPool_1a shape: [None, 1, 1, 2048] type: <dtype: 'float32'>

inception_v3地址: oss://pai-vision-data-sh/pretrained_models/saved_models/inception_v3输出说明

  1. preprocessed_images shape: [None, 299, 299, 3] type: <dtype: 'float32'>
  2. Conv2d_1a_3x3 shape: [None, 149, 149, 32] type: <dtype: 'float32'>
  3. Conv2d_2a_3x3 shape: [None, 147, 147, 32] type: <dtype: 'float32'>
  4. Conv2d_2b_3x3 shape: [None, 147, 147, 64] type: <dtype: 'float32'>
  5. MaxPool_3a_3x3 shape: [None, 73, 73, 64] type: <dtype: 'float32'>
  6. Conv2d_3b_1x1 shape: [None, 73, 73, 80] type: <dtype: 'float32'>
  7. Conv2d_4a_3x3 shape: [None, 71, 71, 192] type: <dtype: 'float32'>
  8. MaxPool_5a_3x3 shape: [None, 35, 35, 192] type: <dtype: 'float32'>
  9. Mixed_5b shape: [None, 35, 35, 256] type: <dtype: 'float32'>
  10. Mixed_5c shape: [None, 35, 35, 288] type: <dtype: 'float32'>
  11. Mixed_5d shape: [None, 35, 35, 288] type: <dtype: 'float32'>
  12. Mixed_6a shape: [None, 17, 17, 768] type: <dtype: 'float32'>
  13. Mixed_6b shape: [None, 17, 17, 768] type: <dtype: 'float32'>
  14. Mixed_6c shape: [None, 17, 17, 768] type: <dtype: 'float32'>
  15. Mixed_6d shape: [None, 17, 17, 768] type: <dtype: 'float32'>
  16. Mixed_6e shape: [None, 17, 17, 768] type: <dtype: 'float32'>
  17. Mixed_7a shape: [None, 8, 8, 1280] type: <dtype: 'float32'>
  18. Mixed_7b shape: [None, 8, 8, 2048] type: <dtype: 'float32'>
  19. Mixed_7c shape: [None, 8, 8, 2048] type: <dtype: 'float32'>
  20. AvgPool_1a shape: [None, 1, 1, 2048] type: <dtype: 'float32'>
  21. PreLogits shape: [None, 1, 1, 2048] type: <dtype: 'float32'>
  22. Logits shape: [None, 1001] type: <dtype: 'float32'>
  23. Predictions shape: [None, 1001] type: <dtype: 'float32'>
  24. logits shape: [None, 1001] type: <dtype: 'float32'>
  25. probs shape: [None, 1001] type: <dtype: 'float32'>
  26. class shape: [None] type: <dtype: 'int32'>
  27. predictions shape: [None] type: <dtype: 'int32'>
  28. original_image shape: [None, None, None, 3] type: <dtype: 'float32'>
  29. original_image_shape shape: [None, 3] type: <dtype: 'int32'>

inception_v4地址: oss://pai-vision-data-sh/pretrained_models/saved_models/inception_v4输出说明

  1. preprocessed_images shape: [None, 299, 299, 3] type: <dtype: 'float32'>
  2. Conv2d_1a_3x3 shape: [None, 149, 149, 32] type: <dtype: 'float32'>
  3. Conv2d_2a_3x3 shape: [None, 147, 147, 32] type: <dtype: 'float32'>
  4. Conv2d_2b_3x3 shape: [None, 147, 147, 64] type: <dtype: 'float32'>
  5. Mixed_3a shape: [None, 73, 73, 160] type: <dtype: 'float32'>
  6. Mixed_4a shape: [None, 71, 71, 192] type: <dtype: 'float32'>
  7. Mixed_5a shape: [None, 35, 35, 384] type: <dtype: 'float32'>
  8. Mixed_5b shape: [None, 35, 35, 384] type: <dtype: 'float32'>
  9. Mixed_5c shape: [None, 35, 35, 384] type: <dtype: 'float32'>
  10. Mixed_5d shape: [None, 35, 35, 384] type: <dtype: 'float32'>
  11. Mixed_5e shape: [None, 35, 35, 384] type: <dtype: 'float32'>
  12. Mixed_6a shape: [None, 17, 17, 1024] type: <dtype: 'float32'>
  13. Mixed_6b shape: [None, 17, 17, 1024] type: <dtype: 'float32'>
  14. Mixed_6c shape: [None, 17, 17, 1024] type: <dtype: 'float32'>
  15. Mixed_6d shape: [None, 17, 17, 1024] type: <dtype: 'float32'>
  16. Mixed_6e shape: [None, 17, 17, 1024] type: <dtype: 'float32'>
  17. Mixed_6f shape: [None, 17, 17, 1024] type: <dtype: 'float32'>
  18. Mixed_6g shape: [None, 17, 17, 1024] type: <dtype: 'float32'>
  19. Mixed_6h shape: [None, 17, 17, 1024] type: <dtype: 'float32'>
  20. Mixed_7a shape: [None, 8, 8, 1536] type: <dtype: 'float32'>
  21. Mixed_7b shape: [None, 8, 8, 1536] type: <dtype: 'float32'>
  22. Mixed_7c shape: [None, 8, 8, 1536] type: <dtype: 'float32'>
  23. Mixed_7d shape: [None, 8, 8, 1536] type: <dtype: 'float32'>
  24. AvgPool_1a shape: [None, 1, 1, 1536] type: <dtype: 'float32'>
  25. PreLogitsFlatten shape: [None, 1536] type: <dtype: 'float32'>
  26. Logits shape: [None, 1001] type: <dtype: 'float32'>
  27. Predictions shape: [None, 1001] type: <dtype: 'float32'>
  28. logits shape: [None, 1001] type: <dtype: 'float32'>
  29. probs shape: [None, 1001] type: <dtype: 'float32'>
  30. class shape: [None] type: <dtype: 'int32'>
  31. predictions shape: [None] type: <dtype: 'int32'>
  32. original_image shape: [None, None, None, 3] type: <dtype: 'float32'>
  33. original_image_shape shape: [None, 3] type: <dtype: 'int32'>

mobilenet_v2地址: oss://pai-vision-data-sh/pretrained_models/saved_models/mobilenet_v2_1.0_224输出说明

  1. preprocessed_images shape: [None, 224, 224, 3] type: <dtype: 'float32'>
  2. layer_1 shape: [None, 112, 112, 32] type: <dtype: 'float32'>
  3. layer_2 shape: [None, 112, 112, 16] type: <dtype: 'float32'>
  4. layer_3 shape: [None, 56, 56, 24] type: <dtype: 'float32'>
  5. layer_4 shape: [None, 56, 56, 24] type: <dtype: 'float32'>
  6. layer_5 shape: [None, 28, 28, 32] type: <dtype: 'float32'>
  7. layer_6 shape: [None, 28, 28, 32] type: <dtype: 'float32'>
  8. layer_7 shape: [None, 28, 28, 32] type: <dtype: 'float32'>
  9. layer_8 shape: [None, 14, 14, 64] type: <dtype: 'float32'>
  10. layer_9 shape: [None, 14, 14, 64] type: <dtype: 'float32'>
  11. layer_10 shape: [None, 14, 14, 64] type: <dtype: 'float32'>
  12. layer_11 shape: [None, 14, 14, 64] type: <dtype: 'float32'>
  13. layer_12 shape: [None, 14, 14, 96] type: <dtype: 'float32'>
  14. layer_13 shape: [None, 14, 14, 96] type: <dtype: 'float32'>
  15. layer_14 shape: [None, 14, 14, 96] type: <dtype: 'float32'>
  16. layer_15 shape: [None, 7, 7, 160] type: <dtype: 'float32'>
  17. layer_16 shape: [None, 7, 7, 160] type: <dtype: 'float32'>
  18. layer_17 shape: [None, 7, 7, 160] type: <dtype: 'float32'>
  19. layer_18 shape: [None, 7, 7, 320] type: <dtype: 'float32'>
  20. layer_19 shape: [None, 7, 7, 1280] type: <dtype: 'float32'>
  21. layer_2/depthwise_output shape: [None, 112, 112, 32] type: <dtype: 'float32'>
  22. layer_2/output shape: [None, 112, 112, 16] type: <dtype: 'float32'>
  23. layer_3/expansion_output shape: [None, 112, 112, 96] type: <dtype: 'float32'>
  24. layer_3/depthwise_output shape: [None, 56, 56, 96] type: <dtype: 'float32'>
  25. layer_3/output shape: [None, 56, 56, 24] type: <dtype: 'float32'>
  26. layer_4/expansion_output shape: [None, 56, 56, 144] type: <dtype: 'float32'>
  27. layer_4/depthwise_output shape: [None, 56, 56, 144] type: <dtype: 'float32'>
  28. layer_4/output shape: [None, 56, 56, 24] type: <dtype: 'float32'>
  29. layer_5/expansion_output shape: [None, 56, 56, 144] type: <dtype: 'float32'>
  30. layer_5/depthwise_output shape: [None, 28, 28, 144] type: <dtype: 'float32'>
  31. layer_5/output shape: [None, 28, 28, 32] type: <dtype: 'float32'>
  32. layer_6/expansion_output shape: [None, 28, 28, 192] type: <dtype: 'float32'>
  33. layer_6/depthwise_output shape: [None, 28, 28, 192] type: <dtype: 'float32'>
  34. layer_6/output shape: [None, 28, 28, 32] type: <dtype: 'float32'>
  35. layer_7/expansion_output shape: [None, 28, 28, 192] type: <dtype: 'float32'>
  36. layer_7/depthwise_output shape: [None, 28, 28, 192] type: <dtype: 'float32'>
  37. layer_7/output shape: [None, 28, 28, 32] type: <dtype: 'float32'>
  38. layer_8/expansion_output shape: [None, 28, 28, 192] type: <dtype: 'float32'>
  39. layer_8/depthwise_output shape: [None, 14, 14, 192] type: <dtype: 'float32'>
  40. layer_8/output shape: [None, 14, 14, 64] type: <dtype: 'float32'>
  41. layer_9/expansion_output shape: [None, 14, 14, 384] type: <dtype: 'float32'>
  42. layer_9/depthwise_output shape: [None, 14, 14, 384] type: <dtype: 'float32'>
  43. layer_9/output shape: [None, 14, 14, 64] type: <dtype: 'float32'>
  44. layer_10/expansion_output shape: [None, 14, 14, 384] type: <dtype: 'float32'>
  45. layer_10/depthwise_output shape: [None, 14, 14, 384] type: <dtype: 'float32'>
  46. layer_10/output shape: [None, 14, 14, 64] type: <dtype: 'float32'>
  47. layer_11/expansion_output shape: [None, 14, 14, 384] type: <dtype: 'float32'>
  48. layer_11/depthwise_output shape: [None, 14, 14, 384] type: <dtype: 'float32'>
  49. layer_11/output shape: [None, 14, 14, 64] type: <dtype: 'float32'>
  50. layer_12/expansion_output shape: [None, 14, 14, 384] type: <dtype: 'float32'>
  51. layer_12/depthwise_output shape: [None, 14, 14, 384] type: <dtype: 'float32'>
  52. layer_12/output shape: [None, 14, 14, 96] type: <dtype: 'float32'>
  53. layer_13/expansion_output shape: [None, 14, 14, 576] type: <dtype: 'float32'>
  54. layer_13/depthwise_output shape: [None, 14, 14, 576] type: <dtype: 'float32'>
  55. layer_13/output shape: [None, 14, 14, 96] type: <dtype: 'float32'>
  56. layer_14/expansion_output shape: [None, 14, 14, 576] type: <dtype: 'float32'>
  57. layer_14/depthwise_output shape: [None, 14, 14, 576] type: <dtype: 'float32'>
  58. layer_14/output shape: [None, 14, 14, 96] type: <dtype: 'float32'>
  59. layer_15/expansion_output shape: [None, 14, 14, 576] type: <dtype: 'float32'>
  60. layer_15/depthwise_output shape: [None, 7, 7, 576] type: <dtype: 'float32'>
  61. layer_15/output shape: [None, 7, 7, 160] type: <dtype: 'float32'>
  62. layer_16/expansion_output shape: [None, 7, 7, 960] type: <dtype: 'float32'>
  63. layer_16/depthwise_output shape: [None, 7, 7, 960] type: <dtype: 'float32'>
  64. layer_16/output shape: [None, 7, 7, 160] type: <dtype: 'float32'>
  65. layer_17/expansion_output shape: [None, 7, 7, 960] type: <dtype: 'float32'>
  66. layer_17/depthwise_output shape: [None, 7, 7, 960] type: <dtype: 'float32'>
  67. layer_17/output shape: [None, 7, 7, 160] type: <dtype: 'float32'>
  68. layer_18/expansion_output shape: [None, 7, 7, 960] type: <dtype: 'float32'>
  69. layer_18/depthwise_output shape: [None, 7, 7, 960] type: <dtype: 'float32'>
  70. layer_18/output shape: [None, 7, 7, 320] type: <dtype: 'float32'>
  71. AvgPool_1a shape: [None, 1, 1, 1280] type: <dtype: 'float32'>
  72. Logits shape: [None, 1001] type: <dtype: 'float32'>
  73. Predictions shape: [None, 1001] type: <dtype: 'float32'>
  74. logits shape: [None, 1001] type: <dtype: 'float32'>
  75. probs shape: [None, 1001] type: <dtype: 'float32'>
  76. class shape: [None] type: <dtype: 'int32'>
  77. predictions shape: [None] type: <dtype: 'int32'>
  78. original_image shape: [None, None, None, 3] type: <dtype: 'float32'>
  79. original_image_shape shape: [None, 3] type: <dtype: 'int32'>

efficientnet_b0地址: oss://pai-vision-data-sh/pretrained_models/saved_models/efficientnet-b0输出说明

  1. stem shape: [None, 112, 112, 32] type: <dtype: 'float32'>
  2. block_0/expansion_output shape: [None, 112, 112, 32] type: <dtype: 'float32'>
  3. block_0 shape: [None, 112, 112, 16] type: <dtype: 'float32'>
  4. reduction_1/expansion_output shape: [None, 112, 112, 32] type: <dtype: 'float32'>
  5. reduction_1 shape: [None, 112, 112, 16] type: <dtype: 'float32'>
  6. block_1/expansion_output shape: [None, 56, 56, 96] type: <dtype: 'float32'>
  7. block_1 shape: [None, 56, 56, 24] type: <dtype: 'float32'>
  8. block_2/expansion_output shape: [None, 56, 56, 144] type: <dtype: 'float32'>
  9. block_2 shape: [None, 56, 56, 24] type: <dtype: 'float32'>
  10. reduction_2/expansion_output shape: [None, 56, 56, 144] type: <dtype: 'float32'>
  11. reduction_2 shape: [None, 56, 56, 24] type: <dtype: 'float32'>
  12. block_3/expansion_output shape: [None, 28, 28, 144] type: <dtype: 'float32'>
  13. block_3 shape: [None, 28, 28, 40] type: <dtype: 'float32'>
  14. block_4/expansion_output shape: [None, 28, 28, 240] type: <dtype: 'float32'>
  15. block_4 shape: [None, 28, 28, 40] type: <dtype: 'float32'>
  16. reduction_3/expansion_output shape: [None, 28, 28, 240] type: <dtype: 'float32'>
  17. reduction_3 shape: [None, 28, 28, 40] type: <dtype: 'float32'>
  18. block_5/expansion_output shape: [None, 14, 14, 240] type: <dtype: 'float32'>
  19. block_5 shape: [None, 14, 14, 80] type: <dtype: 'float32'>
  20. block_6/expansion_output shape: [None, 14, 14, 480] type: <dtype: 'float32'>
  21. block_6 shape: [None, 14, 14, 80] type: <dtype: 'float32'>
  22. block_7/expansion_output shape: [None, 14, 14, 480] type: <dtype: 'float32'>
  23. block_7 shape: [None, 14, 14, 80] type: <dtype: 'float32'>
  24. block_8/expansion_output shape: [None, 14, 14, 480] type: <dtype: 'float32'>
  25. block_8 shape: [None, 14, 14, 112] type: <dtype: 'float32'>
  26. block_9/expansion_output shape: [None, 14, 14, 672] type: <dtype: 'float32'>
  27. block_9 shape: [None, 14, 14, 112] type: <dtype: 'float32'>
  28. block_10/expansion_output shape: [None, 14, 14, 672] type: <dtype: 'float32'>
  29. block_10 shape: [None, 14, 14, 112] type: <dtype: 'float32'>
  30. reduction_4/expansion_output shape: [None, 14, 14, 672] type: <dtype: 'float32'>
  31. reduction_4 shape: [None, 14, 14, 112] type: <dtype: 'float32'>
  32. block_11/expansion_output shape: [None, 7, 7, 672] type: <dtype: 'float32'>
  33. block_11 shape: [None, 7, 7, 192] type: <dtype: 'float32'>
  34. block_12/expansion_output shape: [None, 7, 7, 1152] type: <dtype: 'float32'>
  35. block_12 shape: [None, 7, 7, 192] type: <dtype: 'float32'>
  36. block_13/expansion_output shape: [None, 7, 7, 1152] type: <dtype: 'float32'>
  37. block_13 shape: [None, 7, 7, 192] type: <dtype: 'float32'>
  38. block_14/expansion_output shape: [None, 7, 7, 1152] type: <dtype: 'float32'>
  39. block_14 shape: [None, 7, 7, 192] type: <dtype: 'float32'>
  40. block_15/expansion_output shape: [None, 7, 7, 1152] type: <dtype: 'float32'>
  41. block_15 shape: [None, 7, 7, 320] type: <dtype: 'float32'>
  42. reduction_5/expansion_output shape: [None, 7, 7, 1152] type: <dtype: 'float32'>
  43. reduction_5 shape: [None, 7, 7, 320] type: <dtype: 'float32'>
  44. features shape: [None, 7, 7, 320] type: <dtype: 'float32'>
  45. head_1x1 shape: [None, 7, 7, 1280] type: <dtype: 'float32'>
  46. pooled_features shape: [None, 1280] type: <dtype: 'float32'>
  47. global_pool shape: [None, 1280] type: <dtype: 'float32'>
  48. class shape: [None] type: <dtype: 'int32'>
  49. head shape: [None, 1000] type: <dtype: 'float32'>
  50. logits shape: [None, 1000] type: <dtype: 'float32'>
  51. probs shape: [None, 1001] type: <dtype: 'float32'>
  52. predictions shape: [None] type: <dtype: 'int32'>