refactor: no need to inherit in python3 clean the code (#5659)

### What problem does this PR solve?

As title

### Type of change


- [x] Refactoring

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
This commit is contained in:
yihong 2025-03-05 18:03:53 +08:00 committed by GitHub
parent a64f4539e7
commit 4326873af6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 31 additions and 31 deletions

View File

@ -224,7 +224,7 @@ class TenantLLMService(CommonService):
return list(objs) return list(objs)
class LLMBundle(object): class LLMBundle:
def __init__(self, tenant_id, llm_type, llm_name=None, lang="Chinese"): def __init__(self, tenant_id, llm_type, llm_name=None, lang="Chinese"):
self.tenant_id = tenant_id self.tenant_id = tenant_id
self.llm_type = llm_type self.llm_type = llm_type

View File

@ -1170,7 +1170,7 @@ class RAGFlowPdfParser:
return poss return poss
class PlainParser(object): class PlainParser:
def __call__(self, filename, from_page=0, to_page=100000, **kwargs): def __call__(self, filename, from_page=0, to_page=100000, **kwargs):
self.outlines = [] self.outlines = []
lines = [] lines = []

View File

@ -19,7 +19,7 @@ from io import BytesIO
from pptx import Presentation from pptx import Presentation
class RAGFlowPptParser(object): class RAGFlowPptParser:
def __init__(self): def __init__(self):
super().__init__() super().__init__()

View File

@ -122,7 +122,7 @@ def load_model(model_dir, nm):
return loaded_model return loaded_model
class TextRecognizer(object): class TextRecognizer:
def __init__(self, model_dir): def __init__(self, model_dir):
self.rec_image_shape = [int(v) for v in "3, 48, 320".split(",")] self.rec_image_shape = [int(v) for v in "3, 48, 320".split(",")]
self.rec_batch_num = 16 self.rec_batch_num = 16
@ -393,7 +393,7 @@ class TextRecognizer(object):
return rec_res, time.time() - st return rec_res, time.time() - st
class TextDetector(object): class TextDetector:
def __init__(self, model_dir): def __init__(self, model_dir):
pre_process_list = [{ pre_process_list = [{
'DetResizeForTest': { 'DetResizeForTest': {
@ -506,7 +506,7 @@ class TextDetector(object):
return dt_boxes, time.time() - st return dt_boxes, time.time() - st
class OCR(object): class OCR:
def __init__(self, model_dir=None): def __init__(self, model_dir=None):
""" """
If you have trouble downloading HuggingFace models, -_^ this might help!! If you have trouble downloading HuggingFace models, -_^ this might help!!

View File

@ -23,7 +23,7 @@ import math
from PIL import Image from PIL import Image
class DecodeImage(object): class DecodeImage:
""" decode image """ """ decode image """
def __init__(self, def __init__(self,
@ -65,7 +65,7 @@ class DecodeImage(object):
return data return data
class StandardizeImage(object): class StandardizeImag:
"""normalize image """normalize image
Args: Args:
mean (list): im - mean mean (list): im - mean
@ -102,7 +102,7 @@ class StandardizeImage(object):
return im, im_info return im, im_info
class NormalizeImage(object): class NormalizeImage:
""" normalize image such as subtract mean, divide std """ normalize image such as subtract mean, divide std
""" """
@ -129,7 +129,7 @@ class NormalizeImage(object):
return data return data
class ToCHWImage(object): class ToCHWImage:
""" convert hwc image to chw image """ convert hwc image to chw image
""" """
@ -145,7 +145,7 @@ class ToCHWImage(object):
return data return data
class KeepKeys(object): class KeepKeys:
def __init__(self, keep_keys, **kwargs): def __init__(self, keep_keys, **kwargs):
self.keep_keys = keep_keys self.keep_keys = keep_keys
@ -156,7 +156,7 @@ class KeepKeys(object):
return data_list return data_list
class Pad(object): class Pad:
def __init__(self, size=None, size_div=32, **kwargs): def __init__(self, size=None, size_div=32, **kwargs):
if size is not None and not isinstance(size, (int, list, tuple)): if size is not None and not isinstance(size, (int, list, tuple)):
raise TypeError("Type of target_size is invalid. Now is {}".format( raise TypeError("Type of target_size is invalid. Now is {}".format(
@ -194,7 +194,7 @@ class Pad(object):
return data return data
class LinearResize(object): class LinearResize:
"""resize image by target_size and max_size """resize image by target_size and max_size
Args: Args:
target_size (int): the target size of image target_size (int): the target size of image
@ -261,7 +261,7 @@ class LinearResize(object):
return im_scale_y, im_scale_x return im_scale_y, im_scale_x
class Resize(object): class Resize:
def __init__(self, size=(640, 640), **kwargs): def __init__(self, size=(640, 640), **kwargs):
self.size = size self.size = size
@ -291,7 +291,7 @@ class Resize(object):
return data return data
class DetResizeForTest(object): class DetResizeForTest:
def __init__(self, **kwargs): def __init__(self, **kwargs):
super(DetResizeForTest, self).__init__() super(DetResizeForTest, self).__init__()
self.resize_type = 0 self.resize_type = 0
@ -421,7 +421,7 @@ class DetResizeForTest(object):
return img, [ratio_h, ratio_w] return img, [ratio_h, ratio_w]
class E2EResizeForTest(object): class E2EResizeForTest:
def __init__(self, **kwargs): def __init__(self, **kwargs):
super(E2EResizeForTest, self).__init__() super(E2EResizeForTest, self).__init__()
self.max_side_len = kwargs['max_side_len'] self.max_side_len = kwargs['max_side_len']
@ -489,7 +489,7 @@ class E2EResizeForTest(object):
return im, (ratio_h, ratio_w) return im, (ratio_h, ratio_w)
class KieResize(object): class KieResize:
def __init__(self, **kwargs): def __init__(self, **kwargs):
super(KieResize, self).__init__() super(KieResize, self).__init__()
self.max_side, self.min_side = kwargs['img_scale'][0], kwargs[ self.max_side, self.min_side = kwargs['img_scale'][0], kwargs[
@ -539,7 +539,7 @@ class KieResize(object):
return points return points
class SRResize(object): class SRResize:
def __init__(self, def __init__(self,
imgH=32, imgH=32,
imgW=128, imgW=128,
@ -576,7 +576,7 @@ class SRResize(object):
return data return data
class ResizeNormalize(object): class ResizeNormalize:
def __init__(self, size, interpolation=Image.BICUBIC): def __init__(self, size, interpolation=Image.BICUBIC):
self.size = size self.size = size
self.interpolation = interpolation self.interpolation = interpolation
@ -588,7 +588,7 @@ class ResizeNormalize(object):
return img_numpy return img_numpy
class GrayImageChannelFormat(object): class GrayImageChannelFormat:
""" """
format gray scale image's channel: (3,h,w) -> (1,h,w) format gray scale image's channel: (3,h,w) -> (1,h,w)
Args: Args:
@ -612,7 +612,7 @@ class GrayImageChannelFormat(object):
return data return data
class Permute(object): class Permute:
"""permute image """permute image
Args: Args:
to_bgr (bool): whether convert RGB to BGR to_bgr (bool): whether convert RGB to BGR
@ -635,7 +635,7 @@ class Permute(object):
return im, im_info return im, im_info
class PadStride(object): class PadStride:
""" padding image for model with FPN, instead PadBatch(pad_to_stride) in original config """ padding image for model with FPN, instead PadBatch(pad_to_stride) in original config
Args: Args:
stride (bool): model with FPN need image shape % stride == 0 stride (bool): model with FPN need image shape % stride == 0

View File

@ -38,7 +38,7 @@ def build_post_process(config, global_config=None):
return module_class(**config) return module_class(**config)
class DBPostProcess(object): class DBPostProcess:
""" """
The post process for Differentiable Binarization (DB). The post process for Differentiable Binarization (DB).
""" """
@ -259,7 +259,7 @@ class DBPostProcess(object):
return boxes_batch return boxes_batch
class BaseRecLabelDecode(object): class BaseRecLabelDecode:
""" Convert between text-label and text-index """ """ Convert between text-label and text-index """
def __init__(self, character_dict_path=None, use_space_char=False): def __init__(self, character_dict_path=None, use_space_char=False):

View File

@ -28,7 +28,7 @@ from .operators import preprocess
from . import operators from . import operators
from .ocr import load_model from .ocr import load_model
class Recognizer(object): class Recognizer:
def __init__(self, label_list, task_name, model_dir=None): def __init__(self, label_list, task_name, model_dir=None):
""" """
If you have trouble downloading HuggingFace models, -_^ this might help!! If you have trouble downloading HuggingFace models, -_^ this might help!!

View File

@ -24,7 +24,7 @@ from azure.storage.blob import ContainerClient
@singleton @singleton
class RAGFlowAzureSasBlob(object): class RAGFlowAzureSasBlob:
def __init__(self): def __init__(self):
self.conn = None self.conn = None
self.container_url = os.getenv('CONTAINER_URL', settings.AZURE["container_url"]) self.container_url = os.getenv('CONTAINER_URL', settings.AZURE["container_url"])

View File

@ -24,7 +24,7 @@ from azure.storage.filedatalake import FileSystemClient
@singleton @singleton
class RAGFlowAzureSpnBlob(object): class RAGFlowAzureSpnBlob:
def __init__(self): def __init__(self):
self.conn = None self.conn = None
self.account_url = os.getenv('ACCOUNT_URL', settings.AZURE["account_url"]) self.account_url = os.getenv('ACCOUNT_URL', settings.AZURE["account_url"])

View File

@ -24,7 +24,7 @@ from rag.utils import singleton
@singleton @singleton
class RAGFlowMinio(object): class RAGFlowMinio:
def __init__(self): def __init__(self):
self.conn = None self.conn = None
self.__open__() self.__open__()

View File

@ -24,7 +24,7 @@ from rag import settings
@singleton @singleton
class RAGFlowOSS(object): class RAGFlowOSS:
def __init__(self): def __init__(self):
self.conn = None self.conn = None
self.oss_config = settings.OSS self.oss_config = settings.OSS

View File

@ -23,7 +23,7 @@ from rag.utils import singleton
from rag import settings from rag import settings
@singleton @singleton
class RAGFlowS3(object): class RAGFlowS3:
def __init__(self): def __init__(self):
self.conn = None self.conn = None
self.s3_config = settings.S3 self.s3_config = settings.S3

View File

@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
# #
class Base(object): class Base:
def __init__(self, rag, res_dict): def __init__(self, rag, res_dict):
self.rag = rag self.rag = rag
for k, v in res_dict.items(): for k, v in res_dict.items():