@@ -102,7 +102,10 @@ internal static Operation[] _CheckAtLeast3DImage(Tensor image, bool require_stat
102102 {
103103 throw new ValueError ( "\' image\' must be fully defined." ) ;
104104 }
105- var dims = image_shape [ "-3:" ] ;
105+ var dims = new Shape ( new [ ] {
106+ image_shape . dims [ image_shape . dims . Length - 3 ] ,
107+ image_shape . dims [ image_shape . dims . Length - 2 ] ,
108+ image_shape . dims [ image_shape . dims . Length - 1 ] } ) ;
106109 foreach ( var dim in dims . dims )
107110 {
108111 if ( dim == 0 )
@@ -112,16 +115,18 @@ internal static Operation[] _CheckAtLeast3DImage(Tensor image, bool require_stat
112115 }
113116
114117 var image_shape_last_three_elements = new Shape ( new [ ] {
115- image_shape . dims [ image_shape . dims . Length - 1 ] ,
118+ image_shape . dims [ image_shape . dims . Length - 3 ] ,
116119 image_shape . dims [ image_shape . dims . Length - 2 ] ,
117- image_shape . dims [ image_shape . dims . Length - 3 ] } ) ;
120+ image_shape . dims [ image_shape . dims . Length - 1 ] } ) ;
118121 if ( ! image_shape_last_three_elements . IsFullyDefined )
119122 {
120123 Tensor image_shape_ = array_ops . shape ( image ) ;
121- var image_shape_return = tf . constant ( new [ ] {
122- image_shape_ . dims [ image_shape . dims . Length - 1 ] ,
123- image_shape_ . dims [ image_shape . dims . Length - 2 ] ,
124- image_shape_ . dims [ image_shape . dims . Length - 3 ] } ) ;
124+ var image_shape_return = tf . slice ( image_shape_ , new [ ] { Math . Max ( image_shape . dims . Length - 3 , 0 ) } , new [ ] { 3 } ) ;
125+
126+ //var image_shape_return = tf.constant(new[] {
127+ // image_shape_.dims[image_shape_.dims.Length - 3],
128+ // image_shape_.dims[image_shape_.dims.Length - 2],
129+ // image_shape_.dims[image_shape_.dims.Length - 1]});
125130
126131 return new Operation [ ] {
127132 check_ops . assert_positive (
@@ -209,10 +214,10 @@ internal static Tensor _random_flip(Tensor image, int flip_index, int seed, stri
209214 }
210215
211216 public static Tensor flip_left_right ( Tensor image )
212- => _flip ( image , 0 , "flip_left_right" ) ;
217+ => _flip ( image , 1 , "flip_left_right" ) ;
213218
214219 public static Tensor flip_up_down ( Tensor image )
215- => _flip ( image , 1 , "flip_up_down" ) ;
220+ => _flip ( image , 0 , "flip_up_down" ) ;
216221
217222 internal static Tensor _flip ( Tensor image , int flip_index , string scope_name )
218223 {
@@ -223,11 +228,11 @@ internal static Tensor _flip(Tensor image, int flip_index, string scope_name)
223228 Shape shape = image . shape ;
224229 if ( shape . ndim == 3 || shape . ndim == Unknown )
225230 {
226- return fix_image_flip_shape ( image , gen_array_ops . reverse ( image , ops . convert_to_tensor ( new int [ ] { flip_index } ) ) ) ;
231+ return fix_image_flip_shape ( image , gen_array_ops . reverse_v2 ( image , ops . convert_to_tensor ( new int [ ] { flip_index } ) ) ) ;
227232 }
228233 else if ( shape . ndim == 4 )
229234 {
230- return gen_array_ops . reverse_v2 ( image , ops . convert_to_tensor ( new [ ] { ( flip_index + 1 ) % 2 } ) ) ;
235+ return gen_array_ops . reverse_v2 ( image , ops . convert_to_tensor ( new [ ] { flip_index + 1 } ) ) ;
231236 }
232237 else
233238 {
@@ -2047,6 +2052,22 @@ internal static (Tensor, Tensor) non_max_suppression_padded_v1(Tensor boxes, Ten
20472052 } ) ;
20482053 }
20492054
2055+ public static Tensor encode_jpeg ( Tensor contents , string name = null )
2056+ {
2057+ return tf_with ( ops . name_scope ( name , "encode_jpeg" ) , scope =>
2058+ {
2059+ return gen_ops . encode_jpeg ( contents , name : name ) ;
2060+ } ) ;
2061+ }
2062+
2063+ public static Tensor encode_png ( Tensor contents , string name = null )
2064+ {
2065+ return tf_with ( ops . name_scope ( name , "encode_png" ) , scope =>
2066+ {
2067+ return gen_ops . encode_png ( contents , name : name ) ;
2068+ } ) ;
2069+ }
2070+
20502071 public static Tensor is_jpeg ( Tensor contents , string name = null )
20512072 {
20522073 return tf_with ( ops . name_scope ( name , "is_jpeg" ) , scope =>
0 commit comments