MetadataExtractor

공개 클래스 MetadataExtractor

TFLite Model FlatBuffer에서 메타데이터를 로드합니다.

TFLite 모델 FlatBuffer는 TFLite 모델 스키마 파일을 사용하여 생성할 수 있습니다.

일부 모델에는 모델의 기능과 모델 해석 방법에 대한 자세한 정보를 기록하는 TFLite 메타데이터 Flatbuffer가 포함되어 있습니다. TFLite 메타데이터 플랫 버퍼는 TFLite 메타데이터 스키마 파일을 사용하여 생성할 수 있습니다.

TFLite 메타데이터 없이 모델 FlatBuffer를 전달할 수 있습니다. 그러나 TFLite 메타데이터에서 읽는 메서드를 호출하면 런타임 오류가 발생합니다.

마찬가지로, 연결된 파일 없이 모델 FlatBuffer를 전달할 수 있습니다. 그러나 관련 파일을 읽는 메서드를 호출하면 런타임 오류가 발생합니다.

TFLite 모델 FlatBuffer는 여러 하위 그래프를 지원하지만 TFLite 인터프리터는 지금까지 단일 하위 그래프만 지원합니다. 자세한 내용은 변환 중에 하위 그래프를 지정하는 방법을 참고하세요. 따라서 MetadataExtractor는 메서드의 입력으로 하위 그래프 색인을 생략합니다.

중첩된 클래스

클래스 MetadataExtractor.QuantizationParams TFLite 모델 스키마 파일 의 테이블 QuantizationParameters에 해당하는 양자화 매개변수입니다.

공개 생성자

MetadataExtractor(ByteBuffer 버퍼)
TFLite 모델 FlatBuffer를 사용하여 MetadataExtractor를 만듭니다.

공개 메서드

InputStream
getAssociatedFile(String fileName)
지정된 fileName로 압축된 관련 파일을 가져옵니다.
Set<String>
getAssociatedFileNames()를
연결된 파일의 이름을 가져옵니다.
int
getInputTensorCount()
모델의 입력 텐서 수를 가져옵니다.
TensorMetadata
getInputTensorMetadata(int inputIndex)
inputIndex로 지정된 입력 텐서의 메타데이터를 가져옵니다.
MetadataExtractor.QuantizationParams
getInputTensorQuantizationParams(int inputIndex)
inputIndex로 지정된 입력 텐서의 양자화 매개변수를 가져옵니다.
int[]
getInputTensorShape(int inputIndex)
inputIndex를 사용하여 입력 텐서의 형태를 가져옵니다.
byte
getInputTensorType(int inputIndex)
inputIndex를 사용하여 입력 텐서의 ERROR(/TensorType)를 가져옵니다.
ModelMetadata
getModelMetadata()
모델 메타데이터의 루트 핸들러를 가져옵니다.
int
getOutputTensorCount()
모델의 출력 텐서 수를 가져옵니다.
TensorMetadata
getOutputTensorMetadata(int outputIndex)
outputIndex로 지정된 출력 텐서의 메타데이터를 가져옵니다.
MetadataExtractor.QuantizationParams
getOutputTensorQuantizationParams(int outputIndex)
outputIndex로 지정된 출력 텐서의 양자화 매개변수를 가져옵니다.
int[]
getOutputTensorShape(int outputIndex)
outputIndex를 사용하여 출력 텐서의 형태를 가져옵니다.
byte
getOutputTensorType(int outputIndex)
outputIndex를 사용하여 출력 텐서의 ERROR(/TensorType)를 가져옵니다.
boolean
hasMetadata()
모델에 메타데이터가 있으면 true를 반환합니다.
최종 불리언
isMinimumParserVersionSatisfied()가
지정된 메타데이터 flatbuffer에 필요한 최소 파서 버전이 이 MetadataExtractor 라이브러리가 사용하는 메타데이터 파서 버전보다 이전이거나 동일하면 true를 반환합니다.

상속된 메서드

공개 생성자

공개 MetadataExtractor (ByteBuffer 버퍼)

TFLite 모델 FlatBuffer를 사용하여 MetadataExtractor를 만듭니다.

매개변수
buffer TFLite 모델인 FlatBuffer
생성 값
IllegalArgumentException 모델의 입력 또는 출력 텐서 수가 메타데이터의 수와 일치하지 않는 경우
IOException 모델을 ZIP 파일로 읽는 동안 오류가 발생하는 경우

