Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why python script doesn't print to console or can't debug using pdb in Ubuntu #38

Closed
nyanmn opened this issue Feb 7, 2019 · 0 comments

Comments

@nyanmn
Copy link

nyanmn commented Feb 7, 2019

I am looking into the code.

For training lpr, we can use train.py in lpr folder.

train.py uses methods and classes in trainer.py, such as CTCUtils, InputData, inference and LPRVocab.

I put print inside LPRVocab to see how the code works as follows.

class LPRVocab:
  @staticmethod
  def create_vocab(train_list_path, val_list_path, use_h_concat=False, use_oi_concat=False):
    print('create_vocab called ')
    [vocab, r_vocab, num_classes] = LPRVocab._create_standard_vocabs(train_list_path, val_list_path)
    if use_h_concat:
      [vocab, r_vocab, num_classes] = LPRVocab._concat_all_hieroglyphs(vocab, r_vocab)
    if use_oi_concat:
      [vocab, r_vocab, num_classes] = LPRVocab._concat_oi(vocab, r_vocab)

    return vocab, r_vocab, num_classes

  @staticmethod
  def _char_range(char1, char2):
    """Generates the characters from `char1` to `char2`, inclusive."""
    for char_code in range(ord(char1), ord(char2) + 1):
      yield chr(char_code)

  # Function for reading special symbols
  @staticmethod
  def _read_specials(filepath):
    characters = set()
    with open(filepath, 'r') as file_:
      for line in file_:
        current_label = line.split(' ')[-1].strip()
        characters = characters.union(re.findall('(<[^>]*>|.)', current_label))
    return characters

  @staticmethod
  def _create_standard_vocabs(train_list_path, val_list_path):
    print('_create_standard_vocabs called ')
    chars = set().union(LPRVocab._char_range('A', 'Z')).union(LPRVocab._char_range('0', '9'))
    print(chars)
    print('for special characters')
    chars = chars.union(LPRVocab._read_specials(train_list_path)).union(LPRVocab._read_specials(val_list_path))
    print(chars)
    print('for list characters')
    chars = list(chars)
    print(chars)
    print('for sort characters')
    chars.sort()
    print(chars)
    print('for append characters')
    chars.append('_')
    print(chars)    
    num_classes = len(chars)
    print('num_classes '+str(num_classes))
    vocab = dict(zip(chars, range(num_classes)))
    print('vocab ')
    print(vocab)
    r_vocab = dict(zip(range(num_classes), chars))
    r_vocab[-1] = ''
    print('r_vocab ')
    print(r_vocab)
    return [vocab, r_vocab, num_classes]

But I don't see any prints to console.

Then I used

python -m pdb train.py

then set break point inside trainer.py. Break points are never hit. Press Key S also doesn't make to go detail inside another files.

Why debug desn't work and print doesn't print to console? I used python3.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants