@@ -374,17 +374,32 @@ public void TensorFlowTransformObjectDetectionTest()
374
374
[ Fact ( Skip = "Model files are not available yet" ) ]
375
375
public void TensorFlowTransformInceptionTest ( )
376
376
{
377
- var modelLocation = @"C:\models\TensorFlow\tensorflow_inception_graph.pb" ;
377
+ string inputName = "input" ;
378
+ string outputName = "softmax2_pre_activation" ;
379
+ var modelLocation = @"inception5h\tensorflow_inception_graph.pb" ;
378
380
var mlContext = new MLContext ( seed : 1 ) ;
379
381
var dataFile = GetDataPath ( "images/images.tsv" ) ;
380
382
var imageFolder = Path . GetDirectoryName ( dataFile ) ;
381
- var data = mlContext . CreateLoader ( "Text{col=ImagePath:TX:0 col=Name:TX:1}" , new MultiFileSource ( dataFile ) ) ;
383
+ var reader = mlContext . Data . CreateTextLoader (
384
+ columns : new [ ]
385
+ {
386
+ new TextLoader . Column ( "ImagePath" , DataKind . String , 0 ) ,
387
+ new TextLoader . Column ( "Name" , DataKind . String , 1 )
388
+
389
+ } ,
390
+ hasHeader : false ,
391
+ allowSparse : false
392
+ ) ;
393
+
394
+ var data = reader . Load ( new MultiFileSource ( dataFile ) ) ;
382
395
var images = mlContext . Transforms . LoadImages ( imageFolder , ( "ImageReal" , "ImagePath" ) ) . Fit ( data ) . Transform ( data ) ;
383
396
var cropped = mlContext . Transforms . ResizeImages ( "ImageCropped" , 224 , 224 , "ImageReal" ) . Fit ( images ) . Transform ( images ) ;
384
- var pixels = mlContext . Transforms . ExtractPixels ( "input" , "ImageCropped" ) . Fit ( cropped ) . Transform ( cropped ) ;
385
- var tf = mlContext . Model . LoadTensorFlowModel ( modelLocation ) . ScoreTensorFlowModel ( "softmax2_pre_activation" , "input" ) . Fit ( pixels ) . Transform ( pixels ) ;
397
+ var pixels = mlContext . Transforms . ExtractPixels ( inputName , "ImageCropped" ) . Fit ( cropped ) . Transform ( cropped ) ;
398
+ var tf = mlContext . Model . LoadTensorFlowModel ( modelLocation ) . ScoreTensorFlowModel ( outputName , inputName ) . Fit ( pixels ) . Transform ( pixels ) ;
386
399
387
- using ( var curs = tf . GetRowCursor ( tf . Schema [ "input" ] , tf . Schema [ "softmax2_pre_activation" ] ) )
400
+ tf . Schema . TryGetColumnIndex ( inputName , out int input ) ;
401
+ tf . Schema . TryGetColumnIndex ( outputName , out int b ) ;
402
+ using ( var curs = tf . GetRowCursor ( tf . Schema [ inputName ] , tf . Schema [ outputName ] ) )
388
403
{
389
404
var get = curs . GetGetter < VBuffer < float > > ( tf . Schema [ "softmax2_pre_activation" ] ) ;
390
405
var getInput = curs . GetGetter < VBuffer < float > > ( tf . Schema [ "input" ] ) ;
0 commit comments