[Python] How to reconstruct an Arabic word from YOLO predictions using class IDs and x-center...

Discussão em 'Python' iniciado por Stack, Julho 3, 2025.

  1. Stack

    Stack Membro Participativo

    I’m using a YOLO model to detect Arabic characters in an image.

    The model gives me two lists after inference:

    • classes: a list of predicted class IDs (each ID corresponds to an Arabic character, e.g. 0 = 'ا', 1 = 'ب', etc.)
    • centers_x: the x-center coordinates of each detected character

    I want to reconstruct the full Arabic word from these predictions from right to left (because Arabic is RTL).
    That means: I should sort the characters by their x_center from highest to lowest, and then map the class ID to the corresponding Arabic letter.

    Example:

    id_to_char = {0: 'ا', 1: 'ب', 2: 'ت'}
    classes = [2, 0, 1]
    centers_x = [300, 250, 100]


    Desired result: 'بتا'

    Continue reading...

Compartilhe esta Página