공개 메서드

public InputStream getAssociatedFile (String fileName)

지정된 fileName로 압축된 관련 파일을 가져옵니다.

매개변수
fileName 관련 파일의 이름
반환 값
  • 지정된 파일을 포함하는 원시 입력 스트림
생성 값
IllegalStateException 모델이 ZIP 파일이 아닌 경우
IllegalArgumentException 지정된 파일이 모델에 없는 경우

public Set<String> getAssociatedFileNames ()

연결된 파일의 이름을 가져옵니다.

반환 값
  • 관련 파일의 파일 이름
생성 값
IllegalStateException 모델이 ZIP 파일이 아닌 경우

public int getInputTensorCount ()

모델의 입력 텐서 수를 가져옵니다.

public TensorMetadata getInputTensorMetadata (int inputIndex)

inputIndex로 지정된 입력 텐서의 메타데이터를 가져옵니다.

매개변수
inputIndex 원하는 입력 텐서의 색인
생성 값
IllegalStateException 이 모델에 모델 메타데이터가 포함되지 않은 경우

public MetadataExtractor.QuantizationParams getInputTensorQuantizationParams (int inputIndex)

inputIndex로 지정된 입력 텐서의 양자화 매개변수를 가져옵니다.

매개변수
inputIndex 원하는 입력 텐서의 색인

public int[] getInputTensorShape (int inputIndex)

inputIndex를 사용하여 입력 텐서의 형태를 가져옵니다.

매개변수
inputIndex 원하는 입력 텐서의 색인

public byte getInputTensorType (int inputIndex)

inputIndex를 사용하여 입력 텐서의 ERROR(/TensorType)를 가져옵니다.

매개변수
inputIndex 원하는 입력 텐서의 색인

공개 ModelMetadata getModelMetadata ()

모델 메타데이터의 루트 핸들러를 가져옵니다.

생성 값
IllegalStateException 이 모델에 모델 메타데이터가 포함되지 않은 경우

public int getOutputTensorCount ()

모델의 출력 텐서 수를 가져옵니다.

public TensorMetadata getOutputTensorMetadata (int outputIndex)

outputIndex로 지정된 출력 텐서의 메타데이터를 가져옵니다.

매개변수
outputIndex 원하는 출력 텐서의 색인
생성 값
IllegalStateException 이 모델에 모델 메타데이터가 포함되지 않은 경우

public MetadataExtractor.QuantizationParams getOutputTensorQuantizationParams (int outputIndex)

outputIndex로 지정된 출력 텐서의 양자화 매개변수를 가져옵니다.

매개변수
outputIndex 원하는 출력 텐서의 색인

public int[] getOutputTensorShape (int outputIndex)

outputIndex를 사용하여 출력 텐서의 형태를 가져옵니다.

매개변수
outputIndex 원하는 출력 텐서의 색인

public byte getOutputTensorType (int outputIndex)

outputIndex를 사용하여 출력 텐서의 ERROR(/TensorType)를 가져옵니다.

매개변수
outputIndex 원하는 출력 텐서의 색인

public 부울 hasMetadata ()

모델에 메타데이터가 있으면 true를 반환합니다. 그렇지 않으면 false을 반환합니다.

public 최종 부울 isMinimumParserVersionSatisfied ()

지정된 메타데이터 flatbuffer에 필요한 최소 파서 버전이 이 MetadataExtractor 라이브러리가 사용하는 메타데이터 파서 버전보다 이전이거나 동일하면 true를 반환합니다. 이 경우 메타데이터의 모든 필드는 메타데이터 추출기 라이브러리를 사용하여 올바르게 파싱할 수 있습니다. 그렇지 않으면 false을 반환합니다.

예를 들어 기본 메타데이터 파서 버전이 1.14.1이라고 가정해 보겠습니다.

  • 필요한 최소 파서 버전이 동일하거나 이전 버전(예: 1.14.1 또는 1.14.0)이면 true를 반환합니다. 일부 메타데이터 플랫버퍼는 첫 번째 버전이 지정된 출시 전에 생성되므로 모든 숫자 버전보다 null 버전이 우선합니다.
  • 필요한 최소 파서 버전이 최신 버전(예: 1.14.2)이면 false를 반환합니다.