@@ -186,17 +186,18 @@ def _prepocess_inputs(
186
186
The preprocessed input tensor flattened along the spatial dimensions.
187
187
"""
188
188
# flatten the spatial dimensions of the input tensor, e.g., (B, H, W, C) -> (B, H*W, C).
189
- inputs = torch .flatten (inputs , 1 , - 2 )
190
- mask_stuffs = _isin (inputs [:, :, 0 ], list (stuffs ))
191
- mask_things = _isin (inputs [:, :, 0 ], list (things ))
189
+ out = inputs .detach ().clone ()
190
+ out = torch .flatten (out , 1 , - 2 )
191
+ mask_stuffs = _isin (out [:, :, 0 ], list (stuffs ))
192
+ mask_things = _isin (out [:, :, 0 ], list (things ))
192
193
# reset instance IDs of stuffs
193
194
mask_stuffs_instance = torch .stack ([torch .zeros_like (mask_stuffs ), mask_stuffs ], dim = - 1 )
194
- inputs [mask_stuffs_instance ] = 0
195
+ out [mask_stuffs_instance ] = 0
195
196
if not allow_unknown_category and not torch .all (mask_things | mask_stuffs ):
196
- raise ValueError ("Unknown categories found. " )
197
+ raise ValueError (f "Unknown categories found: { out [ ~ ( mask_things | mask_stuffs )] } " )
197
198
# set unknown categories to void color
198
- inputs [~ (mask_things | mask_stuffs )] = inputs .new (void_color )
199
- return inputs
199
+ out [~ (mask_things | mask_stuffs )] = out .new (void_color )
200
+ return out
200
201
201
202
202
203
def _panoptic_quality_update_sample (
0 commit comments