Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

How can I get noun scores and verb scores? #42

Open
anamanzano opened this issue Aug 18, 2023 · 1 comment
Open

How can I get noun scores and verb scores? #42

anamanzano opened this issue Aug 18, 2023 · 1 comment

Comments

@anamanzano
Copy link

Hi! So I was wondering if it's possible to get verb scores and noun scores from the action recognition scores. I was using margin probability to obtain the results, but I don't get anything that makes sense. Maybe I have to normalize the results? Or is something that I can not get from action scores?
Thank you!

@anamanzano
Copy link
Author

Does this code make sense?

 with torch.no_grad():
       prediction = model(video_input.to(device), input_type="video")

       # Get the predicted classes (action scores)
       pred_class_all = prediction.topk(k=3806)
       class_indices = pred_class_all.indices
       class_scores = pred_class_all.values


   pred_class_names_all = []
   for indices, score in zip(class_indices[0], class_scores[0]):
       pred_class_names_all.append((epic_id_to_action[int(indices)], score))

   verbs = []
   nouns = []
   verb_scores = []
   noun_scores = []
   dic_verbs = {}
   dic_nouns = {}
   
   for pred, score in pred_class_names_all:
       verb, noun = pred.split()
       verbs.append(verb)
       nouns.append(noun)
       verb_scores.append(score)
       noun_scores.append(score)
     
   # Split the predictions into verbs and nouns and store in separate dictionaries
   verb_scores_dict = {}
   noun_scores_dict = {}
   
   for pred, score in pred_class_names_all:
       verb, noun = pred.split()
       
       if verb in verb_scores_dict:
         verb_scores_dict[verb] += score
       else:
         verb_scores_dict[verb] = score
       
       if noun in noun_scores_dict:
         noun_scores_dict[noun] += score
       else:
         noun_scores_dict[noun] = score

Thank you!

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

No branches or pull requests

1 participant