Update modeling_prismatic.py
Browse files- modeling_prismatic.py +8 -1
modeling_prismatic.py
CHANGED
@@ -581,7 +581,14 @@ class OpenVLAForActionPrediction(PrismaticForConditionalGeneration):
|
|
581 |
generated_ids = self.generate(input_ids, **kwargs)
|
582 |
# VLLM inference
|
583 |
# Extract predicted action tokens and translate into (normalized) continuous actions
|
584 |
-
predicted_action_token_ids = generated_ids[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
585 |
discretized_actions = self.vocab_size - predicted_action_token_ids
|
586 |
discretized_actions = np.clip(discretized_actions - 1, a_min=0, a_max=self.bin_centers.shape[0] - 1)
|
587 |
normalized_actions = self.bin_centers[discretized_actions]
|
|
|
581 |
generated_ids = self.generate(input_ids, **kwargs)
|
582 |
# VLLM inference
|
583 |
# Extract predicted action tokens and translate into (normalized) continuous actions
|
584 |
+
# predicted_action_token_ids = generated_ids[-1, -(self.get_action_dim(unnorm_key) + 1) : -1].cpu().numpy()
|
585 |
+
# Get the last row of generated_ids
|
586 |
+
last_row = generated_ids[-1]
|
587 |
+
|
588 |
+
# Remove padding tokens (assuming pad token id is 32000)
|
589 |
+
non_pad_tokens = last_row[last_row != 32000]
|
590 |
+
# Take the last 7 tokens from the filtered tokens
|
591 |
+
predicted_action_token_ids = non_pad_tokens[-(self.get_action_dim(unnorm_key) + 1) : -1].cpu().numpy()
|
592 |
discretized_actions = self.vocab_size - predicted_action_token_ids
|
593 |
discretized_actions = np.clip(discretized_actions - 1, a_min=0, a_max=self.bin_centers.shape[0] - 1)
|
594 |
normalized_actions = self.bin_centers[discretized_actions]
|