Google Video Intelligence API: - RP C Ошибка: поток удален - PullRequest
0 голосов
/ 22 февраля 2020

Я пытаюсь использовать Video Intelligence API с использованием сценария Python. Я запускаю этот скрипт на виртуальной машине Hyper-V. Ниже приведен скрипт, который я запускаю

def analyze_labels(path):
    os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "C:/Users/User/Documents/video_api.json"
    # [START video_analyze_labels]
    """Detect labels given a file path."""
    video_client = videointelligence.VideoIntelligenceServiceClient()
    features = [videointelligence.enums.Feature.LABEL_DETECTION]

    mode = videointelligence.enums.LabelDetectionMode.SHOT_AND_FRAME_MODE
    config = videointelligence.types.LabelDetectionConfig(
        label_detection_mode=mode)
    context = videointelligence.types.VideoContext(
        label_detection_config=config)

    operation = video_client.annotate_video(
        path, features=features, video_context=context)
    print('\nProcessing video for label annotations:')

    result = operation.result(timeout=180)
    print('\nFinished processing.')

    df1 = []
    # Process shot level label annotations
    shot_labels = result.annotation_results[0].shot_label_annotations
    label_row1 = {}
    for i, shot_label in enumerate(shot_labels):
        print('Shot label description: {}'.format(
            shot_label.entity.description))
        label_row1['Description'] = shot_label.entity.description

        for category_entity in shot_label.category_entities:
            print('\tLabel category description: {}'.format(
                category_entity.description))
        for i, shot in enumerate(shot_label.segments):
            start_time = (shot.segment.start_time_offset.seconds +
                          shot.segment.start_time_offset.nanos / 1e9)
            end_time = (shot.segment.end_time_offset.seconds +
                        shot.segment.end_time_offset.nanos / 1e9)
            positions = '{}s to {}s'.format(start_time, end_time)
            confidence = shot.confidence
            row_segment_info1 = ({'Confidence': shot.confidence, 'Start': start_time, 'End': end_time})
            print(row_segment_info1)
            label_row1.update(row_segment_info1)
            print(label_row1)
            df1.append(label_row1.copy())
            print('\tSegment {}: {}'.format(i, positions))
            print('\tConfidence: {}'.format(confidence))
        print('\n')
    frame_shot = pd.DataFrame(df1)
    frame_shot = frame_shot.sort_values('Start')
    frame_shot = frame_shot[['Start', 'End', 'Description', 'Confidence']]
    return frame_shot

Однако я получаю следующую ошибку

_InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
    status = StatusCode.UNKNOWN
    details = "Stream removed"
    debug_error_string = "{"created":"@1582329910.914000000","description":"Error received from peer ipv4:172.217.25.170:443","file":"src/core/lib/surface/call.cc","file_line":1056,"grpc_message":"Stream removed","grpc_status":2}"

Я проверил документацию Google, и нет описания этой ошибки, которое могло бы помочь решить эту проблему. выпуск.

...