
    Wpf5                         d Z ddlmZ ddlmZ ddlmZ ddlZddlmc m	Z
 ddlmZ  G d de
j        j                  Zed	k    re
j                                         dS dS )
aR  Copyright 2019 The MediaPipe Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Tests for media_sequence.py.
    )absolute_import)division)print_functionN)media_sequencec                   J    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZdS )MediaSequenceTestc                    t           j                                        }t          j        d|           t          j        d|           t          j        ddg|           t          j        d|           t          j        d|           t          j	        d|           t          j
        d|           t          j        d|           t          j        d|           t          j        d|           t          j        d|           t          j        d|           t          j        d|           t          j        d|           t          j        d|           t          j        d|           t          j        d|           t          j        d|           t          j        d|           t          j        d|           t          j        d|           t          j        d|           t          j        d|           t          j        d|           t          j        d|           t          j        d	|           t          j        d|           t          j        d|           t          j         d|           t          j!        d|           t          j"        d|           t          j#        d|           t          j$        d	|           t          j%        d|           t          j&        d|           t          j'        d|           t          j(        d|           t          j)        d|           t          j*        d|           t          j+        d|           t          j,        d|           t          j-        d|           t          j.        d
|           t          j/        d|           t          j0        d|           t          j1        d|           t          j2        d|           t          j3        ddg|           t          j4        d|           t          j5        d|           t          j6        ddg|           t          j7        d|           t          j8        d|           t          j9        d|           t          j:        d|           t          j;        d|           t          j<        d|           t          j=        d|           t          j>        d|           t          j?        d|           t          j@        d|           t          jA        d|           t          jB        d|           t          jC        d|           t          jD        d|           t          jE        d|           t          jF        d|           t          jG        d|           t          jH        d|           t          jI        d|           t          jJ        d|           t          jK        d|           t          jL        d|           t          jM        d|           t          jN        d|           t          jO        d|           t          jP        d|           t          jQ        d|           t          jR        d|           t          jS        d|           t          jT        d|           t          jU        d|           t          jV        d|           t          jW        ddg|           t          jX        d|           t          jY        ddg|           t          jZ        d|           t          j[        d|           t          j\        d|           t          j]        d|           t          j^        d|           t          j_        d|           t          j`        d|           t          ja        d|           t          jb        ddg|           t          jc        d	dg|           t          jd        d|           t          je        d|           t          jf        d	|           t          jg        d|           t          jh        d|           t          ji        d|           d S )N   strings   overal   test/   )r
   r   )r   1   )Gz?\(\?)r   s   stringsr   )s   HEADs   TOE)g     G@g     A@)r   #   )   texts   stingsr   r   r   s   one)jtftrainSequenceExamplemsset_example_idset_example_dataset_nameset_example_dataset_flag_stringset_clip_media_idset_clip_alternative_media_idset_clip_encoded_media_bytes&set_clip_encoded_media_start_timestampset_clip_data_pathset_clip_start_timestampset_clip_end_timestampset_clip_label_stringset_clip_label_indexset_clip_label_confidenceset_segment_start_timestampset_segment_start_indexset_segment_end_timestampset_segment_end_indexset_segment_label_indexset_segment_label_stringset_segment_label_confidenceset_image_formatset_image_channelsset_image_colorspaceset_image_heightset_image_widthset_image_frame_rateset_image_data_pathset_forward_flow_formatset_forward_flow_channelsset_forward_flow_colorspaceset_forward_flow_heightset_forward_flow_widthset_forward_flow_frame_rateset_class_segmentation_formatset_class_segmentation_heightset_class_segmentation_width)set_class_segmentation_class_label_string(set_class_segmentation_class_label_index set_instance_segmentation_format set_instance_segmentation_heightset_instance_segmentation_width,set_instance_segmentation_object_class_indexset_bbox_partsset_context_feature_floatsset_context_feature_bytesset_context_feature_intsadd_image_encodedadd_image_multi_encodedadd_image_timestampadd_forward_flow_encodedadd_forward_flow_multi_encodedadd_forward_flow_timestampadd_bbox_yminadd_bbox_xminadd_bbox_ymaxadd_bbox_xmaxadd_bbox_point_xadd_bbox_point_yadd_bbox_3d_point_xadd_bbox_3d_point_yadd_bbox_3d_point_zadd_predicted_bbox_yminadd_predicted_bbox_xminadd_predicted_bbox_ymaxadd_predicted_bbox_xmaxadd_bbox_num_regionsadd_bbox_is_annotatedadd_bbox_is_generatedadd_bbox_is_occludedadd_bbox_label_indexadd_bbox_label_stringadd_bbox_label_confidenceadd_bbox_class_indexadd_bbox_class_stringadd_bbox_class_confidenceadd_bbox_track_indexadd_bbox_track_stringadd_bbox_track_confidenceadd_bbox_timestampadd_predicted_bbox_class_indexadd_predicted_bbox_class_stringadd_predicted_bbox_timestampadd_class_segmentation_encoded$add_class_segmentation_multi_encoded!add_instance_segmentation_encoded'add_instance_segmentation_multi_encoded add_class_segmentation_timestamp(set_bbox_embedding_dimensions_per_regionset_bbox_embedding_formatadd_bbox_embedding_floatsadd_bbox_embedding_encodedadd_bbox_embedding_confidenceset_text_languageset_text_context_contentset_text_context_token_idset_text_context_embeddingadd_text_contentadd_text_timestampadd_text_confidenceadd_text_durationadd_text_token_idadd_text_embeddingselfexamples     k/var/www/html/nettyfy-visnx/env/lib/python3.11/site-packages/mediapipe/util/sequence/media_sequence_test.py#test_expected_functions_are_definedz5MediaSequenceTest.test_expected_functions_are_defined   s    h&&((Gi)))	7333&	7';WEEEG,,,$Y888#Iw777-b':::)W---G,,,b'***17;;;Hg... w777"8W555x111 7333Xw///x111 5w???#L':::)))"g&&&GW---G$$$r7###D'***7G,,,w000 W---"7G444r7+++b'***"4111$Wg666$R111#B00001FPPP/'BBB'999'G444&r73333HgFFF'111!*g666 !6@@@'222'***17;;;2w'''111%w&8'BBB!"g...\7+++\7+++\7+++\7+++g...g...<111<111<111|W555|W555|W555|W555B(((R)))Xw///Hg...Hg...2G<<< w777Hg...2G<<< w777Hg...2G<<< w777"g&&&%h888&'<gFFF#B000%gw777+Wg,>HHH(':::./A7KKK'G444/'BBB '222 w777!"6@@@$\7;;;'***111 "b7333!4,888((("g&&&4)))W%%%W%%%,00000    c                 Z   t           j                                        }t          j        g dg dg          }t          j        g           }t          j        ||           t          j        ||           |                     dt          j        |                     | 	                    |t          j
        d|                     |                     t          j        |                     t          j        |           |                     dt          j        |                     d S N皙?皙?333333?皙?)      ?333333?ffffff?g?   r   )r   r   r   nparrayr   add_bboxassertEqualget_bbox_sizeassertAllCloseget_bbox_at
assertTruehas_bbox
clear_bbox)r}   r~   boxesempty_boxess       r   test_bbox_round_tripz&MediaSequenceTest.test_bbox_round_trip   s   h&&((GH******, - -E(2,,KKwKW%%%Q(11222r~a99:::OOBK(()))M'Q(1122222r   c                 2   t           j                                        }t          j        ddgddgg          }t          j        ||           t          j        ||           |                     dt          j        |                     | 	                    |t          j
        d|                     |                     t          j        |                     t          j        |           |                     dt          j        |                     d S )Nr   r   r   r   r   r   r   r   r   r   r   r   add_bbox_pointr   get_bbox_point_sizer   get_bbox_point_atr   has_bbox_pointclear_bbox_pointr}   r~   pointss      r   test_point_round_tripz'MediaSequenceTest.test_point_round_trip   s    h&&((GXSzSz# $ $Ffg&&&fg&&&Q.w77888 4Q @ @AAAOOB%g..///   Q.w7788888r   c                 @   t           j                                        }t          j        ddgddgg          }t          j        ||d           t          j        ||d           |                     dt          j        |d                     | 	                    |t          j
        d|d                     |                     t          j        |d                     t          j        |d           |                     dt          j        |d                     d S )Nr   r   r   r   testr   r   r   r   s      r   test_prefixed_point_round_tripz0MediaSequenceTest.test_prefixed_point_round_trip   s   h&&((GXSzSz# $ $Ffgv...fgv...Q.w??@@@ 4Q H HIIIOOB%gv66777(((Q.w??@@@@@r   c                 2   t           j                                        }t          j        g dg dg          }t          j        ||           t          j        ||           |                     dt          j        |                     | 	                    |t          j
        d|                     |                     t          j        |                     t          j        |           |                     dt          j        |                     d S )Nr   r   r   )r   r   r   r   r   )r   r   r   r   r   r   add_bbox_3d_pointr   get_bbox_3d_point_sizer   get_bbox_3d_point_atr   has_bbox_3d_pointclear_bbox_3d_pointr   s      r   test_3d_point_round_tripz*MediaSequenceTest.test_3d_point_round_trip   s    h&&((GX&( ) )F))))))Q1'::;;; 77 C CDDDOOB(112227###Q1'::;;;;;r   c                 2   t           j                                        }t          j        g dg dg          }t          j        ||           t          j        ||           |                     dt          j        |                     | 	                    |t          j
        d|                     |                     t          j        |                     t          j        |           |                     dt          j        |                     d S r   )r   r   r   r   r   r   add_predicted_bboxr   get_predicted_bbox_sizer   get_predicted_bbox_atr   has_predicted_bboxclear_predicted_bbox)r}   r~   r   s      r   test_predicted_bbox_round_tripz0MediaSequenceTest.test_predicted_bbox_round_trip   s    h&&((GH******, - -E%)))%)))Q27;;<<<r77CCDDDOOB)'22333G$$$Q27;;<<<<<r   c                    t           j                                        }g d}g d}t          j        ||d           t          j        ||d           t          j        ||d           |                     dt          j        |d                     |                     dt          j        |d                     |                     t          j        |d                     |                     t          j        |d                     | 	                    |t          j
        d|d                     | 	                    |t          j
        d|d                     t          j        |d           |                     dt          j        |d                     |                     t          j        |d                     |                     dt          j        |d                     |                     t          j        |d                     t          j        |d           |                     dt          j        |d                     |                     t          j        |d                     d S )Nr   )r   r   r   12r      r   )r   r   r   r   add_feature_floatsr   get_feature_floats_sizer   has_feature_floatsr   get_feature_floats_atclear_feature_floatsassertFalser}   r~   values_1values_2s       r   test_float_list_round_tripz,MediaSequenceTest.test_float_list_round_trip   s*   h&&((GHH(GS111(GS111(GS111Q27C@@AAAQ27C@@AAAOOB)'377888OOB)'377888"":1gs"K"KLLL"":1gs"K"KLLLGS)))Q27C@@AAAR*7C88999Q27C@@AAAOOB)'377888GS)))Q27C@@AAAR*7C8899999r   c                    t           j                                        }d}d}t          j        ||d           t          j        ||d           t          j        ||d           |                     dt          j        |d                     |                     dt          j        |d                     |                     t          j        |d                     |                     t          j        |d                     | 	                    |t          j
        d|d                     | 	                    |t          j
        d|d                     t          j        |d           |                     dt          j        |d                     |                     t          j        |d                     |                     dt          j        |d                     |                     t          j        |d                     t          j        |d           |                     dt          j        |d                     |                     t          j        |d                     d S )Nr   r   r   r   r   r   r   )r   r   r   r   add_feature_timestampr   get_feature_timestamp_sizer   has_feature_timestampr   get_feature_timestamp_atclear_feature_timestampr   r   s       r   !test_feature_timestamp_round_tripz3MediaSequenceTest.test_feature_timestamp_round_trip   s6   h&&((GHHXw444Xw444Xw444Q5gsCCDDDQ5gsCCDDDOOB,Wc::;;;OOB,Wc::;;;3AwDDF F F3AwDDF F Fw,,,Q5gsCCDDDR-gs;;<<<Q5gsCCDDDOOB,Wc::;;;w,,,Q5gsCCDDDR-gs;;<<<<<r   c                    t           j                                        }t          j        ddg|d           t          j        ddg|d           |                     ddgt          j        |d                     |                     ddgt          j        |d                     |                     t          j        |d                     |                     t          j        |d                     t          j	        |d           | 
                    t          j        |d                     |                     t          j        |d                     t          j	        |d           | 
                    t          j        |d                     | 
                    t          j        |d                     d S )Nr   r   r   2   r   )r   r   r   r   set_feature_dimensionsassertSequenceEqualget_feature_dimensionsr   has_feature_dimensionsclear_feature_dimensionsr   r|   s     r   "test_feature_dimensions_round_tripz4MediaSequenceTest.test_feature_dimensions_round_trip   s   h&&((Gr2h555r2h555b"X6wDDF F Fb"X6wDDF F FOOB-gs;;<<<OOB-gs;;<<<---R.w<<===OOB-gs;;<<<---R.w<<===R.w<<=====r   c                 B   t           j                                        }d}t          j        g d          }t          j        g d          }|                     t          j        |                     |                     t          j        |                     |                     t          j	        |                     t          j
        ||           t          j        ||           t          j        ||           |                     |t          j        |                     |                     |t          j        |                     |                     |t          j        |                     |                     t          j        |                     |                     t          j        |                     |                     t          j	        |                     t          j        |           t          j        |           t          j        |           |                     t          j        |                     |                     t          j        |                     |                     t          j	        |                     d S )Ns   text content)r   r         r   )r   r   r   r   r   r   r   has_text_context_embeddinghas_text_context_token_idhas_text_context_contentrs   rt   ru   r   get_text_context_contentr   get_text_context_token_idget_text_context_embeddingr   clear_text_context_contentclear_text_context_token_idclear_text_context_embedding)r}   r~   text_contenttext_token_idstext_embeddingss        r   test_text_context_round_tripz.MediaSequenceTest.test_text_context_round_trip	  s)   h&&((G"LXlll++Nh33344OR27;;<<<R1'::;;;R099:::g666 999!/7;;;\2#>w#G#GHHH(DW(M(MNNN)Fw)O)OPPPOOB1'::;;;OOB099:::OOB/88999!'***"7+++#G,,,R27;;<<<R1'::;;;R099:::::r   N)__name__
__module____qualname__r   r   r   r   r   r   r   r   r   r    r   r   r   r      s        n1 n1 n1`3 3 3
9 
9 
9
A 
A 
A
< 
< 
<
= 
= 
=: : :,= = =0> > >"; ; ; ; ;r   r   __main__)__doc__
__future__r   r   r   numpyr   tensorflow.compat.v1compatv1r   mediapipe.util.sequencer   r   r   TestCaser   r   mainr   r   r   <module>r      s    " ' & & & & &       % % % % % %     ! ! ! ! ! ! ! ! ! 8 8 8 8 8 8D; D; D; D; D;( D; D; D;L z',,..... r   