Skip to content

Conversation

tomas-gajarsky
Copy link
Owner

Update PostArgMax.run to accept and process tuple inputs, resolving a TypeError.

The TypeError occurred because PostArgMax.run expected a torch.Tensor but could receive a Tuple[torch.Tensor] from some models, while its abstract method and other post-processors already handled tuples. This change adds the necessary tuple unpacking to ensure consistency and prevent the error.


Open in Cursor Open in Web

Learn more about Cursor Agents

@tomas-gajarsky tomas-gajarsky marked this pull request as ready for review August 1, 2025 16:54
cursoragent and others added 4 commits August 1, 2025 16:54
- Remove non-working paperswithcode badges from all model sections
- Clean up README formatting for better readability
- Badges were causing display issues and not functioning properly
- Remove trailing whitespace from blank line in PostArgMax.run()
- Resolves W293 blank line contains whitespace error
- Increment patch version from 0.6.0 to 0.6.1
- Add CHANGELOG entry for PostArgMax tuple handling fix
- Document README badge removal and linting fixes
@tomas-gajarsky tomas-gajarsky requested a review from Copilot August 1, 2025 23:51
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a TypeError in the PostArgMax.run method that occurred when the method received tuple inputs instead of tensor inputs. The fix adds tuple handling to maintain consistency with other post-processors and the abstract method signature.

  • Updated PostArgMax.run to accept Union[torch.Tensor, Tuple[torch.Tensor]] and unpack tuples
  • Bumped version from 0.6.0 to 0.6.1
  • Cleaned up README by removing non-working paperswithcode badges

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
facetorch/analyzer/predictor/post.py Added tuple input handling to PostArgMax.run method
version Version bump to 0.6.1
CHANGELOG.md Added changelog entry for v0.6.1 with bug fix details
README.md Removed non-working paperswithcode badges for cleaner documentation


Returns:
List[Prediction]: List of prediction data structures containing the predicted labels and confidence scores for each face in the batch.
"""
if isinstance(preds, tuple):
Copy link
Preview

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a check for empty tuples to prevent potential IndexError when accessing preds[0]. An empty tuple would cause the next line to fail.

Suggested change
if isinstance(preds, tuple):
if isinstance(preds, tuple):
if len(preds) == 0:
# Handle empty tuple gracefully, e.g., return empty list
return []

Copilot uses AI. Check for mistakes.

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

Successfully merging this pull request may close these issues.

2 participants