Преглед изворни кода

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>
tags/v0.17.1
yihong пре 8 месеци
родитељ
комит
4326873af6
No account linked to committer's email address

+ 1
- 1
api/db/services/llm_service.py Прегледај датотеку

@@ -224,7 +224,7 @@ class TenantLLMService(CommonService):
return list(objs)


class LLMBundle(object):
class LLMBundle:
def __init__(self, tenant_id, llm_type, llm_name=None, lang="Chinese"):
self.tenant_id = tenant_id
self.llm_type = llm_type

+ 1
- 1
deepdoc/parser/pdf_parser.py Прегледај датотеку

@@ -1170,7 +1170,7 @@ class RAGFlowPdfParser:
return poss


class PlainParser(object):
class PlainParser:
def __call__(self, filename, from_page=0, to_page=100000, **kwargs):
self.outlines = []
lines = []

+ 1
- 1
deepdoc/parser/ppt_parser.py Прегледај датотеку

@@ -19,7 +19,7 @@ from io import BytesIO
from pptx import Presentation


class RAGFlowPptParser(object):
class RAGFlowPptParser:
def __init__(self):
super().__init__()


+ 3
- 3
deepdoc/vision/ocr.py Прегледај датотеку

@@ -122,7 +122,7 @@ def load_model(model_dir, nm):
return loaded_model


class TextRecognizer(object):
class TextRecognizer:
def __init__(self, model_dir):
self.rec_image_shape = [int(v) for v in "3, 48, 320".split(",")]
self.rec_batch_num = 16
@@ -393,7 +393,7 @@ class TextRecognizer(object):
return rec_res, time.time() - st


class TextDetector(object):
class TextDetector:
def __init__(self, model_dir):
pre_process_list = [{
'DetResizeForTest': {
@@ -506,7 +506,7 @@ class TextDetector(object):
return dt_boxes, time.time() - st


class OCR(object):
class OCR:
def __init__(self, model_dir=None):
"""
If you have trouble downloading HuggingFace models, -_^ this might help!!

+ 16
- 16
deepdoc/vision/operators.py Прегледај датотеку

@@ -23,7 +23,7 @@ import math
from PIL import Image


class DecodeImage(object):
class DecodeImage:
""" decode image """

def __init__(self,
@@ -65,7 +65,7 @@ class DecodeImage(object):
return data


class StandardizeImage(object):
class StandardizeImag:
"""normalize image
Args:
mean (list): im - mean
@@ -102,7 +102,7 @@ class StandardizeImage(object):
return im, im_info


class NormalizeImage(object):
class NormalizeImage:
""" normalize image such as subtract mean, divide std
"""

@@ -129,7 +129,7 @@ class NormalizeImage(object):
return data


class ToCHWImage(object):
class ToCHWImage:
""" convert hwc image to chw image
"""

@@ -145,7 +145,7 @@ class ToCHWImage(object):
return data


class KeepKeys(object):
class KeepKeys:
def __init__(self, keep_keys, **kwargs):
self.keep_keys = keep_keys

@@ -156,7 +156,7 @@ class KeepKeys(object):
return data_list


class Pad(object):
class Pad:
def __init__(self, size=None, size_div=32, **kwargs):
if size is not None and not isinstance(size, (int, list, tuple)):
raise TypeError("Type of target_size is invalid. Now is {}".format(
@@ -194,7 +194,7 @@ class Pad(object):
return data


class LinearResize(object):
class LinearResize:
"""resize image by target_size and max_size
Args:
target_size (int): the target size of image
@@ -261,7 +261,7 @@ class LinearResize(object):
return im_scale_y, im_scale_x


class Resize(object):
class Resize:
def __init__(self, size=(640, 640), **kwargs):
self.size = size

@@ -291,7 +291,7 @@ class Resize(object):
return data


class DetResizeForTest(object):
class DetResizeForTest:
def __init__(self, **kwargs):
super(DetResizeForTest, self).__init__()
self.resize_type = 0
@@ -421,7 +421,7 @@ class DetResizeForTest(object):
return img, [ratio_h, ratio_w]


class E2EResizeForTest(object):
class E2EResizeForTest:
def __init__(self, **kwargs):
super(E2EResizeForTest, self).__init__()
self.max_side_len = kwargs['max_side_len']
@@ -489,7 +489,7 @@ class E2EResizeForTest(object):
return im, (ratio_h, ratio_w)


class KieResize(object):
class KieResize:
def __init__(self, **kwargs):
super(KieResize, self).__init__()
self.max_side, self.min_side = kwargs['img_scale'][0], kwargs[
@@ -539,7 +539,7 @@ class KieResize(object):
return points


class SRResize(object):
class SRResize:
def __init__(self,
imgH=32,
imgW=128,
@@ -576,7 +576,7 @@ class SRResize(object):
return data


class ResizeNormalize(object):
class ResizeNormalize:
def __init__(self, size, interpolation=Image.BICUBIC):
self.size = size
self.interpolation = interpolation
@@ -588,7 +588,7 @@ class ResizeNormalize(object):
return img_numpy


class GrayImageChannelFormat(object):
class GrayImageChannelFormat:
"""
format gray scale image's channel: (3,h,w) -> (1,h,w)
Args:
@@ -612,7 +612,7 @@ class GrayImageChannelFormat(object):
return data


class Permute(object):
class Permute:
"""permute image
Args:
to_bgr (bool): whether convert RGB to BGR
@@ -635,7 +635,7 @@ class Permute(object):
return im, im_info


class PadStride(object):
class PadStride:
""" padding image for model with FPN, instead PadBatch(pad_to_stride) in original config
Args:
stride (bool): model with FPN need image shape % stride == 0

+ 2
- 2
deepdoc/vision/postprocess.py Прегледај датотеку

@@ -38,7 +38,7 @@ def build_post_process(config, global_config=None):
return module_class(**config)


class DBPostProcess(object):
class DBPostProcess:
"""
The post process for Differentiable Binarization (DB).
"""
@@ -259,7 +259,7 @@ class DBPostProcess(object):
return boxes_batch


class BaseRecLabelDecode(object):
class BaseRecLabelDecode:
""" Convert between text-label and text-index """

def __init__(self, character_dict_path=None, use_space_char=False):

+ 1
- 1
deepdoc/vision/recognizer.py Прегледај датотеку

@@ -28,7 +28,7 @@ from .operators import preprocess
from . import operators
from .ocr import load_model

class Recognizer(object):
class Recognizer:
def __init__(self, label_list, task_name, model_dir=None):
"""
If you have trouble downloading HuggingFace models, -_^ this might help!!

+ 1
- 1
rag/utils/azure_sas_conn.py Прегледај датотеку

@@ -24,7 +24,7 @@ from azure.storage.blob import ContainerClient


@singleton
class RAGFlowAzureSasBlob(object):
class RAGFlowAzureSasBlob:
def __init__(self):
self.conn = None
self.container_url = os.getenv('CONTAINER_URL', settings.AZURE["container_url"])

+ 1
- 1
rag/utils/azure_spn_conn.py Прегледај датотеку

@@ -24,7 +24,7 @@ from azure.storage.filedatalake import FileSystemClient


@singleton
class RAGFlowAzureSpnBlob(object):
class RAGFlowAzureSpnBlob:
def __init__(self):
self.conn = None
self.account_url = os.getenv('ACCOUNT_URL', settings.AZURE["account_url"])

+ 1
- 1
rag/utils/minio_conn.py Прегледај датотеку

@@ -24,7 +24,7 @@ from rag.utils import singleton


@singleton
class RAGFlowMinio(object):
class RAGFlowMinio:
def __init__(self):
self.conn = None
self.__open__()

+ 1
- 1
rag/utils/oss_conn.py Прегледај датотеку

@@ -24,7 +24,7 @@ from rag import settings


@singleton
class RAGFlowOSS(object):
class RAGFlowOSS:
def __init__(self):
self.conn = None
self.oss_config = settings.OSS

+ 1
- 1
rag/utils/s3_conn.py Прегледај датотеку

@@ -23,7 +23,7 @@ from rag.utils import singleton
from rag import settings

@singleton
class RAGFlowS3(object):
class RAGFlowS3:
def __init__(self):
self.conn = None
self.s3_config = settings.S3

+ 1
- 1
sdk/python/ragflow_sdk/modules/base.py Прегледај датотеку

@@ -14,7 +14,7 @@
# limitations under the License.
#

class Base(object):
class Base:
def __init__(self, rag, res_dict):
self.rag = rag
for k, v in res_dict.items():

Loading…
Откажи
Сачувај