Pay20Y / SEED

163 stars 39 forks source link

evaluate_with_lexicon #11

Open DYF-AI opened 4 years ago

DYF-AI commented 4 years ago

I changed evaluate_withlexicon:False to True from config.py, the following question “UnboundLocalError: local variable 'embeds' referenced before assignment" appeared, evaluators.py `class Evaluator(BaseEvaluator): def _parse_data(self, inputs): input_dict = {} if global_args.evaluate_with_lexicon: imgs, label_encs, lengths, file_name = inputs else:

imgs, label_encs, lengths = inputs

        imgs, label_encs, lengths, embeds_ = inputs

    with torch.no_grad():
        images = imgs.to(self.device)
        if label_encs is not None:
            labels = label_encs.to(self.device)
        if embeds_ is not None:
            embeds = embeds_.to(self.device)
    input_dict['images'] = images
    input_dict['rec_targets'] = labels
    input_dict['rec_lengths'] = lengths
    input_dict['rec_embeds'] = embeds
    if global_args.evaluate_with_lexicon:
        input_dict['file_name'] = file_name
    return input_dict`

Obviously, filename and embeds cannot exist at the same time, how to solve this problem? Thank you![](url)

Pay20Y commented 4 years ago

I'm sorry, I haven't implemented this part of code yet. I just use another post-processing script to replace the predicted results with the words in the lexicons.

DYF-AI commented 4 years ago

okay, thank you for your outstanding work