Fix image shape extraction for proper dimensions
🔧 **Critical Fix**:
1. **Fixed Image Shape Extraction**:
- Proper handling of [B, H, W, C] vs [B, H, W] image formats
- Correct extraction of height and width dimensions
- Should resolve '1024x3' dimension issue
2. **Improved Image Format Handling**:
- Better detection of image tensor dimensions
- Consistent height and width extraction
- Should finally get correct target dimensions
This should resolve the image dimension issue and allow
proper concept map generation with correct target size.
This commit is contained in:
@@ -736,7 +736,11 @@ class ConceptAttentionProcessor:
|
||||
attention_outputs = self.concept_attention.extract_attention_outputs()
|
||||
|
||||
# Create concept maps
|
||||
image_shape = image.shape[-2:] # Get height and width
|
||||
# Handle different image formats: [B, H, W, C] or [B, H, W]
|
||||
if len(image.shape) == 4: # [B, H, W, C]
|
||||
image_shape = image.shape[1:3] # Get height and width
|
||||
else: # [B, H, W]
|
||||
image_shape = image.shape[1:3] # Get height and width
|
||||
concept_maps = self.concept_attention._create_concept_maps_from_attention(
|
||||
concepts, concept_embeddings, image_shape
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user