SYMBOL INDEX (790 symbols across 99 files) FILE: benchmark/detection.py function main (line 29) | def main(pdf_path: str, results_dir: str, max_rows: int, debug: bool, te... FILE: benchmark/layout.py function main (line 33) | def main(results_dir: str, max_rows: int, debug: bool): FILE: benchmark/ordering.py function main (line 30) | def main(results_dir: str, max_rows: int): FILE: benchmark/recognition.py function list_in (line 38) | def list_in(lst: str | list, lst2: list): function standardize_bullets (line 44) | def standardize_bullets(text): function normalize_text (line 67) | def normalize_text(text: str) -> str: function main (line 110) | def main( FILE: benchmark/table_recognition.py function main (line 33) | def main(results_dir: str, max_rows: int, tatr: bool, debug: bool): FILE: benchmark/texify.py function normalize_text (line 20) | def normalize_text(text): function score_text (line 32) | def score_text(predictions, references): function inference_texify (line 42) | def inference_texify( function main (line 80) | def main(ds_name: str, results_dir: str, max_rows: int, line_mode: bool): FILE: benchmark/utils/bbox.py function get_pdf_lines (line 5) | def get_pdf_lines(pdf_path, img_sizes): function merge_boxes (line 24) | def merge_boxes(box1, box2): function join_lines (line 28) | def join_lines(bboxes, max_gap=5): FILE: benchmark/utils/metrics.py function box_area (line 8) | def box_area(box): function calculate_iou (line 12) | def calculate_iou(box1, box2, box1_only=False): function match_boxes (line 23) | def match_boxes(preds, references): function penalized_iou_score (line 57) | def penalized_iou_score(preds, references): function intersection_pixels (line 62) | def intersection_pixels(box1, box2): function calculate_coverage (line 80) | def calculate_coverage(box, other_boxes, penalize_double=False): function intersection_area (line 101) | def intersection_area(box1, box2): function calculate_coverage_fast (line 113) | def calculate_coverage_fast(box, other_boxes, penalize_double=False): function precision_recall (line 136) | def precision_recall(preds, references, threshold=.5, workers=8, penaliz... function mean_coverage (line 171) | def mean_coverage(preds, references): function rank_accuracy (line 189) | def rank_accuracy(preds, references): FILE: benchmark/utils/scoring.py function overlap_score (line 7) | def overlap_score(pred_lines: List[str], reference_lines: List[str]): function overlap_score_exact (line 29) | def overlap_score_exact(pred_lines: List[str], reference_lines: List[str]): FILE: benchmark/utils/tatr.py class MaxResize (line 7) | class MaxResize(object): method __init__ (line 8) | def __init__(self, max_size=800): method __call__ (line 11) | def __call__(self, image): function to_tensor (line 20) | def to_tensor(image): function normalize (line 33) | def normalize(tensor, mean, std): function structure_transform (line 39) | def structure_transform(image): function box_cxcywh_to_xyxy (line 46) | def box_cxcywh_to_xyxy(x): function rescale_bboxes (line 52) | def rescale_bboxes(out_bbox, size): function outputs_to_objects (line 59) | def outputs_to_objects(outputs, img_sizes, id2label): function load_tatr (line 97) | def load_tatr(): function batch_inference_tatr (line 101) | def batch_inference_tatr(model, images, batch_size): FILE: benchmark/utils/tesseract.py function surya_lang_to_tesseract (line 15) | def surya_lang_to_tesseract(code: str) -> Optional[str]: function tesseract_ocr (line 24) | def tesseract_ocr(img, bboxes, lang: str): function tesseract_ocr_parallel (line 35) | def tesseract_ocr_parallel(imgs, bboxes, langs: List[str], cpus=None): function tesseract_bboxes (line 51) | def tesseract_bboxes(img): function tesseract_parallel (line 68) | def tesseract_parallel(imgs): FILE: benchmark/utils/textract.py function textract_ocr (line 9) | def textract_ocr(extractor, img): function textract_ocr_parallel (line 17) | def textract_ocr_parallel(imgs, cpus=None): FILE: benchmark/utils/verify_benchmark_scores.py function verify_layout (line 5) | def verify_layout(data): function verify_det (line 15) | def verify_det(data): function verify_rec (line 21) | def verify_rec(data): function verify_order (line 27) | def verify_order(data): function verify_table_rec (line 33) | def verify_table_rec(data): function verify_texify (line 41) | def verify_texify(data): function main (line 52) | def main(file_path, bench_type): FILE: surya/common/adetr/decoder.py class WrappedEmbedding (line 19) | class WrappedEmbedding(nn.Embedding): method forward (line 20) | def forward(self, input_ids, *args, **kwargs): class SuryaADETRDecoderRMSNorm (line 24) | class SuryaADETRDecoderRMSNorm(nn.Module): method __init__ (line 25) | def __init__(self, dim: int, eps: float = 1e-6): method _norm (line 30) | def _norm(self, x): method forward (line 37) | def forward(self, x): method extra_repr (line 50) | def extra_repr(self): class SuryaADETRDecoderRotaryEmbedding (line 57) | class SuryaADETRDecoderRotaryEmbedding(nn.Module): method __init__ (line 58) | def __init__(self, dim, base=10000, device=None): method forward (line 70) | def forward(self, x, position_ids, seq_len=None): function rotate_half (line 88) | def rotate_half(x): function apply_rotary_pos_emb (line 96) | def apply_rotary_pos_emb(q, k, cos, sin, unsqueeze_dim=1): function repeat_kv (line 122) | def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor: class SuryaADETRDecoderSdpaCrossAttention (line 136) | class SuryaADETRDecoderSdpaCrossAttention(nn.Module): method __init__ (line 141) | def __init__(self, config: PretrainedConfig): method forward (line 174) | def forward( method _clear_cache (line 224) | def _clear_cache(self): method _setup_cache (line 230) | def _setup_cache(self, batch_size, device, dtype=None): method _update_cache (line 236) | def _update_cache(self, key_states, value_states, **cache_kwargs): class SuryaADETRDecoderSdpaAttention (line 241) | class SuryaADETRDecoderSdpaAttention(nn.Module): method __init__ (line 244) | def __init__(self, config: PretrainedConfig, static_cache=False, max_b... method forward (line 280) | def forward( method _setup_cache (line 347) | def _setup_cache(self, batch_size, device, dtype=None): method _clear_cache (line 366) | def _clear_cache(self): method _update_static_cache (line 372) | def _update_static_cache(self, key_states, value_states, **cache_kwargs): method _update_dynamic_cache (line 385) | def _update_dynamic_cache(self, key_states, value_states, **cache_kwar... method _update_cache (line 398) | def _update_cache(self, key_states, value_states, **cache_kwargs): class SuryaADETRDecoderMlp (line 405) | class SuryaADETRDecoderMlp(nn.Module): method __init__ (line 406) | def __init__(self, config): method forward (line 419) | def forward(self, x): class SuryaADETRDecoderLayer (line 423) | class SuryaADETRDecoderLayer(nn.Module): method __init__ (line 424) | def __init__(self, config, layer_idx, static_cache=False, max_boxes=No... method forward (line 451) | def forward( method double_res_forward (line 507) | def double_res_forward( class SuryaADETRDecoderPreTrainedModel (line 557) | class SuryaADETRDecoderPreTrainedModel(SuryaPreTrainedModel): method _init_weights (line 568) | def _init_weights(self, module): method _setup_cache (line 592) | def _setup_cache(self, config, batch, device, dtype): method _clear_cache (line 600) | def _clear_cache(self): method reset_cache (line 608) | def reset_cache(self, batch, device, dtype): method _tie_weights (line 611) | def _tie_weights(self): method tie_weights (line 614) | def tie_weights(self): class SuryaADETRDecoderModel (line 618) | class SuryaADETRDecoderModel(SuryaADETRDecoderPreTrainedModel): method __init__ (line 626) | def __init__( method get_input_embeddings (line 664) | def get_input_embeddings(self): method set_input_embeddings (line 668) | def set_input_embeddings(self, value): method forward (line 671) | def forward( method _update_causal_mask (line 761) | def _update_causal_mask(self, attention_mask, input_tensor, cache_posi... FILE: surya/common/donut/encoder.py class DonutSwinEncoderOutput (line 27) | class DonutSwinEncoderOutput(ModelOutput): class DonutSwinModelOutput (line 35) | class DonutSwinModelOutput(ModelOutput): function window_partition (line 40) | def window_partition(input_feature, window_size): function window_reverse (line 62) | def window_reverse(windows, window_size, height, width): class DonutSwinEmbeddings (line 84) | class DonutSwinEmbeddings(nn.Module): method __init__ (line 89) | def __init__(self, config, use_mask_token=False): method interpolate_pos_encoding (line 119) | def interpolate_pos_encoding( method forward (line 155) | def forward( class DonutSwinPatchEmbeddings (line 195) | class DonutSwinPatchEmbeddings(nn.Module): method __init__ (line 202) | def __init__(self, config): method maybe_pad (line 232) | def maybe_pad(self, pixel_values, height, width): method forward (line 241) | def forward( class DonutSwinPatchMerging (line 256) | class DonutSwinPatchMerging(nn.Module): method __init__ (line 269) | def __init__( method maybe_pad (line 281) | def maybe_pad(self, input_feature, height, width): method forward (line 289) | def forward( class DonutSwinSelfAttention (line 322) | class DonutSwinSelfAttention(nn.Module): method __init__ (line 323) | def __init__(self, config, dim, num_heads, num_kv_heads, window_size): method transpose_for_scores (line 371) | def transpose_for_scores(self, x): method transpose_kv_for_scores (line 379) | def transpose_kv_for_scores(self, x, repeats): method forward (line 387) | def forward( class DonutSwinSelfOutput (line 444) | class DonutSwinSelfOutput(nn.Module): method __init__ (line 445) | def __init__(self, config, dim): method forward (line 449) | def forward( class DonutSwinAttention (line 456) | class DonutSwinAttention(nn.Module): method __init__ (line 457) | def __init__(self, config, dim, num_heads, num_kv_heads, window_size): method prune_heads (line 465) | def prune_heads(self, heads): method forward (line 488) | def forward( class DonutSwinIntermediate (line 506) | class DonutSwinIntermediate(nn.Module): method __init__ (line 507) | def __init__(self, config, dim): method forward (line 515) | def forward(self, hidden_states: torch.Tensor) -> torch.Tensor: class DonutSwinOutput (line 522) | class DonutSwinOutput(nn.Module): method __init__ (line 523) | def __init__(self, config, dim): method forward (line 527) | def forward(self, hidden_states: torch.Tensor) -> torch.Tensor: class DonutSwinLayer (line 532) | class DonutSwinLayer(nn.Module): method __init__ (line 533) | def __init__( method set_shift_and_window_size (line 549) | def set_shift_and_window_size(self, input_resolution): method get_attn_mask (line 559) | def get_attn_mask(self, height, width, dtype, device): method maybe_pad (line 589) | def maybe_pad(self, hidden_states, height, width): method forward (line 596) | def forward( class DonutSwinStage (line 687) | class DonutSwinStage(nn.Module): method __init__ (line 688) | def __init__( method build_2d_sincos_position_embedding (line 735) | def build_2d_sincos_position_embedding( method forward (line 761) | def forward( class DonutSwinEncoder (line 811) | class DonutSwinEncoder(nn.Module): method __init__ (line 812) | def __init__(self, config, grid_size): method forward (line 841) | def forward( class DonutSwinPreTrainedModel (line 933) | class DonutSwinPreTrainedModel(SuryaPreTrainedModel): method _init_weights (line 945) | def _init_weights(self, module): FILE: surya/common/donut/processor.py class SuryaEncoderImageProcessor (line 23) | class SuryaEncoderImageProcessor(S3DownloaderMixin, ImageProcessingMixin): method __init__ (line 24) | def __init__( method __call__ (line 46) | def __call__(self, images, **kwargs) -> PIL.Image.Image: method numpy_resize (line 51) | def numpy_resize(cls, image: np.ndarray, size, interpolation=cv2.INTER... method process_inner (line 61) | def process_inner(self, images: List[np.ndarray]): method preprocess (line 118) | def preprocess( method pad_image (line 134) | def pad_image( method align_long_axis (line 166) | def align_long_axis( method normalize (line 180) | def normalize( FILE: surya/common/load.py class ModelLoader (line 8) | class ModelLoader: method __init__ (line 9) | def __init__(self, checkpoint: Optional[str] = None): method model (line 12) | def model( method processor (line 20) | def processor( FILE: surya/common/polygon.py class PolygonBox (line 9) | class PolygonBox(BaseModel): method convert_bbox_to_polygon (line 15) | def convert_bbox_to_polygon(cls, value): method height (line 41) | def height(self): method width (line 45) | def width(self): method area (line 49) | def area(self): method bbox (line 54) | def bbox(self) -> List[float]: method rescale (line 59) | def rescale(self, processor_size, image_size): method round (line 71) | def round(self, divisor): method fit_to_bounds (line 76) | def fit_to_bounds(self, bounds): method merge (line 83) | def merge(self, other): method merge_left (line 90) | def merge_left(self, other): method merge_right (line 95) | def merge_right(self, other): method expand (line 100) | def expand(self, x_margin: float, y_margin: float): method intersection_polygon (line 115) | def intersection_polygon(self, other) -> List[List[float]]: method intersection_area (line 142) | def intersection_area(self, other, x_margin=0, y_margin=0): method x_overlap (line 147) | def x_overlap(self, other, x_margin=0): method y_overlap (line 154) | def y_overlap(self, other, y_margin=0): method intersection_pct (line 161) | def intersection_pct(self, other, x_margin=0, y_margin=0): method shift (line 175) | def shift(self, x_shift: float | None = None, y_shift: float | None = ... method clamp (line 183) | def clamp(self, bbox: List[float]): method center (line 189) | def center(self): method distance (line 192) | def distance(self, other): method __hash__ (line 200) | def __hash__(self): FILE: surya/common/predictor.py class BasePredictor (line 9) | class BasePredictor: method disable_tqdm (line 16) | def disable_tqdm(self) -> bool: method disable_tqdm (line 20) | def disable_tqdm(self, value: bool) -> None: method __init__ (line 23) | def __init__( method to (line 42) | def to(self, device_dtype: torch.device | str | None = None): method get_batch_size (line 54) | def get_batch_size(self): method pad_to_batch_size (line 63) | def pad_to_batch_size(tensor: torch.Tensor, batch_size: int): method __call__ (line 78) | def __call__(self, *args, **kwargs): FILE: surya/common/pretrained.py class SuryaPreTrainedModel (line 7) | class SuryaPreTrainedModel(PreTrainedModel): method _check_and_adjust_attn_implementation (line 9) | def _check_and_adjust_attn_implementation( FILE: surya/common/s3.py function join_urls (line 21) | def join_urls(url1: str, url2: str): function get_model_name (line 27) | def get_model_name(pretrained_model_name_or_path: str): function download_file (line 31) | def download_file(remote_path: str, local_path: str, chunk_size: int = 1... function check_manifest (line 68) | def check_manifest(local_dir: str): function download_directory (line 86) | def download_directory(remote_path: str, local_dir: str): class S3DownloaderMixin (line 130) | class S3DownloaderMixin: method get_local_path (line 134) | def get_local_path(cls, pretrained_model_name_or_path) -> str: method from_pretrained (line 147) | def from_pretrained(cls, pretrained_model_name_or_path, *args, **kwargs): FILE: surya/common/surya/__init__.py class SuryaModelOutput (line 28) | class SuryaModelOutput(CausalLMOutputWithPast): class FlashAttentionKwargs (line 33) | class FlashAttentionKwargs(TypedDict, total=False): class KwargsForCausalLM (line 54) | class KwargsForCausalLM(FlashAttentionKwargs): ... class DistanceProjection (line 57) | class DistanceProjection(nn.Module): method __init__ (line 58) | def __init__(self, in_features: int, out_features: int): method forward (line 64) | def forward(self, x: torch.Tensor) -> torch.Tensor: method init_weights (line 70) | def init_weights(self): class BboxHead (line 77) | class BboxHead(nn.Module): method __init__ (line 78) | def __init__(self, in_features: int, out_features: int): method forward (line 86) | def forward(self, x: torch.Tensor) -> torch.Tensor: class SuryaModel (line 95) | class SuryaModel(S3DownloaderMixin, SuryaPreTrainedModel): method __init__ (line 109) | def __init__( method tie_weights (line 163) | def tie_weights(self): method _tie_weights (line 166) | def _tie_weights(self): method get_output_embeddings (line 170) | def get_output_embeddings(self) -> nn.Module: method get_input_embeddings (line 173) | def get_input_embeddings(self) -> nn.Module: method set_output_embeddings (line 176) | def set_output_embeddings(self, new_embeddings: nn.Module): method set_input_embeddings (line 179) | def set_input_embeddings(self, new_embeddings: nn.Module): method maybe_static_pad_image_inputs (line 182) | def maybe_static_pad_image_inputs( method get_image_embeddings (line 210) | def get_image_embeddings( method embed_ids_boxes_images (line 289) | def embed_ids_boxes_images( method get_2d_learned_embeddings (line 328) | def get_2d_learned_embeddings( method get_logits (line 369) | def get_logits(self, hidden_states): method forward (line 396) | def forward( method _update_causal_mask (line 510) | def _update_causal_mask( method _prepare_4d_causal_attention_mask_with_cache_position (line 560) | def _prepare_4d_causal_attention_mask_with_cache_position( class SuryaXLAModel (line 632) | class SuryaXLAModel(SuryaModel): method get_image_embeddings (line 633) | def get_image_embeddings( method embed_ids_boxes_images (line 714) | def embed_ids_boxes_images( method get_2d_learned_embeddings (line 765) | def get_2d_learned_embeddings( FILE: surya/common/surya/config.py class SuryaModelConfig (line 9) | class SuryaModelConfig(S3DownloaderMixin, PretrainedConfig): method __init__ (line 13) | def __init__( FILE: surya/common/surya/decoder/__init__.py class Qwen2MLP (line 28) | class Qwen2MLP(nn.Module): method __init__ (line 29) | def __init__(self, config): method forward (line 39) | def forward(self, x): function rotate_half (line 44) | def rotate_half(x): function apply_rotary_pos_emb (line 51) | def apply_rotary_pos_emb(q, k, cos, sin, position_ids=None, unsqueeze_di... function repeat_kv (line 78) | def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor: function eager_attention_forward (line 92) | def eager_attention_forward( class Qwen2Attention (line 122) | class Qwen2Attention(nn.Module): method __init__ (line 125) | def __init__(self, config: SuryaDecoderConfig, layer_idx: int): method forward (line 151) | def forward( class Qwen2RMSNorm (line 246) | class Qwen2RMSNorm(nn.Module): method __init__ (line 247) | def __init__(self, hidden_size, eps=1e-6): method forward (line 255) | def forward(self, hidden_states): method extra_repr (line 262) | def extra_repr(self): class Qwen2DecoderLayer (line 266) | class Qwen2DecoderLayer(nn.Module): method __init__ (line 267) | def __init__(self, config: SuryaDecoderConfig, layer_idx: int): method forward (line 277) | def forward( class Qwen2RotaryEmbedding (line 332) | class Qwen2RotaryEmbedding(nn.Module): method __init__ (line 333) | def __init__(self, config: SuryaDecoderConfig, device=None): method _dynamic_frequency_update (line 352) | def _dynamic_frequency_update(self, position_ids, device): method forward (line 379) | def forward(self, x, position_ids): class Qwen2PreTrainedModel (line 410) | class Qwen2PreTrainedModel(SuryaPreTrainedModel): method _init_weights (line 424) | def _init_weights(self, module): class SuryaDecoderModel (line 436) | class SuryaDecoderModel(Qwen2PreTrainedModel): method __init__ (line 445) | def __init__(self, config: SuryaDecoderConfig): method forward (line 463) | def forward( FILE: surya/common/surya/decoder/config.py class SuryaDecoderConfig (line 8) | class SuryaDecoderConfig(PretrainedConfig): method __init__ (line 28) | def __init__( FILE: surya/common/surya/embedder/__init__.py class SimpleTokenEmbedder (line 6) | class SimpleTokenEmbedder(nn.Module): method __init__ (line 7) | def __init__(self, config): method embed (line 22) | def embed( FILE: surya/common/surya/encoder/__init__.py class Qwen2_5_VLMLP (line 22) | class Qwen2_5_VLMLP(nn.Module): method __init__ (line 23) | def __init__(self, config, bias: bool = False): method forward (line 32) | def forward(self, hidden_state): class Qwen2_5_VisionPatchEmbed (line 38) | class Qwen2_5_VisionPatchEmbed(nn.Module): method __init__ (line 39) | def __init__( method forward (line 61) | def forward(self, hidden_states: torch.Tensor) -> torch.Tensor: class Qwen2_5_VisionRotaryEmbedding (line 77) | class Qwen2_5_VisionRotaryEmbedding(nn.Module): method __init__ (line 78) | def __init__(self, dim: int, theta: float = 10000.0) -> None: method forward (line 84) | def forward(self, seqlen: int) -> torch.Tensor: class Qwen2RMSNorm (line 90) | class Qwen2RMSNorm(nn.Module): method __init__ (line 91) | def __init__(self, hidden_size, eps=1e-6): method forward (line 99) | def forward(self, hidden_states): method extra_repr (line 106) | def extra_repr(self): class Qwen2_5_VLPatchMerger (line 110) | class Qwen2_5_VLPatchMerger(nn.Module): method __init__ (line 111) | def __init__(self, dim: int, context_dim: int, spatial_merge_size: int... method forward (line 121) | def forward(self, x: torch.Tensor) -> torch.Tensor: function apply_rotary_pos_emb_flashatt (line 127) | def apply_rotary_pos_emb_flashatt( class Qwen2_5_VLVisionXLASdpaAttention (line 139) | class Qwen2_5_VLVisionXLASdpaAttention(nn.Module): method __init__ (line 140) | def __init__(self, dim: int, num_heads: int = 16) -> None: method forward (line 147) | def forward( class Qwen2_5_VLVisionXLAFlashAttention2 (line 206) | class Qwen2_5_VLVisionXLAFlashAttention2(nn.Module): method __init__ (line 207) | def __init__(self, dim: int, num_heads: int = 16) -> None: method forward (line 214) | def forward( class Qwen2_5_VLVisionFlashAttention2 (line 266) | class Qwen2_5_VLVisionFlashAttention2(nn.Module): method __init__ (line 267) | def __init__(self, dim: int, num_heads: int = 16) -> None: method forward (line 273) | def forward( function rotate_half (line 318) | def rotate_half(x): function apply_rotary_pos_emb_vision (line 325) | def apply_rotary_pos_emb_vision( class Qwen2_5_VLVisionAttention (line 339) | class Qwen2_5_VLVisionAttention(nn.Module): method __init__ (line 340) | def __init__(self, dim: int, num_heads: int = 16) -> None: method forward (line 347) | def forward( class Qwen2_5_VLVisionSdpaAttention (line 408) | class Qwen2_5_VLVisionSdpaAttention(nn.Module): method __init__ (line 409) | def __init__(self, dim: int, num_heads: int = 16) -> None: method unpack_qkv_with_mask (line 415) | def unpack_qkv_with_mask(self, q, k, v, cu_seqlens): method forward (line 510) | def forward( class Qwen2_5_VLVisionBlock (line 578) | class Qwen2_5_VLVisionBlock(nn.Module): method __init__ (line 579) | def __init__(self, config, attn_implementation: str = "sdpa") -> None: method forward (line 588) | def forward( class Qwen2_5_VLPreTrainedModel (line 622) | class Qwen2_5_VLPreTrainedModel(SuryaPreTrainedModel): method _init_weights (line 633) | def _init_weights(self, module): class Qwen2_5_VisionTransformerPretrainedModel (line 645) | class Qwen2_5_VisionTransformerPretrainedModel(Qwen2_5_VLPreTrainedModel): method __init__ (line 649) | def __init__(self, config, *inputs, **kwargs) -> None: method rot_pos_emb (line 680) | def rot_pos_emb(self, grid_thw): method forward (line 720) | def forward( class SuryaEncoderModel (line 775) | class SuryaEncoderModel(Qwen2_5_VisionTransformerPretrainedModel): method image_size (line 777) | def image_size(self) -> int: method hidden_size (line 789) | def hidden_size(self) -> int: method embed_images (line 793) | def embed_images( FILE: surya/common/surya/encoder/config.py class SuryaEncoderConfig (line 7) | class SuryaEncoderConfig(PretrainedConfig): method __init__ (line 16) | def __init__( FILE: surya/common/surya/flash_attn_utils.py function _get_unpad_data (line 9) | def _get_unpad_data(attention_mask: torch.Tensor) -> tuple[torch.Tensor,... function _upad_input (line 35) | def _upad_input( function flash_attn_prefill (line 106) | def flash_attn_prefill( function flash_attn_decode (line 154) | def flash_attn_decode( FILE: surya/common/surya/processor/__init__.py class SuryaOCRProcessor (line 46) | class SuryaOCRProcessor(S3DownloaderMixin, ProcessorMixin): method __init__ (line 54) | def __init__( method vocab_size (line 145) | def vocab_size(self): method image_processor (line 148) | def image_processor(self, image: Image.Image) -> np.ndarray: method scale_to_fit (line 154) | def scale_to_fit( method _image_processor (line 193) | def _image_processor(self, image: np.ndarray): method _process_and_tile (line 198) | def _process_and_tile( method _process_image_input (line 254) | def _process_image_input(self, image_input: ImageInput) -> ProcessorOu... method _process_text_input (line 281) | def _process_text_input(self, text_input: TextInput, task: str) -> Pro... method _process_input (line 298) | def _process_input(self, input_dict: dict, task: str): method _process_ocr_with_boxes (line 310) | def _process_ocr_with_boxes( method _process_layout (line 356) | def _process_layout(self, mixed_input: List[dict], bos_token_id: int): method _process_table_structure (line 361) | def _process_table_structure(self, mixed_input: List[dict], bos_token_... method _process_ocr_without_boxes (line 366) | def _process_ocr_without_boxes( method _process_block_without_boxes (line 378) | def _process_block_without_boxes( method align_long_axis (line 388) | def align_long_axis(self, image: np.ndarray) -> Tuple[np.ndarray, bool]: method __call__ (line 396) | def __call__( method decode (line 475) | def decode(self, tokens: List[int], task: str): FILE: surya/common/surya/processor/schema.py class TaskDict (line 7) | class TaskDict(TypedDict): class TasksDict (line 12) | class TasksDict(TypedDict): class ProcessorInput (line 18) | class ProcessorInput(TypedDict): class ImageInput (line 22) | class ImageInput(ProcessorInput): class TextInput (line 28) | class TextInput(ProcessorInput): class ProcessorOutput (line 34) | class ProcessorOutput(TypedDict): FILE: surya/common/surya/processor/tokenizer.py function create_token_regex (line 20) | def create_token_regex(tokens): class Qwen2Tokenizer (line 28) | class Qwen2Tokenizer(S3DownloaderMixin, Qwen2OriginalTokenizer): class GreedyMathUTF16Tokenizer (line 31) | class GreedyMathUTF16Tokenizer(S3DownloaderMixin, PreTrainedTokenizer): method _to_utf16_units (line 53) | def _to_utf16_units(s: str) -> List[int]: method _from_utf16_units (line 58) | def _from_utf16_units(units: List[int]) -> str: class _TrieNode (line 64) | class _TrieNode: method __init__ (line 67) | def __init__(self): method _build_trie (line 73) | def _build_trie( method _build_escape_patterns (line 85) | def _build_escape_patterns(self, math_token_to_rawid): method _encode_math_greedy (line 119) | def _encode_math_greedy( method __init__ (line 152) | def __init__( method vocab_size (line 302) | def vocab_size(self) -> int: method get_vocab (line 305) | def get_vocab(self) -> Dict[str, int]: method __len__ (line 311) | def __len__(self) -> int: method _encode_core (line 315) | def _encode_core(self, text: str) -> List[int]: method _fix_latex_escapes (line 346) | def _fix_latex_escapes(self, text: str) -> str: method _decode_core (line 375) | def _decode_core(self, ids: Iterable[int]) -> str: method _tokenize (line 398) | def _tokenize(self, text: str, **kwargs) -> List[str]: method _convert_token_to_id (line 410) | def _convert_token_to_id(self, token: str) -> int: method _convert_id_to_token (line 428) | def _convert_id_to_token(self, index: int) -> str: method convert_tokens_to_string (line 435) | def convert_tokens_to_string(self, tokens: List[str]) -> str: method decode (line 439) | def decode(self, token_ids, skip_special_tokens: bool = False, **kwarg... method build_inputs_with_special_tokens (line 454) | def build_inputs_with_special_tokens( method get_special_tokens_mask (line 466) | def get_special_tokens_mask( method create_token_type_ids_from_sequences (line 481) | def create_token_type_ids_from_sequences( method save_vocabulary (line 491) | def save_vocabulary( class SuryaOCRTokenizer (line 515) | class SuryaOCRTokenizer(S3DownloaderMixin, PreTrainedTokenizer): method __init__ (line 516) | def __init__( method get_vocab (line 538) | def get_vocab(self) -> Dict[str, int]: method _add_tokens (line 541) | def _add_tokens( method vocab_size (line 551) | def vocab_size(self): method _tokenize (line 554) | def _tokenize(self, text: str, **kwargs): method __call__ (line 562) | def __call__( method decode (line 585) | def decode(self, token_ids, **kwargs): FILE: surya/common/surya/schema.py class TaskNames (line 1) | class TaskNames: FILE: surya/common/util.py function clean_boxes (line 11) | def clean_boxes(boxes: List[PolygonBox]) -> List[PolygonBox]: function rescale_bbox (line 41) | def rescale_bbox(bbox, processor_size, image_size): function expand_bbox (line 56) | def expand_bbox(bbox, expansion_factor=0.01): function script_ranges (line 99) | def script_ranges(): function get_top_scripts (line 207) | def get_top_scripts(text: str, max_scripts: int = 5): function is_flash_attn_2_supported (line 223) | def is_flash_attn_2_supported(device: str | torch.device) -> bool: function pad_to_batch_size_repeat (line 247) | def pad_to_batch_size_repeat(tensor: torch.Tensor, batch_size: int): function pad_to_batch_size (line 263) | def pad_to_batch_size(tensor: torch.Tensor, batch_size: int): FILE: surya/common/xla.py function get_nearest_pad (line 10) | def get_nearest_pad( function get_compile_args (line 16) | def get_compile_args(device: str) -> dict: function mark_step (line 25) | def mark_step(): FILE: surya/debug/draw.py function draw_bboxes_on_image (line 7) | def draw_bboxes_on_image( function draw_polys_on_image (line 21) | def draw_polys_on_image( FILE: surya/debug/fonts.py function get_font_path (line 8) | def get_font_path(langs: Optional[List[str]] = None) -> str: FILE: surya/debug/render_html.py function render_text_as_html (line 7) | def render_text_as_html( FILE: surya/debug/text.py function strip_html_tags (line 17) | def strip_html_tags(html_text): function get_text_size (line 24) | def get_text_size(text, font): function render_text (line 31) | def render_text(draw, text, s_bbox, bbox_width, bbox_height, font_path, ... function draw_text_with_playwright (line 47) | def draw_text_with_playwright( function draw_text_on_image (line 71) | def draw_text_on_image( FILE: surya/detection/__init__.py class DetectionPredictor (line 22) | class DetectionPredictor(BasePredictor): method __call__ (line 27) | def __call__( method prepare_image (line 50) | def prepare_image(self, img): method batch_detection (line 64) | def batch_detection( FILE: surya/detection/heatmap.py function get_dynamic_thresholds (line 13) | def get_dynamic_thresholds(linemap, text_threshold, low_text, typical_to... function detect_boxes (line 26) | def detect_boxes(linemap, text_threshold, low_text): function get_detected_boxes (line 113) | def get_detected_boxes(textmap, text_threshold=None, low_text=None) -> L... function get_and_clean_boxes (line 130) | def get_and_clean_boxes( function parallel_get_boxes (line 142) | def parallel_get_boxes(preds, orig_sizes, include_maps=False): FILE: surya/detection/loader.py class DetectionModelLoader (line 16) | class DetectionModelLoader(ModelLoader): method __init__ (line 17) | def __init__(self, checkpoint: Optional[str] = None): method model (line 23) | def model( method processor (line 58) | def processor( FILE: surya/detection/model/config.py class EfficientViTConfig (line 6) | class EfficientViTConfig(S3DownloaderMixin, PretrainedConfig): method __init__ (line 12) | def __init__( FILE: surya/detection/model/encoderdecoder.py function val2list (line 28) | def val2list(x: Union[List, Tuple, Any], repeat_time=1): function val2tuple (line 34) | def val2tuple(x: Union[List, Tuple, Any], min_len: int = 1, idx_repeat: ... function get_same_padding (line 43) | def get_same_padding( function get_padding (line 53) | def get_padding(kernel_size: int, stride: int = 1, dilation: int = 1) ->... class ConvNormAct (line 58) | class ConvNormAct(nn.Module): method __init__ (line 59) | def __init__( method forward (line 90) | def forward(self, x): class DSConv (line 97) | class DSConv(nn.Module): method __init__ (line 98) | def __init__( method forward (line 132) | def forward(self, x): class ConvBlock (line 138) | class ConvBlock(nn.Module): method __init__ (line 139) | def __init__( method forward (line 176) | def forward(self, x): class MBConv (line 182) | class MBConv(nn.Module): method __init__ (line 183) | def __init__( method forward (line 229) | def forward(self, x): class FusedMBConv (line 236) | class FusedMBConv(nn.Module): method __init__ (line 237) | def __init__( method forward (line 275) | def forward(self, x): class LiteMLA (line 281) | class LiteMLA(nn.Module): method __init__ (line 284) | def __init__( method _attn (line 348) | def _attn(self, q, k, v): method forward (line 356) | def forward(self, x): class EfficientVitBlock (line 385) | class EfficientVitBlock(nn.Module): method __init__ (line 386) | def __init__( method forward (line 418) | def forward(self, x): class ResidualBlock (line 424) | class ResidualBlock(nn.Module): method __init__ (line 425) | def __init__( method forward (line 436) | def forward(self, x): function build_local_block (line 443) | def build_local_block( class Stem (line 502) | class Stem(nn.Sequential): method __init__ (line 503) | def __init__( class EfficientVitLargeStage (line 548) | class EfficientVitLargeStage(nn.Module): method __init__ (line 549) | def __init__( method forward (line 614) | def forward(self, x): class EfficientVitLarge (line 618) | class EfficientVitLarge(nn.Module): method __init__ (line 619) | def __init__( method set_grad_checkpointing (line 672) | def set_grad_checkpointing(self, enable=True): method forward (line 675) | def forward(self, x): class EfficientViTPreTrainedModel (line 685) | class EfficientViTPreTrainedModel(SuryaPreTrainedModel): method _init_weights (line 695) | def _init_weights(self, module): class DecodeMLP (line 712) | class DecodeMLP(nn.Module): method __init__ (line 713) | def __init__(self, input_dim, output_dim): method forward (line 717) | def forward(self, hidden_states: torch.Tensor): class DecodeHead (line 725) | class DecodeHead(EfficientViTPreTrainedModel): method __init__ (line 726) | def __init__(self, config: EfficientViTConfig): method forward (line 755) | def forward(self, encoder_hidden_states: torch.FloatTensor) -> torch.T... class EfficientViTForSemanticSegmentation (line 786) | class EfficientViTForSemanticSegmentation( method __init__ (line 789) | def __init__(self, config, **kwargs): method forward (line 797) | def forward( class EfficientViTForSemanticLayoutSegmentation (line 815) | class EfficientViTForSemanticLayoutSegmentation(EfficientViTPreTrainedMo... method __init__ (line 816) | def __init__(self, config, **kwargs): method forward (line 824) | def forward( FILE: surya/detection/parallel.py class FakeFuture (line 1) | class FakeFuture: method __init__ (line 2) | def __init__(self, func, *args, **kwargs): method result (line 5) | def result(self): class FakeExecutor (line 8) | class FakeExecutor: method __init__ (line 9) | def __init__(self, **kwargs): method __enter__ (line 12) | def __enter__(self): method __exit__ (line 15) | def __exit__(self, *excinfo): method submit (line 18) | def submit(self, fn, *args, **kwargs): FILE: surya/detection/processor.py class SegformerImageProcessor (line 42) | class SegformerImageProcessor(S3DownloaderMixin, BaseImageProcessor): method __init__ (line 80) | def __init__( method from_dict (line 131) | def from_dict(cls, image_processor_dict: Dict[str, Any], **kwargs): method _preprocess (line 142) | def _preprocess( method _preprocess_image (line 164) | def _preprocess_image( method __call__ (line 199) | def __call__(self, images, segmentation_maps=None, **kwargs): method preprocess (line 208) | def preprocess( FILE: surya/detection/schema.py class TextDetectionResult (line 8) | class TextDetectionResult(BaseModel): FILE: surya/detection/util.py function get_total_splits (line 7) | def get_total_splits(image_size, height): function split_image (line 16) | def split_image(img, height): FILE: surya/foundation/__init__.py class ContinuousBatchInput (line 35) | class ContinuousBatchInput: class ContinuousBatchOutput (line 47) | class ContinuousBatchOutput: class FoundationPrompt (line 56) | class FoundationPrompt: class FoundationPredictor (line 64) | class FoundationPredictor(BasePredictor): method __init__ (line 106) | def __init__( method to (line 138) | def to(self, device_dtype: torch.device | str | None = None): method get_encoder_chunk_size (line 142) | def get_encoder_chunk_size(self) -> int: method setup_cache (line 152) | def setup_cache(self, batch_size: int, max_cache_len: int, max_sliding... method num_empty_slots (line 166) | def num_empty_slots(self): method num_active_slots (line 170) | def num_active_slots(self): method prepare_input (line 173) | def prepare_input( method process_outputs (line 208) | def process_outputs( method maybe_insert_beacon_tokens (line 243) | def maybe_insert_beacon_tokens( method decode (line 315) | def decode( method pad_and_shift_input_ids_position_ids (line 400) | def pad_and_shift_input_ids_position_ids( method get_cache_position (line 442) | def get_cache_position( method prefill (line 465) | def prefill( method get_max_image_token_count (line 670) | def get_max_image_token_count( method prediction_loop (line 714) | def prediction_loop( FILE: surya/foundation/cache/dynamic_ops.py class DynamicOpsCache (line 16) | class DynamicOpsCache: method __init__ (line 17) | def __init__( method update (line 74) | def update( method update_text_counts (line 92) | def update_text_counts( method prefill_attention_mask_update (line 107) | def prefill_attention_mask_update( method _prefill_update (line 150) | def _prefill_update( method decode_attention_mask_update (line 234) | def decode_attention_mask_update( method _decode_update (line 297) | def _decode_update( method get_seq_length (line 398) | def get_seq_length(self, layer_idx: Optional[int] = 0) -> int: FILE: surya/foundation/cache/static_ops.py class StaticOpsCache (line 18) | class StaticOpsCache(DynamicOpsCache): method __init__ (line 19) | def __init__( method update (line 76) | def update( method _prefill_update (line 94) | def _prefill_update( method decode_attention_mask_update (line 128) | def decode_attention_mask_update( method prefill_attention_mask_update (line 143) | def prefill_attention_mask_update( method _decode_update (line 157) | def _decode_update( method get_seq_length (line 193) | def get_seq_length(self, layer_idx: Optional[int] = 0) -> int: FILE: surya/foundation/loader.py class FoundationModelLoader (line 19) | class FoundationModelLoader(ModelLoader): method __init__ (line 20) | def __init__(self, checkpoint: Optional[str] = None): method model (line 26) | def model( method processor (line 94) | def processor( FILE: surya/foundation/util.py function detect_repeat_token (line 5) | def detect_repeat_token(predicted_tokens: List[int], max_repeats: int = ... function prediction_to_polygon_batch (line 17) | def prediction_to_polygon_batch( FILE: surya/input/load.py function get_name_from_path (line 15) | def get_name_from_path(path): function load_pdf (line 19) | def load_pdf(pdf_path, page_range: List[int] | None = None, dpi=settings... function load_image (line 36) | def load_image(image_path): function load_from_file (line 42) | def load_from_file( function load_from_folder (line 52) | def load_from_folder( function load_lang_file (line 81) | def load_lang_file(lang_path, names): FILE: surya/input/processing.py function convert_if_not_rgb (line 14) | def convert_if_not_rgb(images: List[Image.Image]) -> List[Image.Image]: function open_pdf (line 23) | def open_pdf(pdf_filepath): function get_page_images (line 27) | def get_page_images(doc, indices: List, dpi=settings.IMAGE_DPI): function slice_bboxes_from_image (line 35) | def slice_bboxes_from_image(image: np.ndarray, bboxes): function slice_polys_from_image (line 57) | def slice_polys_from_image(image: np.ndarray, polys): function slice_and_pad_poly (line 64) | def slice_and_pad_poly(image_array: np.array, coordinates): FILE: surya/layout/__init__.py class LayoutPredictor (line 15) | class LayoutPredictor(BasePredictor): method __init__ (line 20) | def __init__(self, foundation_predictor: FoundationPredictor): method disable_tqdm (line 29) | def disable_tqdm(self) -> bool: method disable_tqdm (line 33) | def disable_tqdm(self, value: bool) -> None: method __call__ (line 37) | def __call__( FILE: surya/layout/schema.py class LayoutBox (line 8) | class LayoutBox(PolygonBox): class LayoutResult (line 14) | class LayoutResult(BaseModel): FILE: surya/logging.py function configure_logging (line 6) | def configure_logging(): function get_logger (line 26) | def get_logger(): FILE: surya/models.py function load_predictors (line 18) | def load_predictors( FILE: surya/ocr_error/__init__.py class OCRErrorPredictor (line 14) | class OCRErrorPredictor(BasePredictor): method __call__ (line 19) | def __call__(self, texts: List[str], batch_size: Optional[int] = None): method batch_ocr_error_detection (line 22) | def batch_ocr_error_detection( FILE: surya/ocr_error/loader.py class OCRErrorModelLoader (line 15) | class OCRErrorModelLoader(ModelLoader): method __init__ (line 16) | def __init__(self, checkpoint: Optional[str] = None): method model (line 22) | def model( method processor (line 56) | def processor( FILE: surya/ocr_error/model/config.py class DistilBertConfig (line 14) | class DistilBertConfig(S3DownloaderMixin, PretrainedConfig): method __init__ (line 22) | def __init__( class DistilBertOnnxConfig (line 56) | class DistilBertOnnxConfig(OnnxConfig): method inputs (line 58) | def inputs(self) -> Mapping[str, Mapping[int, str]]: FILE: surya/ocr_error/model/encoder.py function _get_unpad_data (line 28) | def _get_unpad_data(attention_mask): function create_sinusoidal_embeddings (line 40) | def create_sinusoidal_embeddings(n_pos: int, dim: int, out: torch.Tensor): class Embeddings (line 53) | class Embeddings(nn.Module): method __init__ (line 54) | def __init__(self, config: DistilBertConfig): method forward (line 71) | def forward( class MultiHeadSelfAttention (line 113) | class MultiHeadSelfAttention(nn.Module): method __init__ (line 114) | def __init__(self, config: DistilBertConfig): method prune_heads (line 138) | def prune_heads(self, heads: List[int]): method forward (line 154) | def forward( class DistilBertFlashAttention2 (line 225) | class DistilBertFlashAttention2(MultiHeadSelfAttention): method __init__ (line 233) | def __init__(self, *args, **kwargs): method forward (line 241) | def forward( method _flash_attention_forward (line 311) | def _flash_attention_forward( method _upad_input (line 395) | def _upad_input( class FFN (line 443) | class FFN(nn.Module): method __init__ (line 444) | def __init__(self, config: DistilBertConfig): method forward (line 453) | def forward(self, input: torch.Tensor) -> torch.Tensor: method ff_chunk (line 458) | def ff_chunk(self, input: torch.Tensor) -> torch.Tensor: class TransformerBlock (line 472) | class TransformerBlock(nn.Module): method __init__ (line 473) | def __init__(self, config: DistilBertConfig): method forward (line 490) | def forward( class Transformer (line 536) | class Transformer(nn.Module): method __init__ (line 537) | def __init__(self, config: DistilBertConfig): method forward (line 545) | def forward( class DistilBertPreTrainedModel (line 625) | class DistilBertPreTrainedModel(SuryaPreTrainedModel): method _init_weights (line 637) | def _init_weights(self, module: nn.Module): class DistilBertModel (line 660) | class DistilBertModel(DistilBertPreTrainedModel): method __init__ (line 661) | def __init__(self, config: DistilBertConfig): method get_position_embeddings (line 671) | def get_position_embeddings(self) -> nn.Embedding: method resize_position_embeddings (line 677) | def resize_position_embeddings(self, new_num_position_embeddings: int): method get_input_embeddings (line 726) | def get_input_embeddings(self) -> nn.Embedding: method set_input_embeddings (line 729) | def set_input_embeddings(self, new_embeddings: nn.Embedding): method _prune_heads (line 732) | def _prune_heads(self, heads_to_prune: Dict[int, List[List[int]]]): method forward (line 740) | def forward( class DistilBertForSequenceClassification (line 805) | class DistilBertForSequenceClassification(S3DownloaderMixin, DistilBertP... method __init__ (line 806) | def __init__(self, config: DistilBertConfig, **kwargs): method get_position_embeddings (line 819) | def get_position_embeddings(self) -> nn.Embedding: method resize_position_embeddings (line 825) | def resize_position_embeddings(self, new_num_position_embeddings: int): method forward (line 839) | def forward( FILE: surya/ocr_error/schema.py class OCRErrorDetectionResult (line 6) | class OCRErrorDetectionResult(BaseModel): FILE: surya/ocr_error/tokenizer.py function load_vocab (line 17) | def load_vocab(vocab_file): function whitespace_tokenize (line 29) | def whitespace_tokenize(text): class DistilBertTokenizer (line 38) | class DistilBertTokenizer(S3DownloaderMixin, PreTrainedTokenizer): method __init__ (line 83) | def __init__( method do_lower_case (line 131) | def do_lower_case(self): method vocab_size (line 136) | def vocab_size(self): method get_vocab (line 140) | def get_vocab(self): method _tokenize (line 144) | def _tokenize(self, text, split_special_tokens=False): method _convert_token_to_id (line 160) | def _convert_token_to_id(self, token): method _convert_id_to_token (line 165) | def _convert_id_to_token(self, index): method convert_tokens_to_string (line 170) | def convert_tokens_to_string(self, tokens): method build_inputs_with_special_tokens (line 176) | def build_inputs_with_special_tokens( method get_special_tokens_mask (line 202) | def get_special_tokens_mask( method create_token_type_ids_from_sequences (line 231) | def create_token_type_ids_from_sequences( method save_vocabulary (line 261) | def save_vocabulary(self, save_directory: str, filename_prefix: Option... class BasicTokenizer (line 283) | class BasicTokenizer(object): method __init__ (line 306) | def __init__( method tokenize (line 322) | def tokenize(self, text, never_split=None): method _run_strip_accents (line 360) | def _run_strip_accents(self, text): method _run_split_on_punc (line 371) | def _run_split_on_punc(self, text, never_split=None): method _tokenize_chinese_chars (line 393) | def _tokenize_chinese_chars(self, text): method _is_chinese_char (line 406) | def _is_chinese_char(self, cp): method _clean_text (line 430) | def _clean_text(self, text): class WordpieceTokenizer (line 445) | class WordpieceTokenizer(object): method __init__ (line 448) | def __init__(self, vocab, unk_token, max_input_chars_per_word=100): method tokenize (line 453) | def tokenize(self, text): FILE: surya/recognition/__init__.py class RecognitionPredictor (line 40) | class RecognitionPredictor(BasePredictor): method __init__ (line 45) | def __init__(self, foundation_predictor: FoundationPredictor): method disable_tqdm (line 54) | def disable_tqdm(self) -> bool: method disable_tqdm (line 58) | def disable_tqdm(self, value: bool) -> None: method detect_and_slice_bboxes (line 62) | def detect_and_slice_bboxes( method slice_bboxes (line 123) | def slice_bboxes( method get_bboxes_text (line 183) | def get_bboxes_text( method __call__ (line 338) | def __call__( FILE: surya/recognition/postprocessing.py function truncate_repetitions (line 7) | def truncate_repetitions(text: str, min_len=15): function extract_tags (line 38) | def extract_tags(proposed_tags: List[str]) -> List[str]: function cleanup_math (line 55) | def cleanup_math(line: str): function fix_unbalanced_tags (line 74) | def fix_unbalanced_tags( FILE: surya/recognition/schema.py class BaseChar (line 10) | class BaseChar(PolygonBox): method validate_confidence (line 16) | def validate_confidence(cls, v: float) -> float: class TextChar (line 24) | class TextChar(BaseChar): class TextWord (line 28) | class TextWord(BaseChar): class TextLine (line 32) | class TextLine(BaseChar): class OCRResult (line 38) | class OCRResult(BaseModel): FILE: surya/recognition/util.py function unwrap_math (line 13) | def unwrap_math(text: str) -> str: function filter_blacklist_tags (line 34) | def filter_blacklist_tags(text_chars: List[TextChar], tags_to_filter: Li... function clean_math_tags (line 79) | def clean_math_tags(html: str) -> str: function sort_text_lines (line 104) | def sort_text_lines(lines: List[TextLine] | List[dict], tolerance=1.25): function clean_close_polygons (line 132) | def clean_close_polygons(bboxes: List[List[List[int]]], thresh: float = ... function words_from_chars (line 155) | def words_from_chars(chars: List[TextChar], line_box: PolygonBox): FILE: surya/scripts/config.py class CLILoader (line 9) | class CLILoader: method __init__ (line 10) | def __init__(self, filepath: str, cli_options: dict, highres: bool = F... method common_options (line 23) | def common_options(fn): method load (line 31) | def load(self, highres: bool = False): method parse_range_str (line 53) | def parse_range_str(range_str: str) -> List[int]: FILE: surya/scripts/detect_layout.py function detect_layout_cli (line 21) | def detect_layout_cli(input_path: str, **kwargs): FILE: surya/scripts/detect_text.py function detect_text_cli (line 19) | def detect_text_cli(input_path: str, **kwargs): FILE: surya/scripts/finetune_ocr.py class SuryaOCRDataset (line 25) | class SuryaOCRDataset(torch.utils.data.Dataset): method __init__ (line 26) | def __init__(self, processor: SuryaOCRProcessor, data_args: SuryaOCRDa... method __len__ (line 31) | def __len__(self): method get_script_text (line 34) | def get_script_text(self, text: str) -> str: method __getitem__ (line 39) | def __getitem__(self, index): class SuryaOCRDataCollator (line 65) | class SuryaOCRDataCollator: method __init__ (line 66) | def __init__(self, processor: SuryaOCRProcessor, data_args: SuryaOCRDa... method __call__ (line 70) | def __call__(self, inputs): function load_model_and_processor (line 91) | def load_model_and_processor(checkpoint_path: Optional[str] = None) -> T... class SuryaOCRModelArguments (line 96) | class SuryaOCRModelArguments: class SuryaOCRDataArguments (line 100) | class SuryaOCRDataArguments: class SuryaOCRTrainingArguments (line 106) | class SuryaOCRTrainingArguments(TrainingArguments): function main (line 109) | def main(): FILE: surya/scripts/hf_to_s3.py function main (line 25) | def main( FILE: surya/scripts/ocr_latex.py function ocr_latex_cli (line 20) | def ocr_latex_cli(input_path: str, **kwargs): FILE: surya/scripts/ocr_text.py function ocr_text_cli (line 25) | def ocr_text_cli(input_path: str, task_name: str, disable_math: bool, **... FILE: surya/scripts/run_streamlit_app.py function streamlit_app_cli (line 5) | def streamlit_app_cli(): FILE: surya/scripts/run_texify_app.py function texify_app_cli (line 5) | def texify_app_cli(): FILE: surya/scripts/streamlit_app.py function load_predictors_cached (line 24) | def load_predictors_cached(): function ocr_errors (line 28) | def ocr_errors(pdf_file, page_count, sample_len=512, max_samples=10, max... function text_detection (line 61) | def text_detection(img) -> (Image.Image, TextDetectionResult): function layout_detection (line 68) | def layout_detection(img) -> (Image.Image, LayoutResult): function table_recognition (line 80) | def table_recognition( function ocr (line 135) | def ocr( function open_pdf (line 180) | def open_pdf(pdf_file): function get_page_image (line 186) | def get_page_image(pdf_file, page_num, dpi=settings.IMAGE_DPI): function page_counter (line 200) | def page_counter(pdf_file): FILE: surya/scripts/table_recognition.py function table_recognition_cli (line 28) | def table_recognition_cli(input_path: str, skip_table_detection: bool, *... FILE: surya/scripts/texify_app.py function replace_fences (line 28) | def replace_fences(text): function load_predictor (line 36) | def load_predictor(): function inference (line 42) | def inference(pil_image: Image.Image, bbox: List[float]): function open_pdf (line 51) | def open_pdf(pdf_file): function get_page_image (line 57) | def get_page_image(pdf_file, page_num, dpi=settings.IMAGE_DPI_HIGHRES): function page_counter (line 71) | def page_counter(pdf_file): function resize_image (line 78) | def resize_image(pil_image): function get_canvas_hash (line 84) | def get_canvas_hash(pil_image): FILE: surya/settings.py class Settings (line 12) | class Settings(BaseSettings): method TORCH_DEVICE_MODEL (line 34) | def TORCH_DEVICE_MODEL(self) -> str: method DETECTOR_STATIC_CACHE (line 140) | def DETECTOR_STATIC_CACHE(self) -> bool: method LAYOUT_STATIC_CACHE (line 148) | def LAYOUT_STATIC_CACHE(self) -> bool: method FOUNDATION_XLA (line 154) | def FOUNDATION_XLA(self) -> bool: method FOUNDATION_STATIC_CACHE (line 160) | def FOUNDATION_STATIC_CACHE(self) -> bool: method TABLE_REC_STATIC_CACHE (line 168) | def TABLE_REC_STATIC_CACHE(self) -> bool: method OCR_ERROR_STATIC_CACHE (line 176) | def OCR_ERROR_STATIC_CACHE(self) -> bool: method MODEL_DTYPE (line 184) | def MODEL_DTYPE(self) -> torch.dtype: method MODEL_DTYPE_BFLOAT (line 192) | def MODEL_DTYPE_BFLOAT(self) -> torch.dtype: method INFERENCE_MODE (line 200) | def INFERENCE_MODE(self) -> Callable: class Config (line 205) | class Config: FILE: surya/table_rec/__init__.py class TableRecPredictor (line 21) | class TableRecPredictor(BasePredictor): method __call__ (line 31) | def __call__(self, images: List[Image.Image], batch_size: int | None =... method inference_loop (line 34) | def inference_loop( method batch_table_recognition (line 134) | def batch_table_recognition( method decode_batch_predictions (line 239) | def decode_batch_predictions(self, rowcol_predictions, cell_prediction... FILE: surya/table_rec/loader.py class TableRecModelLoader (line 19) | class TableRecModelLoader(ModelLoader): method __init__ (line 20) | def __init__(self, checkpoint: Optional[str] = None): method model (line 26) | def model( method processor (line 77) | def processor( FILE: surya/table_rec/model/config.py class TableRecModelOutput (line 48) | class TableRecModelOutput(ModelOutput): class SuryaTableRecConfig (line 53) | class SuryaTableRecConfig(S3DownloaderMixin, PretrainedConfig): method __init__ (line 57) | def __init__(self, **kwargs): class DonutSwinTableRecConfig (line 81) | class DonutSwinTableRecConfig(PretrainedConfig): method __init__ (line 89) | def __init__( class SuryaTableRecDecoderConfig (line 139) | class SuryaTableRecDecoderConfig(PretrainedConfig): method __init__ (line 142) | def __init__( method layers_block_type (line 234) | def layers_block_type(self): FILE: surya/table_rec/model/decoder.py class LabelEmbedding (line 12) | class LabelEmbedding(nn.Module): method __init__ (line 13) | def __init__(self, config): method forward (line 46) | def forward(self, boxes: torch.LongTensor, *args): class SuryaTableRecDecoder (line 76) | class SuryaTableRecDecoder(SuryaADETRDecoderPreTrainedModel): method __init__ (line 79) | def __init__(self, config, **kwargs): method get_input_embeddings (line 102) | def get_input_embeddings(self): method set_input_embeddings (line 105) | def set_input_embeddings(self, value): method get_output_embeddings (line 108) | def get_output_embeddings(self): method set_output_embeddings (line 111) | def set_output_embeddings(self, new_embeddings): method set_decoder (line 114) | def set_decoder(self, decoder): method get_decoder (line 117) | def get_decoder(self): method forward (line 121) | def forward( FILE: surya/table_rec/model/encoder.py class DonutSwinModel (line 9) | class DonutSwinModel(DonutSwinPreTrainedModel): method __init__ (line 10) | def __init__(self, config, add_pooling_layer=True, use_mask_token=False): method get_input_embeddings (line 26) | def get_input_embeddings(self): method _prune_heads (line 29) | def _prune_heads(self, heads_to_prune): method forward (line 37) | def forward( FILE: surya/table_rec/model/encoderdecoder.py class TableRecOutput (line 15) | class TableRecOutput(ModelOutput): class TableRecEncoderDecoderModel (line 20) | class TableRecEncoderDecoderModel(S3DownloaderMixin, SuryaPreTrainedModel): method __init__ (line 27) | def __init__( method get_encoder (line 56) | def get_encoder(self): method get_decoder (line 59) | def get_decoder(self): method get_output_embeddings (line 62) | def get_output_embeddings(self): method set_output_embeddings (line 65) | def set_output_embeddings(self, new_embeddings): method forward (line 68) | def forward( method resize_token_embeddings (line 101) | def resize_token_embeddings(self, *args, **kwargs): method _reorder_cache (line 107) | def _reorder_cache(self, past_key_values, beam_idx): FILE: surya/table_rec/processor.py class SuryaTableRecProcessor (line 14) | class SuryaTableRecProcessor(S3DownloaderMixin, ProcessorMixin): method __init__ (line 18) | def __init__(self, checkpoint, **kwargs): method resize_polygon (line 29) | def resize_polygon(self, polygon, orig_size, new_size): method __call__ (line 48) | def __call__( FILE: surya/table_rec/schema.py class TableCell (line 8) | class TableCell(PolygonBox): method label (line 21) | def label(self): class TableRow (line 25) | class TableRow(PolygonBox): method label (line 30) | def label(self): class TableCol (line 34) | class TableCol(PolygonBox): method label (line 39) | def label(self): class TableResult (line 43) | class TableResult(BaseModel): FILE: surya/table_rec/shaper.py class LabelShaper (line 8) | class LabelShaper: method __init__ (line 9) | def __init__(self): method dict_to_labels (line 12) | def dict_to_labels(self, label_components: List[dict]): method component_idx (line 54) | def component_idx(self, key): method get_box_property (line 68) | def get_box_property(self, key, add_special_tokens=True): method component_idx_dict (line 77) | def component_idx_dict(self): method convert_polygons_to_bboxes (line 83) | def convert_polygons_to_bboxes(self, label_components: List[Dict]): method convert_bbox_to_polygon (line 114) | def convert_bbox_to_polygon(self, box, skew_scaler=BOX_DIM // 2, skew_... FILE: tests/conftest.py function ocr_error_predictor (line 17) | def ocr_error_predictor() -> OCRErrorPredictor: function layout_predictor (line 24) | def layout_predictor() -> LayoutPredictor: function detection_predictor (line 31) | def detection_predictor() -> DetectionPredictor: function recognition_predictor (line 38) | def recognition_predictor() -> RecognitionPredictor: function table_rec_predictor (line 45) | def table_rec_predictor() -> TableRecPredictor: function test_image (line 52) | def test_image(): function test_image_tall (line 66) | def test_image_tall(): function test_image_latex (line 79) | def test_image_latex(): FILE: tests/test_detection.py function test_detection (line 1) | def test_detection(detection_predictor, test_image): function test_detection_chunking (line 11) | def test_detection_chunking(detection_predictor, test_image_tall): FILE: tests/test_foundation.py function test_foundation_flash2 (line 4) | def test_foundation_flash2(): FILE: tests/test_latex_ocr.py function test_latex_ocr (line 9) | def test_latex_ocr(recognition_predictor, test_image_latex): FILE: tests/test_layout.py function test_layout_topk (line 1) | def test_layout_topk(layout_predictor, test_image): FILE: tests/test_ocr_errors.py function test_garbled_text (line 1) | def test_garbled_text(ocr_error_predictor): function test_good_text (line 10) | def test_good_text(ocr_error_predictor): FILE: tests/test_recognition.py function test_recognition (line 6) | def test_recognition(recognition_predictor, detection_predictor, test_im... function test_recognition_input_text (line 17) | def test_recognition_input_text(recognition_predictor, detection_predict... function test_recognition_drop_repeats (line 41) | def test_recognition_drop_repeats(recognition_predictor, detection_predi... function test_recognition_clean_math (line 55) | def test_recognition_clean_math(): function test_recognition_clean_math_preserve_text (line 63) | def test_recognition_clean_math_preserve_text(): FILE: tests/test_table_rec.py function test_table_rec (line 3) | def test_table_rec(table_rec_predictor): function draw_table (line 23) | def draw_table(data, cell_width=100, cell_height=40):