|
50 | 50 | validate_annotations, |
51 | 51 | ) |
52 | 52 | from ...processing_utils import ImagesKwargs, Unpack |
53 | | -from ...utils import TensorType, auto_docstring, is_torch_available, is_vision_available, logging, requires_backends |
| 53 | +from ...utils import TensorType, auto_docstring, is_torch_available, is_vision_available, logging |
54 | 54 | from ...utils.import_utils import requires |
55 | 55 |
|
56 | 56 |
|
@@ -862,7 +862,6 @@ def post_process_object_detection( |
862 | 862 | `list[Dict]`: A list of dictionaries, each dictionary containing the scores, labels and boxes for an image |
863 | 863 | in the batch as predicted by the model. |
864 | 864 | """ |
865 | | - requires_backends(self, ["torch"]) |
866 | 865 | out_logits, out_bbox = outputs.logits, outputs.pred_boxes |
867 | 866 |
|
868 | 867 | if target_sizes is not None: |
@@ -929,7 +928,6 @@ def post_process_semantic_segmentation( |
929 | 928 | `(height, width)`) and `segmentation_scores` (shape `(num_classes, height, width)`). In both cases, |
930 | 929 | `(height, width)` corresponds to the target size (if `target_sizes` is specified). |
931 | 930 | """ |
932 | | - requires_backends(self, ["torch"]) |
933 | 931 | class_queries_logits = outputs.logits # [batch_size, num_queries, num_classes] |
934 | 932 | masks_queries_logits = outputs.pred_masks # [batch_size, num_queries, height, width] |
935 | 933 |
|
@@ -1012,11 +1010,6 @@ def post_process_instance_segmentation( |
1012 | 1010 | - **label_id** -- An integer representing the label / semantic class id corresponding to `segment_id`. |
1013 | 1011 | - **score** -- Prediction score of segment with `segment_id`. |
1014 | 1012 | """ |
1015 | | - if not is_torch_available(): |
1016 | | - raise ImportError("PyTorch is required for post-processing.") |
1017 | | - import torch |
1018 | | - from torch import nn |
1019 | | - |
1020 | 1013 | class_queries_logits = outputs.logits # [batch_size, num_queries, num_classes+1] |
1021 | 1014 | masks_queries_logits = outputs.pred_masks # [batch_size, num_queries, height, width] |
1022 | 1015 |
|
@@ -1110,11 +1103,6 @@ def post_process_panoptic_segmentation( |
1110 | 1103 | logger.warning_once("`label_ids_to_fuse` unset. No instance will be fused.") |
1111 | 1104 | label_ids_to_fuse = set() |
1112 | 1105 |
|
1113 | | - if not is_torch_available(): |
1114 | | - raise ImportError("PyTorch is required for post-processing.") |
1115 | | - import torch |
1116 | | - from torch import nn |
1117 | | - |
1118 | 1106 | class_queries_logits = outputs.logits # [batch_size, num_queries, num_classes+1] |
1119 | 1107 | masks_queries_logits = outputs.pred_masks # [batch_size, num_queries, height, width] |
1120 | 1108 |
|
|
0 commit comments