17
17
using static TorchSharp . torch . optim . lr_scheduler ;
18
18
using Microsoft . ML . TorchSharp . Utils ;
19
19
using Microsoft . ML ;
20
- using Microsoft . ML . TorchSharp . NasBert ;
21
20
using System . IO ;
22
21
using Microsoft . ML . Data . IO ;
23
22
using Microsoft . ML . TorchSharp . Loss ;
24
23
using Microsoft . ML . Transforms . Image ;
25
24
using static Microsoft . ML . TorchSharp . AutoFormerV2 . ObjectDetectionTrainer ;
26
25
using Microsoft . ML . TorchSharp . AutoFormerV2 ;
27
- using Microsoft . ML . Tokenizers ;
28
- using Microsoft . ML . TorchSharp . Extensions ;
29
- using Microsoft . ML . TorchSharp . NasBert . Models ;
30
- using static Microsoft . ML . TorchSharp . NasBert . NasBertTrainer ;
31
- using TorchSharp . Modules ;
32
- using System . Text ;
33
26
using static Microsoft . ML . Data . AnnotationUtils ;
34
27
35
28
[ assembly: LoadableClass ( typeof ( ObjectDetectionTransformer ) , null , typeof ( SignatureLoadModel ) ,
@@ -503,7 +496,7 @@ private void CheckInputSchema(SchemaShape inputSchema)
503
496
}
504
497
}
505
498
506
- public class ObjectDetectionTransformer : RowToRowTransformerBase
499
+ public class ObjectDetectionTransformer : RowToRowTransformerBase , IDisposable
507
500
{
508
501
private protected readonly Device Device ;
509
502
private protected readonly AutoFormerV2 Model ;
@@ -522,6 +515,7 @@ public class ObjectDetectionTransformer : RowToRowTransformerBase
522
515
523
516
private static readonly FuncStaticMethodInfo1 < object , Delegate > _decodeInitMethodInfo
524
517
= new FuncStaticMethodInfo1 < object , Delegate > ( DecodeInit < int > ) ;
518
+ private bool _disposedValue ;
525
519
526
520
internal ObjectDetectionTransformer ( IHostEnvironment env , ObjectDetectionTrainer . Options options , AutoFormerV2 model , DataViewSchema . DetachedColumn labelColumn )
527
521
: base ( Contracts . CheckRef ( env , nameof ( env ) ) . Register ( nameof ( ObjectDetectionTransformer ) ) )
@@ -992,5 +986,31 @@ private protected override Func<int, bool> GetDependenciesCore(Func<int, bool> a
992
986
return col => ( activeOutput ( 0 ) || activeOutput ( 1 ) || activeOutput ( 2 ) ) && _inputColIndices . Any ( i => i == col ) ;
993
987
}
994
988
}
989
+
990
+ protected virtual void Dispose ( bool disposing )
991
+ {
992
+ if ( ! _disposedValue )
993
+ {
994
+ if ( disposing )
995
+ {
996
+ }
997
+
998
+ Model . Dispose ( ) ;
999
+ _disposedValue = true ;
1000
+ }
1001
+ }
1002
+
1003
+ ~ ObjectDetectionTransformer ( )
1004
+ {
1005
+ // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
1006
+ Dispose ( disposing : false ) ;
1007
+ }
1008
+
1009
+ public void Dispose ( )
1010
+ {
1011
+ // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
1012
+ Dispose ( disposing : true ) ;
1013
+ GC . SuppressFinalize ( this ) ;
1014
+ }
995
1015
}
996
1016
}
0 commit comments