code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def _update_audio_metadata(row: pd.Series, audio_client: Any, trace_info: Dict) -> Dict: """ Modifies the metadata of a row if the conditions for table extraction are met. Parameters ---------- row : pd.Series A row from the DataFrame containing metadata for the audio extraction. audio...
Modifies the metadata of a row if the conditions for table extraction are met. Parameters ---------- row : pd.Series A row from the DataFrame containing metadata for the audio extraction. audio_client : Any The client used to call the audio inference model. trace_info : Dict ...
_update_audio_metadata
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/audio/audio_extraction.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/audio/audio_extraction.py
Apache-2.0
def extract_text_from_audio_internal( df_extraction_ledger: pd.DataFrame, task_config: Dict[str, Any], extraction_config: AudioExtractorSchema, execution_trace_log: Optional[Dict] = None, ) -> Tuple[pd.DataFrame, Dict]: """ Extracts audio data from a DataFrame. Parameters ---------- ...
Extracts audio data from a DataFrame. Parameters ---------- df_extraction_ledger : pd.DataFrame DataFrame containing the content from which audio data is to be extracted. task_config : Dict[str, Any] Dictionary containing task properties and configurations. extraction_config ...
extract_text_from_audio_internal
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/audio/audio_extraction.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/audio/audio_extraction.py
Apache-2.0
def _prepare_task_props( task_config: Union[Dict[str, Any], BaseModel], base64_row: pd.Series ) -> (Dict[str, Any], Optional[str]): """ Prepares the task properties by converting a Pydantic model to a dictionary (if needed) and injecting row-specific data. Parameters ---------- task_config ...
Prepares the task properties by converting a Pydantic model to a dictionary (if needed) and injecting row-specific data. Parameters ---------- task_config : Union[Dict[str, Any], BaseModel] A dictionary or Pydantic model containing instructions and parameters for extraction. base64_row...
_prepare_task_props
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/docx/docx_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/docx/docx_extractor.py
Apache-2.0
def _decode_and_extract_from_docx( base64_row: pd.Series, task_config: Union[Dict[str, Any], BaseModel], extraction_config: Any, execution_trace_log: Optional[Dict[str, Any]] = None, ) -> Any: """ Decodes base64 content from a DataFrame row and extracts data using the specified extraction method...
Decodes base64 content from a DataFrame row and extracts data using the specified extraction method. The function decodes the base64-encoded content from the "content" key in the row, prepares extraction parameters (including additional row data and configuration), and invokes the extraction function ...
_decode_and_extract_from_docx
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/docx/docx_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/docx/docx_extractor.py
Apache-2.0
def extract_primitives_from_docx_internal( df_extraction_ledger: pd.DataFrame, task_config: Union[Dict[str, Any], BaseModel], extraction_config: DocxExtractorSchema, execution_trace_log: Optional[Dict[str, Any]] = None, ) -> pd.DataFrame: """ Processes a pandas DataFrame containing DOCX files en...
Processes a pandas DataFrame containing DOCX files encoded in base64, extracting text from each document and replacing the original content with the extracted text. This function applies a decoding and extraction routine to each row of the input DataFrame. The routine is provided via the `decode_and_e...
extract_primitives_from_docx_internal
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/docx/docx_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/docx/docx_extractor.py
Apache-2.0
def __init__(self, document: Document, source_metadata: Dict): """ Copy over some of the docx core properties """ self.document = document self.source_metadata = source_metadata # Extract core properties with None checks core_properties = self.document.core_prope...
Copy over some of the docx core properties
__init__
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
Apache-2.0
def _update_source_meta_data(self): """ Update the source metadata with the document's core properties """ # Only update metadata if dates are available metadata_updates = {} if self.created is not None: metadata_updates["date_created"] = self.created.isoform...
Update the source metadata with the document's core properties
_update_source_meta_data
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
Apache-2.0
def format_text(self, text: str, bold: bool, italic: bool, underline: bool) -> str: """ Apply markdown styling (bold, italic, underline) to the given text. Parameters ---------- text : str The text to format. bold : bool Whether to apply bold styl...
Apply markdown styling (bold, italic, underline) to the given text. Parameters ---------- text : str The text to format. bold : bool Whether to apply bold styling. italic : bool Whether to apply italic styling. underline : boo...
format_text
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
Apache-2.0
def format_paragraph(self, paragraph: "Paragraph") -> Tuple[str, List["Image"]]: """ Format a paragraph into styled text and extract associated images. Parameters ---------- paragraph : Paragraph The paragraph to format. This includes text and potentially embedded im...
Format a paragraph into styled text and extract associated images. Parameters ---------- paragraph : Paragraph The paragraph to format. This includes text and potentially embedded images. Returns ------- tuple of (str, list of Image) - T...
format_paragraph
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
Apache-2.0
def format_cell(self, cell: "_Cell") -> Tuple[str, List["Image"]]: """ Format a table cell into Markdown text and extract associated images. Parameters ---------- cell : _Cell The table cell to format. Returns ------- tuple of (str, list of I...
Format a table cell into Markdown text and extract associated images. Parameters ---------- cell : _Cell The table cell to format. Returns ------- tuple of (str, list of Image) - The formatted text of the cell with markdown styling appli...
format_cell
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
Apache-2.0
def format_table(self, table: "Table") -> Tuple[Optional[str], List["Image"], DataFrame]: """ Format a table into text, extract images, and represent it as a DataFrame. Parameters ---------- table : Table The table to format. Returns ------- ...
Format a table into text, extract images, and represent it as a DataFrame. Parameters ---------- table : Table The table to format. Returns ------- tuple of (str or None, list of Image, DataFrame) - The formatted table as text, using the...
format_table
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
Apache-2.0
def apply_text_style(style: str, text: str, level: int = 0) -> str: """ Apply a specific text style (e.g., heading, list, title, subtitle) to the given text. Parameters ---------- style : str The style to apply. Supported styles include headings ("Heading 1" to "Head...
Apply a specific text style (e.g., heading, list, title, subtitle) to the given text. Parameters ---------- style : str The style to apply. Supported styles include headings ("Heading 1" to "Heading 9"), list items ("List"), and document structures ("Title", "Su...
apply_text_style
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
Apache-2.0
def _construct_image_metadata( self, para_idx: int, caption: str, base_unified_metadata: Dict, base64_img: str ) -> List[Union[str, dict]]: """ Build metadata for an image in a DOCX file. Parameters ---------- para_idx : int The paragraph index containing...
Build metadata for an image in a DOCX file. Parameters ---------- para_idx : int The paragraph index containing the image. caption : str The caption associated with the image. base_unified_metadata : dict The base metadata to build up...
_construct_image_metadata
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
Apache-2.0
def _extract_para_images( self, images: List["Image"], para_idx: int, caption: str, base_unified_metadata: Dict ) -> None: """ Collect images from a paragraph and store them for metadata construction. Parameters ---------- images : list of Image The image...
Collect images from a paragraph and store them for metadata construction. Parameters ---------- images : list of Image The images found in the paragraph. para_idx : int The index of the paragraph containing the images. caption : str T...
_extract_para_images
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
Apache-2.0
def _construct_text_metadata( self, accumulated_text: List[str], para_idx: int, text_depth: "TextTypeEnum", base_unified_metadata: Dict ) -> List[Union[str, dict]]: """ Build metadata for text content in a DOCX file. Parameters ---------- accumulated_text : list of s...
Build metadata for text content in a DOCX file. Parameters ---------- accumulated_text : list of str The accumulated text to include in the metadata. para_idx : int The paragraph index containing the text. text_depth : TextTypeEnum Th...
_construct_text_metadata
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
Apache-2.0
def _extract_para_text( self, paragraph, paragraph_text, base_unified_metadata: Dict, text_depth: str, para_idx: int, ) -> None: """ Process the text, images, and styles in a DOCX paragraph. Parameters ---------- paragraph: Par...
Process the text, images, and styles in a DOCX paragraph. Parameters ---------- paragraph: Paragraph The paragraph to process. paragraph_text: str The text content of the paragraph. base_unified_metadata : dict The base metadata to as...
_extract_para_text
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
Apache-2.0
def _finalize_images(self, extract_tables: bool, extract_charts: bool, **kwargs) -> None: """ Build and append final metadata for each pending image in batches. Parameters ---------- extract_tables : bool Whether to attempt table detection in images. extract_...
Build and append final metadata for each pending image in batches. Parameters ---------- extract_tables : bool Whether to attempt table detection in images. extract_charts : bool Whether to attempt chart detection in images. **kwargs ...
_finalize_images
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
Apache-2.0
def _extract_table_data( self, child, base_unified_metadata: Dict, ) -> None: """ Process the text and images in a DOCX table. Parameters ---------- child : element The table element to process. base_unified_metadata : dict ...
Process the text and images in a DOCX table. Parameters ---------- child : element The table element to process. base_unified_metadata : dict The base metadata to associate with extracted data. text_depth : TextTypeEnum The depth of t...
_extract_table_data
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docxreader.py
Apache-2.0
def python_docx( *, docx_stream: IO, extract_text: bool, extract_images: bool, extract_infographics: bool, extract_tables: bool, extract_charts: bool, extraction_config: dict, execution_trace_log: Optional[List] = None, ): """ Helper function that use python-docx to extract t...
Helper function that use python-docx to extract text from a bytestream document A document has three levels - document, paragraphs and runs. To align with the pdf extraction paragraphs are aliased as block. python-docx leaves the page number and line number to the renderer so we assume that the entire...
python_docx
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docx_helper.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/docx/engines/docxreader_helpers/docx_helper.py
Apache-2.0
def _filter_valid_chart_images( base64_images: List[str], ) -> Tuple[List[str], List[np.ndarray], List[int], List[Tuple[str, Optional[Dict]]]]: """ Filter base64-encoded images based on minimum dimensions for chart extraction. Returns: - valid_images: Base64 strings meeting size requirements. ...
Filter base64-encoded images based on minimum dimensions for chart extraction. Returns: - valid_images: Base64 strings meeting size requirements. - valid_arrays: Corresponding numpy arrays. - valid_indices: Original indices of valid images. - results: Initial results list where invalid...
_filter_valid_chart_images
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/image/chart_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/image/chart_extractor.py
Apache-2.0
def _run_chart_inference( yolox_client: Any, paddle_client: Any, valid_arrays: List[np.ndarray], valid_images: List[str], trace_info: Dict, ) -> Tuple[List[Any], List[Any]]: """ Run concurrent inference for chart extraction using YOLOX and Paddle. Returns a tuple of (yolox_results, padd...
Run concurrent inference for chart extraction using YOLOX and Paddle. Returns a tuple of (yolox_results, paddle_results).
_run_chart_inference
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/image/chart_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/image/chart_extractor.py
Apache-2.0
def _validate_chart_inference_results( yolox_results: Any, paddle_results: Any, valid_arrays: List[Any], valid_images: List[str] ) -> Tuple[List[Any], List[Any]]: """ Ensure inference results are lists and have expected lengths. Raises: ValueError if results do not match expected types or lengths...
Ensure inference results are lists and have expected lengths. Raises: ValueError if results do not match expected types or lengths.
_validate_chart_inference_results
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/image/chart_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/image/chart_extractor.py
Apache-2.0
def _merge_chart_results( base64_images: List[str], valid_indices: List[int], yolox_results: List[Any], paddle_results: List[Any], initial_results: List[Tuple[str, Optional[Dict]]], ) -> List[Tuple[str, Optional[Dict]]]: """ Merge inference results into the initial results list using the ori...
Merge inference results into the initial results list using the original indices. For each valid image, processes the results from both inference calls and updates the corresponding entry in the results list.
_merge_chart_results
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/image/chart_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/image/chart_extractor.py
Apache-2.0
def _update_chart_metadata( base64_images: List[str], yolox_client: Any, paddle_client: Any, trace_info: Dict, worker_pool_size: int = 8, # Not currently used. ) -> List[Tuple[str, Optional[Dict]]]: """ Given a list of base64-encoded chart images, concurrently call both YOLOX and Paddle ...
Given a list of base64-encoded chart images, concurrently call both YOLOX and Paddle inference services to extract chart data. For each base64-encoded image, returns: (original_image_str, joined_chart_content_dict) Images that do not meet minimum size requirements are marked as skipped.
_update_chart_metadata
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/image/chart_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/image/chart_extractor.py
Apache-2.0
def _decode_and_extract_from_image( base64_row: pd.Series, task_config: Dict[str, Any], validated_extraction_config: ImageExtractorSchema, execution_trace_log: Optional[List[Any]] = None, ) -> Any: """ Decode base64-encoded image content from a DataFrame row and extract data using a specified ex...
Decode base64-encoded image content from a DataFrame row and extract data using a specified extraction method. This function extracts the "content" (base64 string) from the row, prepares additional task parameters by inserting the remaining row data under "row_data", and decodes the base64 content into a ...
_decode_and_extract_from_image
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/image/image_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/image/image_extractor.py
Apache-2.0
def _filter_infographic_images( base64_images: List[str], ) -> Tuple[List[str], List[int], List[Tuple[str, Optional[Any], Optional[Any]]]]: """ Filters base64-encoded images based on minimum size requirements. Parameters ---------- base64_images : List[str] List of base64-encoded image ...
Filters base64-encoded images based on minimum size requirements. Parameters ---------- base64_images : List[str] List of base64-encoded image strings. Returns ------- Tuple[List[str], List[int], List[Tuple[str, Optional[Any], Optional[Any]]]] - valid_images: List of image...
_filter_infographic_images
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/image/infographic_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/image/infographic_extractor.py
Apache-2.0
def _update_infographic_metadata( base64_images: List[str], paddle_client: NimClient, worker_pool_size: int = 8, # Not currently used trace_info: Optional[Dict] = None, ) -> List[Tuple[str, Optional[Any], Optional[Any]]]: """ Filters base64-encoded images and uses PaddleOCR to extract infograph...
Filters base64-encoded images and uses PaddleOCR to extract infographic data. For each image that meets the minimum size, calls paddle_client.infer to obtain (text_predictions, bounding_boxes). Invalid images are marked as skipped. Parameters ---------- base64_images : List[str] List ...
_update_infographic_metadata
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/image/infographic_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/image/infographic_extractor.py
Apache-2.0
def _meets_infographic_criteria(row: pd.Series) -> bool: """ Determines if a DataFrame row meets the criteria for infographic extraction. A row qualifies if: - It contains a 'metadata' dictionary. - The 'content_metadata' in metadata has type "structured" and subtype "infographic". - The ...
Determines if a DataFrame row meets the criteria for infographic extraction. A row qualifies if: - It contains a 'metadata' dictionary. - The 'content_metadata' in metadata has type "structured" and subtype "infographic". - The 'table_metadata' is not None. - The 'content' is not None ...
_meets_infographic_criteria
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/image/infographic_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/image/infographic_extractor.py
Apache-2.0
def extract_infographic_data_from_image_internal( df_extraction_ledger: pd.DataFrame, task_config: Dict[str, Any], extraction_config: InfographicExtractorSchema, execution_trace_log: Optional[Dict] = None, ) -> Tuple[pd.DataFrame, Dict]: """ Extracts infographic data from a DataFrame in bulk, fo...
Extracts infographic data from a DataFrame in bulk, following the chart extraction pattern. Parameters ---------- df_extraction_ledger : pd.DataFrame DataFrame containing the content from which infographic data is to be extracted. task_config : Dict[str, Any] Dictionary containing ...
extract_infographic_data_from_image_internal
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/image/infographic_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/image/infographic_extractor.py
Apache-2.0
def _filter_valid_images(base64_images: List[str]) -> Tuple[List[str], List[np.ndarray], List[int]]: """ Filter base64-encoded images by their dimensions. Returns three lists: - valid_images: The base64 strings that meet minimum size requirements. - valid_arrays: The corresponding numpy arrays....
Filter base64-encoded images by their dimensions. Returns three lists: - valid_images: The base64 strings that meet minimum size requirements. - valid_arrays: The corresponding numpy arrays. - valid_indices: The original indices in the input list.
_filter_valid_images
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/image/table_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/image/table_extractor.py
Apache-2.0
def _run_inference( enable_yolox: bool, yolox_client: Any, paddle_client: Any, valid_arrays: List[np.ndarray], valid_images: List[str], trace_info: Optional[Dict] = None, ) -> Tuple[List[Any], List[Any]]: """ Run inference concurrently for YOLOX (if enabled) and Paddle. Returns a tu...
Run inference concurrently for YOLOX (if enabled) and Paddle. Returns a tuple of (yolox_results, paddle_results).
_run_inference
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/image/table_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/image/table_extractor.py
Apache-2.0
def _validate_inference_results( yolox_results: Any, paddle_results: Any, valid_arrays: List[Any], valid_images: List[str], ) -> Tuple[List[Any], List[Any]]: """ Validate that both inference results are lists and have the expected lengths. If not, default values are assigned. Raises a Value...
Validate that both inference results are lists and have the expected lengths. If not, default values are assigned. Raises a ValueError if the lengths do not match.
_validate_inference_results
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/image/table_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/image/table_extractor.py
Apache-2.0
def _update_table_metadata( base64_images: List[str], yolox_client: Any, paddle_client: Any, worker_pool_size: int = 8, # Not currently used enable_yolox: bool = False, trace_info: Optional[Dict] = None, ) -> List[Tuple[str, Any, Any, Any]]: """ Given a list of base64-encoded images, th...
Given a list of base64-encoded images, this function filters out images that do not meet the minimum size requirements and then calls the PaddleOCR model via paddle_client.infer to extract table data. For each base64-encoded image, the result is a tuple: (base64_image, yolox_result, paddle_tex...
_update_table_metadata
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/image/table_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/image/table_extractor.py
Apache-2.0
def extract_table_data_from_image_internal( df_extraction_ledger: pd.DataFrame, task_config: Union[IngestTaskTableExtraction, Dict[str, Any]], extraction_config: TableExtractorSchema, execution_trace_log: Optional[Dict] = None, ) -> Tuple[pd.DataFrame, Dict]: """ Extracts table data from a DataF...
Extracts table data from a DataFrame in a bulk fashion rather than row-by-row, following the chart extraction pattern. Parameters ---------- df_extraction_ledger : pd.DataFrame DataFrame containing the content from which table data is to be extracted. task_config : Dict[str, Any] ...
extract_table_data_from_image_internal
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/image/table_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/image/table_extractor.py
Apache-2.0
def load_and_preprocess_image(image_stream: io.BytesIO) -> np.ndarray: """ Loads and preprocesses a JPEG, JPG, or PNG image from a bytestream. Parameters ---------- image_stream : io.BytesIO A bytestream of the image file. Returns ------- np.ndarray Preprocessed image a...
Loads and preprocesses a JPEG, JPG, or PNG image from a bytestream. Parameters ---------- image_stream : io.BytesIO A bytestream of the image file. Returns ------- np.ndarray Preprocessed image as a numpy array.
load_and_preprocess_image
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/image/image_helpers/common.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/image/image_helpers/common.py
Apache-2.0
def convert_svg_to_bitmap(image_stream: io.BytesIO) -> np.ndarray: """ Converts an SVG image from a bytestream to a bitmap format. Parameters ---------- image_stream : io.BytesIO A bytestream of the SVG file. Returns ------- np.ndarray Preprocessed image as a numpy arra...
Converts an SVG image from a bytestream to a bitmap format. Parameters ---------- image_stream : io.BytesIO A bytestream of the SVG file. Returns ------- np.ndarray Preprocessed image as a numpy array in bitmap format.
convert_svg_to_bitmap
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/image/image_helpers/common.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/image/image_helpers/common.py
Apache-2.0
def extract_page_element_images( annotation_dict: Dict[str, List[List[float]]], original_image: np.ndarray, page_idx: int, page_elements: List[Tuple[int, "CroppedImageWithContent"]], ) -> None: """ Handle the extraction of tables and charts from the inference results and run additional model inf...
Handle the extraction of tables and charts from the inference results and run additional model inference. Parameters ---------- annotation_dict : dict of {str : list of list of float} A dictionary containing detected objects and their bounding boxes. Keys should include "table" and "chart", ...
extract_page_element_images
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/image/image_helpers/common.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/image/image_helpers/common.py
Apache-2.0
def extract_page_elements_from_images( images: List[np.ndarray], config: ImageConfigSchema, trace_info: Optional[List] = None, ) -> List[Tuple[int, object]]: """ Detect and extract tables/charts from a list of NumPy images using YOLOX. Parameters ---------- images : List[np.ndarray] ...
Detect and extract tables/charts from a list of NumPy images using YOLOX. Parameters ---------- images : List[np.ndarray] List of images in NumPy array format. config : ImageConfigSchema Configuration object containing YOLOX endpoints, auth token, etc. trace_info : Optional[Lis...
extract_page_elements_from_images
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/image/image_helpers/common.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/image/image_helpers/common.py
Apache-2.0
def extract_primitives_from_pdf_internal( df_extraction_ledger: pd.DataFrame, task_config: Dict[str, Any], extractor_config: Any, execution_trace_log: Optional[List[Any]] = None, ) -> Tuple[pd.DataFrame, Dict]: """ Process a DataFrame of PDF documents by orchestrating extraction for each row. ...
Process a DataFrame of PDF documents by orchestrating extraction for each row. This function applies the row-level orchestration function to every row in the DataFrame, aggregates the results, and returns a new DataFrame with the extracted data along with any trace information. Parameters ---...
extract_primitives_from_pdf_internal
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/pdf/pdf_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/pdf/pdf_extractor.py
Apache-2.0
def adobe_extractor( pdf_stream: io.BytesIO, extract_text: bool, extract_images: bool, extract_infographics: bool, extract_tables: bool, extractor_config: dict, execution_trace_log: Optional[List[Any]] = None, ) -> pd.DataFrame: """ Helper function to use unstructured-io REST API to ...
Helper function to use unstructured-io REST API to extract text from a bytestream PDF. Parameters ---------- pdf_stream : io.BytesIO A bytestream PDF. extract_text : bool Specifies whether to extract text. extract_images : bool Specifies whether to extract images. e...
adobe_extractor
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/pdf/engines/adobe.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/pdf/engines/adobe.py
Apache-2.0
def llama_parse_extractor( pdf_stream: io.BytesIO, extract_text: bool, extract_images: bool, extract_infographics: bool, extract_tables: bool, extractor_config: dict, execution_trace_log: Optional[List[Any]] = None, ) -> List[Dict[ContentTypeEnum, Dict[str, Any]]]: """ Helper functio...
Helper function to use LlamaParse API to extract text from a bytestream PDF. Parameters ---------- pdf_stream : io.BytesIO A bytestream PDF. extract_text : bool Specifies whether to extract text. extract_images : bool Specifies whether to extract images. extract_tab...
llama_parse_extractor
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/pdf/engines/llama.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/pdf/engines/llama.py
Apache-2.0
async def async_llama_parse( pdf_stream: io.BytesIO, api_key: str, file_name: str = DEFAULT_FILE_NAME, result_type: str = DEFAULT_RESULT_TYPE, check_interval_seconds: int = DEFAULT_CHECK_INTERVAL_SECONDS, max_timeout_seconds: int = DEFAULT_MAX_TIMEOUT_SECONDS, ) -> str: """Uses the LlamaPars...
Uses the LlamaParse API to extract text from bytestream PDF. Parameters ---------- pdf_stream : io.BytesIO A bytestream PDF. api_key: str API key from https://cloud.llamaindex.ai. file_name: str Name of the PDF file. result_type: str The result type for the parse...
async_llama_parse
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/pdf/engines/llama.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/pdf/engines/llama.py
Apache-2.0
def nemoretriever_parse_extractor( pdf_stream: io.BytesIO, extract_text: bool, extract_images: bool, extract_infographics: bool, extract_tables: bool, extract_charts: bool, extractor_config: dict, execution_trace_log: Optional[List[Any]] = None, ) -> str: """ Helper function to u...
Helper function to use nemoretriever_parse to extract text from a bytestream PDF. Parameters ---------- pdf_stream : io.BytesIO A bytestream PDF. extract_text : bool Specifies whether to extract text. extract_images : bool Specifies whether to extract images. extrac...
nemoretriever_parse_extractor
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/pdf/engines/nemoretriever.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/pdf/engines/nemoretriever.py
Apache-2.0
def _extract_page_elements_using_image_ensemble( pages: List[Tuple[int, np.ndarray, Tuple[int, int]]], yolox_client, yolox_model_name: str = "yolox", execution_trace_log: Optional[List] = None, ) -> List[Tuple[int, object]]: """ Given a list of (page_index, image) tuples and a YOLOX client, this...
Given a list of (page_index, image) tuples and a YOLOX client, this function performs inference to extract page element annotations from all pages. Parameters ---------- pages : List[Tuple[int, np.ndarray, Tuple[int, int]]] List of tuples containing page index, image data as numpy array, ...
_extract_page_elements_using_image_ensemble
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/pdf/engines/pdfium.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/pdf/engines/pdfium.py
Apache-2.0
def _extract_page_element_images( annotation_dict, original_image, page_idx, page_elements, padding_offset=(0, 0), ): """ Handle the extraction of page elements from the inference results and run additional model inference. Parameters ---------- annotation_dict : dict/ A...
Handle the extraction of page elements from the inference results and run additional model inference. Parameters ---------- annotation_dict : dict/ A dictionary containing detected objects and their bounding boxes. original_image : np.ndarray The original image from which objects w...
_extract_page_element_images
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/pdf/engines/pdfium.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/pdf/engines/pdfium.py
Apache-2.0
def _extract_page_images( extract_images_method: str, page, page_idx: int, page_width: float, page_height: float, page_count: int, source_metadata: dict, base_unified_metadata: dict, **extract_images_params, ) -> list: """ Always extract images from the given page and return ...
Always extract images from the given page and return a list of image metadata items. The caller decides whether to call this based on a flag.
_extract_page_images
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/pdf/engines/pdfium.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/pdf/engines/pdfium.py
Apache-2.0
def _extract_page_elements( pages: list, page_count: int, source_metadata: dict, base_unified_metadata: dict, extract_tables: bool, extract_charts: bool, extract_infographics: bool, paddle_output_format: str, yolox_endpoints: Tuple[Optional[str], Optional[str]], yolox_infer_proto...
Extract page elements from the given pages using YOLOX-based inference. This function creates a YOLOX client using the provided parameters, extracts elements from pages, and builds metadata for each extracted element based on the specified extraction flags. Parameters ---------- pages : l...
_extract_page_elements
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/pdf/engines/pdfium.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/pdf/engines/pdfium.py
Apache-2.0
def unstructured_io_extractor( pdf_stream: io.BytesIO, extract_text: bool, extract_images: bool, extract_infographics: bool, extract_charts: bool, extract_tables: bool, extractor_config: Dict[str, Any], execution_trace_log: Optional[List[Any]] = None, ) -> pd.DataFrame: """ Helpe...
Helper function to use unstructured-io REST API to extract text from a bytestream PDF. This function sends the provided PDF stream to the unstructured-io API and returns the extracted text. Additional parameters for the extraction are provided via the extractor_config dictionary. Note that although fl...
unstructured_io_extractor
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/pdf/engines/unstructured_io.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/pdf/engines/unstructured_io.py
Apache-2.0
def _work_extract_pdf( *, pdf_stream: io.BytesIO, extract_text: bool, extract_images: bool, extract_infographics: bool, extract_tables: bool, extract_charts: bool, extractor_config: dict, execution_trace_log=None, ) -> Any: """ Perform PDF extraction on a decoded PDF stream u...
Perform PDF extraction on a decoded PDF stream using the given extraction parameters.
_work_extract_pdf
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/pdf/engines/pdf_helpers/__init__.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/pdf/engines/pdf_helpers/__init__.py
Apache-2.0
def _orchestrate_row_extraction( row: pd.Series, task_config: Dict[str, Any], extractor_config: Any, execution_trace_log: Optional[List[Any]] = None, ) -> Any: """ Orchestrate extraction for a single DataFrame row by decoding the PDF stream, building an extractor_config, and then delegating ...
Orchestrate extraction for a single DataFrame row by decoding the PDF stream, building an extractor_config, and then delegating to the work function.
_orchestrate_row_extraction
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/pdf/engines/pdf_helpers/__init__.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/pdf/engines/pdf_helpers/__init__.py
Apache-2.0
def _prepare_task_properties( base64_row: pd.Series, task_props: Union[Dict[str, Any], BaseModel] ) -> Tuple[Dict[str, Any], Optional[str]]: """ Prepare and return the task properties dictionary and source identifier from a DataFrame row. This function converts task properties to a dictionary (if provi...
Prepare and return the task properties dictionary and source identifier from a DataFrame row. This function converts task properties to a dictionary (if provided as a Pydantic model), extracts row data (excluding the "content" field), and stores it under the "row_data" key within the task properties. ...
_prepare_task_properties
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/pptx/pptx_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/pptx/pptx_extractor.py
Apache-2.0
def _decode_and_extract_from_pptx( base64_row: pd.Series, task_props: Union[Dict[str, Any], BaseModel], extraction_config: Any, trace_info: Dict[str, Any], ) -> Any: """ Decode base64-encoded PPTX content from a DataFrame row and extract data using the specified method. The function prepare...
Decode base64-encoded PPTX content from a DataFrame row and extract data using the specified method. The function prepares task properties (using `_prepare_task_properties`), decodes the base64 content into a byte stream, determines extraction parameters, and calls the extraction function (e.g. `python_pp...
_decode_and_extract_from_pptx
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/pptx/pptx_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/pptx/pptx_extractor.py
Apache-2.0
def _finalize_images( pending_images: List[Tuple[Shape, int, int, int, dict, dict, dict]], extracted_data: List, pptx_extraction_config: PPTXConfigSchema, extract_tables: bool = False, extract_charts: bool = False, trace_info: Optional[Dict] = None, ): """ Post-process all pending images...
Post-process all pending images. - Convert shape image -> NumPy or base64 - If `extract_tables` or `extract_charts`, do detection (table/chart) - Build the appropriate metadata, either table/chart or image. This mimics the docx approach, but adapted for python-pptx shapes.
_finalize_images
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/pptx/engines/pptx_helper.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/pptx/engines/pptx_helper.py
Apache-2.0
def process_shape( shape, shape_idx, slide_idx, slide_count, pending_images, page_nearby_blocks, source_metadata, base_unified_metadata ): """ Recursively process a shape: - If the shape is a group, iterate over its child shapes. - If it is a picture or a placeholder with an embedded image, appe...
Recursively process a shape: - If the shape is a group, iterate over its child shapes. - If it is a picture or a placeholder with an embedded image, append it to pending_images.
process_shape
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/pptx/engines/pptx_helper.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/pptx/engines/pptx_helper.py
Apache-2.0
def python_pptx( *, pptx_stream: IO, extract_text: bool, extract_images: bool, extract_infographics: bool, extract_tables: bool, extract_charts: bool, extraction_config: dict, execution_trace_log: Optional[List] = None, ): """ Uses python-pptx to extract text from a PPTX byte...
Uses python-pptx to extract text from a PPTX bytestream, while deferring image classification into tables/charts if requested.
python_pptx
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/extract/pptx/engines/pptx_helper.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/extract/pptx/engines/pptx_helper.py
Apache-2.0
def _hash_content(x: Any, algorithm: str = "md5") -> bytes: """ Compute a hash of the content using the specified algorithm. Parameters ---------- x : dict A dictionary containing the content under the key "content". algorithm : str, optional Hashing algorithm to use (default "m...
Compute a hash of the content using the specified algorithm. Parameters ---------- x : dict A dictionary containing the content under the key "content". algorithm : str, optional Hashing algorithm to use (default "md5"). Returns ------- bytes The computed hash....
_hash_content
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/mutate/deduplicate.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/mutate/deduplicate.py
Apache-2.0
def deduplicate_images_internal( df_ledger: pd.DataFrame, task_config: Dict[str, Any], mutate_config: ImageDedupSchema = ImageDedupSchema(), execution_trace_log: Optional[List[Any]] = None, ) -> pd.DataFrame: """ Deduplicate images in a DataFrame based on content hashes. The function proces...
Deduplicate images in a DataFrame based on content hashes. The function processes rows where the 'document_type' is IMAGE, computes a content hash for each, and then either removes duplicates or marks them based on the 'filter' flag in task_config. A 'hash_algorithm' flag in task_config determines the...
deduplicate_images_internal
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/mutate/deduplicate.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/mutate/deduplicate.py
Apache-2.0
def filter_images_internal( df_ledger: pd.DataFrame, task_config: Dict[str, Any], mutate_config: ImageFilterSchema = ImageFilterSchema(), execution_trace_log: Optional[List[Any]] = None, ) -> pd.DataFrame: """ Apply an image filtering operation to a DataFrame based on average image size and aspe...
Apply an image filtering operation to a DataFrame based on average image size and aspect ratio. Parameters ---------- df_ledger : pd.DataFrame DataFrame to be filtered. Must contain 'document_type' and 'metadata' columns. task_config : dict Dictionary with the following keys: ...
filter_images_internal
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/mutate/filter.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/mutate/filter.py
Apache-2.0
def remove_task_by_type(ctrl_msg, task: str): """ Remove a task from the control message by matching its type. This function iterates over the tasks in the control message, and if it finds a task whose type matches the provided task string, it removes that task (using its unique id) and returns the...
Remove a task from the control message by matching its type. This function iterates over the tasks in the control message, and if it finds a task whose type matches the provided task string, it removes that task (using its unique id) and returns the task's properties. Parameters ---------- ...
remove_task_by_type
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/ingest_control_message.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/ingest_control_message.py
Apache-2.0
def add_task(self, task: ControlMessageTask): """ Add a task to the control message, keyed by the task's unique 'id'. Raises ------ ValueError If a task with the same 'id' already exists. """ if task.id in self._tasks: raise ValueError(f"T...
Add a task to the control message, keyed by the task's unique 'id'. Raises ------ ValueError If a task with the same 'id' already exists.
add_task
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/ingest_control_message.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/ingest_control_message.py
Apache-2.0
def remove_task(self, task_id: str) -> ControlMessageTask: """ Remove a task from the control message. Logs a warning if the task does not exist. """ if task_id in self._tasks: _task = self._tasks[task_id] del self._tasks[task_id] return _task ...
Remove a task from the control message. Logs a warning if the task does not exist.
remove_task
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/ingest_control_message.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/ingest_control_message.py
Apache-2.0
def config(self, config: Dict[str, Any] = None) -> Dict[str, Any]: """ Get or update the control message configuration. If 'config' is provided, it must be a dictionary. The configuration is updated with the provided values. If no argument is provided, returns a copy of the current conf...
Get or update the control message configuration. If 'config' is provided, it must be a dictionary. The configuration is updated with the provided values. If no argument is provided, returns a copy of the current configuration. Raises ------ ValueError If th...
config
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/ingest_control_message.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/ingest_control_message.py
Apache-2.0
def get_metadata(self, key: Union[str, re.Pattern] = None, default_value: Any = None) -> Any: """ Retrieve metadata. If 'key' is None, returns a copy of all metadata. Parameters ---------- key : str or re.Pattern, optional If a string is provided, returns the value f...
Retrieve metadata. If 'key' is None, returns a copy of all metadata. Parameters ---------- key : str or re.Pattern, optional If a string is provided, returns the value for that exact key. If a regex pattern is provided, returns a dictionary of all metadata key-v...
get_metadata
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/ingest_control_message.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/ingest_control_message.py
Apache-2.0
def has_metadata(self, key: Union[str, re.Pattern]) -> bool: """ Check if a metadata key exists. Parameters ---------- key : str or re.Pattern If a string is provided, checks for the exact key. If a regex pattern is provided, returns True if any metadata ...
Check if a metadata key exists. Parameters ---------- key : str or re.Pattern If a string is provided, checks for the exact key. If a regex pattern is provided, returns True if any metadata key matches the regex. Returns ------- bool ...
has_metadata
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/ingest_control_message.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/ingest_control_message.py
Apache-2.0
def filter_timestamp(self, regex_filter: str) -> Dict[str, datetime]: """ Retrieve timestamps whose keys match the regex filter. """ pattern = re.compile(regex_filter) timestamps_snapshot = self._timestamps.copy() return {key: ts for key, ts in timestamps_snapshot.items()...
Retrieve timestamps whose keys match the regex filter.
filter_timestamp
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/ingest_control_message.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/ingest_control_message.py
Apache-2.0
def get_timestamp(self, key: str, fail_if_nonexist: bool = False) -> datetime: """ Retrieve a timestamp for a given key. Raises ------ KeyError If the key is not found and 'fail_if_nonexist' is True. """ if key in self._timestamps: return ...
Retrieve a timestamp for a given key. Raises ------ KeyError If the key is not found and 'fail_if_nonexist' is True.
get_timestamp
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/ingest_control_message.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/ingest_control_message.py
Apache-2.0
def set_timestamp(self, key: str, timestamp: Any) -> None: """ Set a timestamp for a given key. Accepts either a datetime object or an ISO format string. Raises ------ ValueError If the provided timestamp is neither a datetime object nor a valid ISO format string. ...
Set a timestamp for a given key. Accepts either a datetime object or an ISO format string. Raises ------ ValueError If the provided timestamp is neither a datetime object nor a valid ISO format string.
set_timestamp
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/ingest_control_message.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/ingest_control_message.py
Apache-2.0
def payload(self, payload: pd.DataFrame = None) -> pd.DataFrame: """ Get or set the payload DataFrame. Raises ------ ValueError If the provided payload is not a pandas DataFrame. """ if payload is None: return self._payload if not...
Get or set the payload DataFrame. Raises ------ ValueError If the provided payload is not a pandas DataFrame.
payload
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/ingest_control_message.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/ingest_control_message.py
Apache-2.0
def __init__( self, model_interface, protocol: str, endpoints: Tuple[str, str], auth_token: Optional[str] = None, timeout: float = 120.0, max_retries: int = 5, ): """ Initialize the NimClient with the specified model interface, protocol, and se...
Initialize the NimClient with the specified model interface, protocol, and server endpoints. Parameters ---------- model_interface : ModelInterface The model interface implementation to use. protocol : str The protocol to use ("grpc" or "http"). ...
__init__
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/nim_client.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/nim_client.py
Apache-2.0
def _fetch_max_batch_size(self, model_name, model_version: str = "") -> int: """Fetch the maximum batch size from the Triton model configuration in a thread-safe manner.""" if model_name in self._max_batch_sizes: return self._max_batch_sizes[model_name] with self._lock: ...
Fetch the maximum batch size from the Triton model configuration in a thread-safe manner.
_fetch_max_batch_size
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/nim_client.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/nim_client.py
Apache-2.0
def _process_batch(self, batch_input, *, batch_data, model_name, **kwargs): """ Process a single batch input for inference using its corresponding batch_data. Parameters ---------- batch_input : Any The input data for this batch. batch_data : Any ...
Process a single batch input for inference using its corresponding batch_data. Parameters ---------- batch_input : Any The input data for this batch. batch_data : Any The corresponding scratch-pad data for this batch as returned by format_input. ...
_process_batch
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/nim_client.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/nim_client.py
Apache-2.0
def infer(self, data: dict, model_name: str, **kwargs) -> Any: """ Perform inference using the specified model and input data. Parameters ---------- data : dict The input data for inference. model_name : str The model name. kwargs : dict ...
Perform inference using the specified model and input data. Parameters ---------- data : dict The input data for inference. model_name : str The model name. kwargs : dict Additional parameters for inference. Returns -...
infer
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/nim_client.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/nim_client.py
Apache-2.0
def _grpc_infer(self, formatted_input: np.ndarray, model_name: str) -> np.ndarray: """ Perform inference using the gRPC protocol. Parameters ---------- formatted_input : np.ndarray The input data formatted as a numpy array. model_name : str The na...
Perform inference using the gRPC protocol. Parameters ---------- formatted_input : np.ndarray The input data formatted as a numpy array. model_name : str The name of the model to use for inference. Returns ------- np.ndarray ...
_grpc_infer
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/nim_client.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/nim_client.py
Apache-2.0
def _http_infer(self, formatted_input: dict) -> dict: """ Perform inference using the HTTP protocol, retrying for timeouts or 5xx errors up to 5 times. Parameters ---------- formatted_input : dict The input data formatted as a dictionary. Returns ---...
Perform inference using the HTTP protocol, retrying for timeouts or 5xx errors up to 5 times. Parameters ---------- formatted_input : dict The input data formatted as a dictionary. Returns ------- dict The output of the model as a dictio...
_http_infer
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/nim_client.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/nim_client.py
Apache-2.0
def prepare_data_for_inference(self, data: Dict[str, Any]) -> Dict[str, Any]: """ Decode base64-encoded images into NumPy arrays, storing them in `data["image_arrays"]`. Parameters ---------- data : dict of str -> Any The input data containing either: - ...
Decode base64-encoded images into NumPy arrays, storing them in `data["image_arrays"]`. Parameters ---------- data : dict of str -> Any The input data containing either: - "base64_image": a single base64-encoded image, or - "base64_images": a list ...
prepare_data_for_inference
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/cached.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/cached.py
Apache-2.0
def format_input(self, data: Dict[str, Any], protocol: str, max_batch_size: int, **kwargs) -> Any: """ Format input data for the specified protocol ("grpc" or "http"), handling batched images. Additionally, returns batched data that coalesces the original image arrays and their dimensions ...
Format input data for the specified protocol ("grpc" or "http"), handling batched images. Additionally, returns batched data that coalesces the original image arrays and their dimensions in the same order as provided. Parameters ---------- data : dict of str -> Any ...
format_input
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/cached.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/cached.py
Apache-2.0
def parse_output(self, response: Any, protocol: str, data: Optional[Dict[str, Any]] = None, **kwargs: Any) -> Any: """ Parse the output from the Cached model's inference response. Parameters ---------- response : Any The raw response from the model inference. ...
Parse the output from the Cached model's inference response. Parameters ---------- response : Any The raw response from the model inference. protocol : str The protocol used ("grpc" or "http"). data : dict of str -> Any, optional Addi...
parse_output
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/cached.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/cached.py
Apache-2.0
def _extract_content_from_nim_response(self, json_response: Dict[str, Any]) -> Any: """ Extract content from the JSON response of a NIM (HTTP) API request. Parameters ---------- json_response : dict of str -> Any The JSON response from the NIM API. Returns ...
Extract content from the JSON response of a NIM (HTTP) API request. Parameters ---------- json_response : dict of str -> Any The JSON response from the NIM API. Returns ------- Any The extracted content from the response. Raises...
_extract_content_from_nim_response
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/cached.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/cached.py
Apache-2.0
def multiprocessing_cache(max_calls): """ A decorator that creates a global cache shared between multiple processes. The cache is invalidated after `max_calls` number of accesses. Args: max_calls (int): The number of calls after which the cache is cleared. Returns: function: The de...
A decorator that creates a global cache shared between multiple processes. The cache is invalidated after `max_calls` number of accesses. Args: max_calls (int): The number of calls after which the cache is cleared. Returns: function: The decorated function with global cache and invali...
multiprocessing_cache
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/decorators.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/decorators.py
Apache-2.0
def prepare_data_for_inference(self, data: Dict[str, Any]) -> Dict[str, Any]: """ Prepare input data by decoding one or more base64-encoded images into NumPy arrays. Parameters ---------- data : dict The input data containing either 'base64_image' (single image) ...
Prepare input data by decoding one or more base64-encoded images into NumPy arrays. Parameters ---------- data : dict The input data containing either 'base64_image' (single image) or 'base64_images' (multiple images). Returns ------- di...
prepare_data_for_inference
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/deplot.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/deplot.py
Apache-2.0
def _prepare_deplot_payload( base64_list: list, max_tokens: int = 500, temperature: float = 0.5, top_p: float = 0.9, ) -> Dict[str, Any]: """ Prepare an HTTP payload for Deplot that includes one message per image, matching the original single-image style: ...
Prepare an HTTP payload for Deplot that includes one message per image, matching the original single-image style: messages = [ { "role": "user", "content": "Generate ... <img src="data:image/png;base64,..." />" }, { ...
_prepare_deplot_payload
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/deplot.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/deplot.py
Apache-2.0
def _extract_content_from_deplot_response(json_response: Dict[str, Any]) -> Any: """ Extract content from the JSON response of a Deplot HTTP API request. The original code expected a single choice with a single textual content. """ if "choices" not in json_response or not json_re...
Extract content from the JSON response of a Deplot HTTP API request. The original code expected a single choice with a single textual content.
_extract_content_from_deplot_response
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/deplot.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/deplot.py
Apache-2.0
def preprocess_image_for_paddle(array: np.ndarray, image_max_dimension: int = 960) -> np.ndarray: """ Preprocesses an input image to be suitable for use with PaddleOCR by resizing, normalizing, padding, and transposing it into the required format. This function is intended for preprocessing images to b...
Preprocesses an input image to be suitable for use with PaddleOCR by resizing, normalizing, padding, and transposing it into the required format. This function is intended for preprocessing images to be passed as input to PaddleOCR using GRPC. It is not necessary when using the HTTP endpoint. Ste...
preprocess_image_for_paddle
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/helpers.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/helpers.py
Apache-2.0
def is_ready(http_endpoint: str, ready_endpoint: str) -> bool: """ Check if the server at the given endpoint is ready. Parameters ---------- http_endpoint : str The HTTP endpoint of the server. ready_endpoint : str The specific ready-check endpoint. Returns ------- ...
Check if the server at the given endpoint is ready. Parameters ---------- http_endpoint : str The HTTP endpoint of the server. ready_endpoint : str The specific ready-check endpoint. Returns ------- bool True if the server is ready, False otherwise.
is_ready
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/helpers.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/helpers.py
Apache-2.0
def get_version(http_endpoint: str, metadata_endpoint: str = "/v1/metadata", version_field: str = "version") -> str: """ Get the version of the server from its metadata endpoint. Parameters ---------- http_endpoint : str The HTTP endpoint of the server. metadata_endpoint : str, optional...
Get the version of the server from its metadata endpoint. Parameters ---------- http_endpoint : str The HTTP endpoint of the server. metadata_endpoint : str, optional The metadata endpoint to query (default: "/v1/metadata"). version_field : str, optional The field conta...
get_version
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/helpers.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/helpers.py
Apache-2.0
def get_model_name( http_endpoint: str, default_model_name, metadata_endpoint: str = "/v1/metadata", model_info_field: str = "modelInfo", ) -> str: """ Get the model name of the server from its metadata endpoint. Parameters ---------- http_endpoint : str The HTTP endpoint of...
Get the model name of the server from its metadata endpoint. Parameters ---------- http_endpoint : str The HTTP endpoint of the server. metadata_endpoint : str, optional The metadata endpoint to query (default: "/v1/metadata"). model_info_field : str, optional The field...
get_model_name
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/helpers.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/helpers.py
Apache-2.0
def format_input(self, data: Dict[str, Any], protocol: str, max_batch_size: int, **kwargs) -> Any: """ Format input data for the specified protocol. Parameters ---------- data : dict The input data to format. protocol : str The protocol to use ("g...
Format input data for the specified protocol. Parameters ---------- data : dict The input data to format. protocol : str The protocol to use ("grpc" or "http"). **kwargs : dict Additional parameters for HTTP payload formatting. ...
format_input
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/nemoretriever_parse.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/nemoretriever_parse.py
Apache-2.0
def parse_output(self, response: Any, protocol: str, data: Optional[Dict[str, Any]] = None, **kwargs) -> Any: """ Parse the output from the model's inference response. Parameters ---------- response : Any The response from the model inference. protocol : str ...
Parse the output from the model's inference response. Parameters ---------- response : Any The response from the model inference. protocol : str The protocol used ("grpc" or "http"). data : dict, optional Additional input data passed ...
parse_output
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/nemoretriever_parse.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/nemoretriever_parse.py
Apache-2.0
def _extract_content_from_nemoretriever_parse_response(self, json_response: Dict[str, Any]) -> Any: """ Extract content from the JSON response of a Deplot HTTP API request. Parameters ---------- json_response : dict The JSON response from the Deplot API. Ret...
Extract content from the JSON response of a Deplot HTTP API request. Parameters ---------- json_response : dict The JSON response from the Deplot API. Returns ------- Any The extracted content from the response. Raises -...
_extract_content_from_nemoretriever_parse_response
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/nemoretriever_parse.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/nemoretriever_parse.py
Apache-2.0
def prepare_data_for_inference(self, data: Dict[str, Any]) -> Dict[str, Any]: """ Decode one or more base64-encoded images into NumPy arrays, storing them alongside their dimensions in `data`. Parameters ---------- data : dict of str -> Any The input data con...
Decode one or more base64-encoded images into NumPy arrays, storing them alongside their dimensions in `data`. Parameters ---------- data : dict of str -> Any The input data containing either: - 'base64_image': a single base64-encoded image, or ...
prepare_data_for_inference
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/paddle.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/paddle.py
Apache-2.0
def format_input(self, data: Dict[str, Any], protocol: str, max_batch_size: int, **kwargs) -> Any: """ Format input data for the specified protocol ("grpc" or "http"), supporting batched data. Parameters ---------- data : dict of str -> Any The input data dictionary,...
Format input data for the specified protocol ("grpc" or "http"), supporting batched data. Parameters ---------- data : dict of str -> Any The input data dictionary, expected to contain "image_arrays" (list of np.ndarray) and "image_dims" (list of (height, width)...
format_input
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/paddle.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/paddle.py
Apache-2.0
def parse_output(self, response: Any, protocol: str, data: Optional[Dict[str, Any]] = None, **kwargs: Any) -> Any: """ Parse the model's inference response for the given protocol. The parsing may handle batched outputs for multiple images. Parameters ---------- response ...
Parse the model's inference response for the given protocol. The parsing may handle batched outputs for multiple images. Parameters ---------- response : Any The raw response from the PaddleOCR model. protocol : str The protocol used for inferenc...
parse_output
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/paddle.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/paddle.py
Apache-2.0
def _prepare_paddle_payload(self, base64_img: str) -> Dict[str, Any]: """ DEPRECATED by batch logic in format_input. Kept here if you need single-image direct calls. Parameters ---------- base64_img : str A single base64-encoded image string. Returns ...
DEPRECATED by batch logic in format_input. Kept here if you need single-image direct calls. Parameters ---------- base64_img : str A single base64-encoded image string. Returns ------- dict of str -> Any The payload in either legacy or n...
_prepare_paddle_payload
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/paddle.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/paddle.py
Apache-2.0
def _extract_content_from_paddle_http_response( self, json_response: Dict[str, Any], dimensions: List[Dict[str, Any]], ) -> List[Tuple[str, str]]: """ Extract content from the JSON response of a PaddleOCR HTTP API request. Parameters ---------- json_r...
Extract content from the JSON response of a PaddleOCR HTTP API request. Parameters ---------- json_response : dict of str -> Any The JSON response returned by the PaddleOCR endpoint. table_content_format : str or None The specified format for table conte...
_extract_content_from_paddle_http_response
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/paddle.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/paddle.py
Apache-2.0
def _extract_content_from_paddle_grpc_response( self, response: np.ndarray, dimensions: List[Dict[str, Any]], ) -> List[Tuple[str, str]]: """ Parse a gRPC response for one or more images. The response can have two possible shapes: - (3,) for batch_size=1 -...
Parse a gRPC response for one or more images. The response can have two possible shapes: - (3,) for batch_size=1 - (3, n) for batch_size=n In either case: response[0, i]: byte string containing bounding box data response[1, i]: byte string containing text predic...
_extract_content_from_paddle_grpc_response
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/paddle.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/paddle.py
Apache-2.0
def _postprocess_paddle_response( bounding_boxes: List[Any], text_predictions: List[str], dims: Optional[List[Dict[str, Any]]] = None, img_index: int = 0, ) -> Tuple[List[Any], List[str]]: """ Convert bounding boxes with normalized coordinates to pixel cooridnates by ...
Convert bounding boxes with normalized coordinates to pixel cooridnates by using the dimensions. Also shift the coorindates if the inputs were padded. For multiple images, the correct image dimensions (height, width) are retrieved from `dims[img_index]`. Parameters ---------- ...
_postprocess_paddle_response
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/paddle.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/paddle.py
Apache-2.0
def __init__( self, endpoint: str, auth_token: Optional[str] = None, function_id: Optional[str] = None, use_ssl: Optional[bool] = None, ssl_cert: Optional[str] = None, ): """ Initialize the ParakeetClient. Parameters ---------- ...
Initialize the ParakeetClient. Parameters ---------- endpoint : str The URL of the Parakeet service endpoint. auth_token : Optional[str], default=None The authentication token for accessing the service. function_id: Optional[str] The ...
__init__
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/parakeet.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/parakeet.py
Apache-2.0
def transcribe( self, audio_content: str, language_code: str = "en-US", automatic_punctuation: bool = True, word_time_offsets: bool = True, max_alternatives: int = 1, profanity_filter: bool = False, verbatim_transcripts: bool = True, speaker_diariz...
Transcribe an audio file using Riva ASR. Parameters ---------- audio_content : str Base64-encoded audio content to be transcribed. language_code : str, default="en-US" The language code for transcription. automatic_punctuation : bool, default=Tru...
transcribe
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/parakeet.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/parakeet.py
Apache-2.0
def convert_to_mono_wav(audio_bytes): """ Convert an audio file to mono WAV format using Librosa and SciPy. Parameters ---------- audio_bytes : bytes The raw audio data in bytes. Returns ------- bytes The processed audio in mono WAV format. """ if librosa is No...
Convert an audio file to mono WAV format using Librosa and SciPy. Parameters ---------- audio_bytes : bytes The raw audio data in bytes. Returns ------- bytes The processed audio in mono WAV format.
convert_to_mono_wav
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/parakeet.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/parakeet.py
Apache-2.0
def process_transcription_response(response): """ Process a Riva transcription response (a protobuf message) to extract: - final_transcript: the complete transcript. - segments: a list of segments with start/end times and text. Parameters: response: The Riva transcription response message...
Process a Riva transcription response (a protobuf message) to extract: - final_transcript: the complete transcript. - segments: a list of segments with start/end times and text. Parameters: response: The Riva transcription response message. Returns: segments (list): Each segment i...
process_transcription_response
python
NVIDIA/nv-ingest
api/src/nv_ingest_api/internal/primitives/nim/model_interface/parakeet.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/src/nv_ingest_api/internal/primitives/nim/model_interface/parakeet.py
Apache-2.0