Update quality tooling for formatting (#21480)
* Result of black 23.1 * Update target to Python 3.7 * Switch flake8 to ruff * Configure isort * Configure isort * Apply isort with line limit * Put the right black version * adapt black in check copies * Fix copies
This commit is contained in:
@@ -24,9 +24,8 @@ import warnings
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union
|
||||
|
||||
from numpy import isin
|
||||
|
||||
from huggingface_hub import model_info
|
||||
from numpy import isin
|
||||
|
||||
from ..configuration_utils import PretrainedConfig
|
||||
from ..dynamic_module_utils import get_class_from_dynamic_module
|
||||
|
||||
@@ -15,7 +15,6 @@ import subprocess
|
||||
from typing import Union
|
||||
|
||||
import numpy as np
|
||||
|
||||
import requests
|
||||
|
||||
from ..utils import add_end_docstrings, is_torch_available, logging
|
||||
|
||||
@@ -15,7 +15,6 @@ from collections import defaultdict
|
||||
from typing import TYPE_CHECKING, Dict, Optional, Union
|
||||
|
||||
import numpy as np
|
||||
|
||||
import requests
|
||||
|
||||
from ..utils import is_torch_available, logging
|
||||
@@ -302,7 +301,7 @@ class AutomaticSpeechRecognitionPipeline(ChunkPipeline):
|
||||
feature_extractor: Union["SequenceFeatureExtractor", str],
|
||||
*,
|
||||
decoder: Optional[Union["BeamSearchDecoderCTC", str]] = None,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
):
|
||||
super().__init__(**kwargs)
|
||||
self.feature_extractor = feature_extractor
|
||||
|
||||
@@ -165,7 +165,6 @@ class ImageSegmentationPipeline(Pipeline):
|
||||
def postprocess(
|
||||
self, model_outputs, subtask=None, threshold=0.9, mask_threshold=0.5, overlap_mask_area_threshold=0.5
|
||||
):
|
||||
|
||||
fn = None
|
||||
if subtask in {"panoptic", None} and hasattr(self.image_processor, "post_process_panoptic_segmentation"):
|
||||
fn = self.image_processor.post_process_panoptic_segmentation
|
||||
|
||||
@@ -307,7 +307,7 @@ class QuestionAnsweringPipeline(ChunkPipeline):
|
||||
max_question_len=None,
|
||||
handle_impossible_answer=None,
|
||||
align_to_words=None,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
):
|
||||
# Set defaults values
|
||||
preprocess_params = {}
|
||||
|
||||
@@ -23,7 +23,6 @@ if is_torch_available():
|
||||
|
||||
if is_tf_available() and is_tensorflow_probability_available():
|
||||
import tensorflow as tf
|
||||
|
||||
import tensorflow_probability as tfp
|
||||
|
||||
from ..models.auto.modeling_tf_auto import (
|
||||
|
||||
@@ -78,7 +78,7 @@ class Text2TextGenerationPipeline(Pipeline):
|
||||
clean_up_tokenization_spaces=None,
|
||||
truncation=None,
|
||||
stop_sequence=None,
|
||||
**generate_kwargs
|
||||
**generate_kwargs,
|
||||
):
|
||||
preprocess_params = {}
|
||||
if truncation is not None:
|
||||
|
||||
@@ -97,7 +97,7 @@ class TextGenerationPipeline(Pipeline):
|
||||
prefix=None,
|
||||
handle_long_generation=None,
|
||||
stop_sequence=None,
|
||||
**generate_kwargs
|
||||
**generate_kwargs,
|
||||
):
|
||||
preprocess_params = {}
|
||||
if prefix is not None:
|
||||
|
||||
@@ -22,7 +22,6 @@ class TokenClassificationArgumentHandler(ArgumentHandler):
|
||||
"""
|
||||
|
||||
def __call__(self, inputs: Union[str, List[str]], **kwargs):
|
||||
|
||||
if inputs is not None and isinstance(inputs, (list, tuple)) and len(inputs) > 0:
|
||||
inputs = list(inputs)
|
||||
batch_size = len(inputs)
|
||||
@@ -141,7 +140,6 @@ class TokenClassificationPipeline(Pipeline):
|
||||
aggregation_strategy: Optional[AggregationStrategy] = None,
|
||||
offset_mapping: Optional[List[Tuple[int, int]]] = None,
|
||||
):
|
||||
|
||||
preprocess_params = {}
|
||||
if offset_mapping is not None:
|
||||
preprocess_params["offset_mapping"] = offset_mapping
|
||||
|
||||
@@ -9,7 +9,6 @@ from .base import PIPELINE_INIT_ARGS, Pipeline
|
||||
|
||||
if is_decord_available():
|
||||
import numpy as np
|
||||
|
||||
from decord import VideoReader
|
||||
|
||||
|
||||
@@ -85,7 +84,6 @@ class VideoClassificationPipeline(Pipeline):
|
||||
return super().__call__(videos, **kwargs)
|
||||
|
||||
def preprocess(self, video, num_frames=None, frame_sampling_rate=1):
|
||||
|
||||
if num_frames is None:
|
||||
num_frames = self.model.config.num_frames
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ class ZeroShotObjectDetectionPipeline(ChunkPipeline):
|
||||
self,
|
||||
image: Union[str, "Image.Image", List[Dict[str, Any]]],
|
||||
candidate_labels: Union[str, List[str]] = None,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
):
|
||||
"""
|
||||
Detect objects (bounding boxes & classes) in the image(s) passed as inputs.
|
||||
@@ -168,7 +168,6 @@ class ZeroShotObjectDetectionPipeline(ChunkPipeline):
|
||||
return model_outputs
|
||||
|
||||
def postprocess(self, model_outputs, threshold=0.1, top_k=None):
|
||||
|
||||
results = []
|
||||
for model_output in model_outputs:
|
||||
label = model_output["candidate_label"]
|
||||
|
||||
Reference in New Issue
Block a user