如何构建用于从收据中提取信息的生成式人工智能工具

原文地址:how-to-build-a-generative-ai-tool-for-information-extraction-from-receipts

使用 LangChain 和 OpenAI 工具从 Google Drive 中存储的收据图像中提取结构化信息

2024 年 4 月 10 日

纸质收据有各种样式和格式,是自动信息提取的一个有趣目标。纸质收据还提供了大量的分项费用,如果将这些费用汇总到数据库中,对于任何有兴趣追踪比银行对账单更详细的消费情况的人来说都非常有用。

如果你能拍一张收据照片,上传到某个应用程序,然后提取其中的信息并将其添加到你的个人支出数据库中,再用自然语言进行查询,那岂不是很酷?然后你就可以对这些数据提出问题,比如 "我上次去宜家买了什么?"或者 "我在 Safeway 花的钱最多的是什么商品"。这样的系统还可以自然而然地扩展到企业财务和支出跟踪。在本文中,我们将构建一个简单的应用程序来处理这一过程的第一部分--即从收据中提取信息并存储到数据库中。我们的系统将监控 Google Drive 文件夹中的新收据,处理它们并将结果附加到 .csv 文件中。

1. 背景和动机

从技术上讲,我们要做的是一种称为模板填充的自动信息提取。我们有一个预定义的字段模式,我们想从收据中提取这些字段,任务就是填写这些字段,或者在适当的地方留空。这里的一个主要问题是,收据的图像或扫描件中包含的信息是非结构化的,虽然光学字符识别 (OCR) 或 PDF 文本提取库在查找文本方面可能做得不错,但它们不能很好地保存单词在文档中的相对位置,例如,这可能会导致很难将物品的价格与成本相匹配。

传统上,这个问题是通过模板匹配来解决的,即创建一个预定义的文档几何模板,然后只在已知包含重要信息的区域进行提取。

为了解决这个问题,AWS Textract 和 AWS Rekognition 等更先进的服务结合使用预先训练好的深度学习模型来进行对象检测、边界框生成和命名实体识别(NER)。我还没有就手头的问题实际试用过这些服务,但如果能将其结果与我们使用 OpenAI 的 LLM构建的结果进行比较,那将会非常有趣。

大型语言模型(LLM),如 gpt-3.5-turbo,也非常擅长从非结构化文本中提取信息和填充模板,尤其是在提示中给出一些示例之后。这使得它们比模板匹配或微调灵活得多,因为添加几个新收据格式的示例比重新训练模型或构建一个新的几何模板要快得多,也便宜得多。

如果我们要在从收据中提取的文本上使用 gpt-3.5-turbo,那么问题就来了,我们该如何构建收据学习的示例呢?我们当然可以手动完成这项工作,但这并不能很好地扩展。在这里,我们将探索使用 gpt-4-vision 来实现这一目标。这个版本的 gpt-4 可以处理包含图像的对话,而且似乎特别擅长描述图像的内容。因此,如果给定一张收据图像和我们想要提取的关键信息的描述,只要图像足够清晰,gpt-4-vision 就能一气呵成。

2. 连接到谷歌硬盘

我们需要一个方便的地方来存储原始收据数据。Google Drive 是一个不错的选择,它提供了一个 Python API,使用起来相对简单。我使用 GeniusScan 应用程序捕获收据,它可以将 .pdf、.jpeg 或其他文件类型从手机直接上传到 Google Drive 文件夹。该应用还能进行一些有用的预处理,如自动裁剪文件,这有助于提取过程。

要设置对 Google Drive 的 API 访问,你需要创建服务帐户凭据,可按照此处的说明生成。作为参考,我在驱动器中创建了一个名为 "receiptchat "的文件夹,并设置了一个密钥对,以便从该文件夹中读取数据。

以下代码可用于设置驱动器服务对象,该对象可让你使用各种方法查询 Google Drive

import os
from googleapiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials
class GoogleDriveService:
    SCOPES = ["https://www.googleapis.com/auth/drive"]
    def __init__(self):
        # the directory where your credentials are stored
        base_path = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
        
        # The name of the file containing your credentials
        credential_path = os.path.join(base_path, "gdrive_credential.json")
        os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = credential_path
    def build(self):
        
        # Get credentials into the desired format
        creds = ServiceAccountCredentials.from_json_keyfile_name(
            os.getenv("GOOGLE_APPLICATION_CREDENTIALS"), self.SCOPES
        )  
        
        # Set up the Gdrive service object
        service = build("drive", "v3", credentials=creds, cache_discovery=False)
        return service

在我们的简单应用程序中,我们只需要做两件事: 列出驱动器文件夹中的所有文件并下载其中的一些文件。下面的类可以处理这些工作:

import io
from googleapiclient.errors import HttpError
from googleapiclient.http import MediaIoBaseDownload
import googleapiclient.discovery
from typing import List
class GoogleDriveLoader:
    # These are the types of files we want to download
    VALID_EXTENSIONS = [".pdf", ".jpeg"]
    def __init__(self, service: googleapiclient.discovery.Resource):
        self.service = service
    def search_for_files(self) -> List:
        """
        See https://developers.google.com/drive/api/guides/search-files#python
        """
      
        # This query searches for objects that are not folders and 
        # contain the valid extensions
        query = "mimeType != 'application/vnd.google-apps.folder' and ("
        for i, ext in enumerate(self.VALID_EXTENSIONS):
            if i == 0:
                query += "name contains '{}' ".format(ext)
            else:
                query += "or name contains '{}' ".format(ext)
        query = query.rstrip()
        query += ")"
        # create drive api client
        files = []
        page_token = None
        try:
            while True:
                response = (
                    self.service.files()
                    .list(
                        q=query,
                        spaces="drive",
                        fields="nextPageToken, files(id, name)",
                        pageToken=page_token,
                    )
                    .execute()
                )
                for file in response.get("files"):
                    # Process change
                    print(f'Found file: {file.get("name")}, {file.get("id")}')
                    file_id = file.get("id")
                    file_name = file.get("name")
                    files.append(
                        {
                            "id": file_id,
                            "name": file_name,
                        }
                    )
                page_token = response.get("nextPageToken", None)
                if page_token is None:
                    break
        except HttpError as error:
            print(f"An error occurred: {error}")
            files = None
        return files
    def download_file(self, real_file_id: str) -> bytes:
        """
        Downloads a single file
        """
        try:
            file_id = real_file_id
            request = self.service.files().get_media(fileId=file_id)
            file = io.BytesIO()
            downloader = MediaIoBaseDownload(file, request)
            done = False
            while done is False:
                status, done = downloader.next_chunk()
                print(f"Download {int(status.progress() * 100)}.")
        except HttpError as error:
            print(f"An error occurred: {error}")
            file = None
        return file.getvalue()

运行后结果如下:

service = GoogleDriveService().build()
loader = GoogleDriveLoader(service)
all_files loader.search_for_files() #returns a list of unqiue file ids and names 
pdf_bytes = loader.download_file({some_id}) #returns bytes for that file

现在我们可以连接 Google Drive,将图片或 pdf 数据导入本地计算机。接下来,我们必须对其进行处理并提取文本。

3. 从 .pdf 和图像中提取原始文本

有多个文档齐全的开源库可以从 pdf 和图像中提取原始文本。对于 pdf,我们将在此使用 PyPDF,如果想更全面地了解类似的软件包。对于 jpeg 格式的图像,我们将使用 pytesseract,它是 tesseract OCR 引擎的封装程序。安装说明请点击此处。最后,我们还希望能将 pdf 转换成 jpeg 格式。这可以通过 pdf2image 软件包来实现。

PyPDF 和 pytesseract 都提供了从文档中提取文本的高级方法。例如,pytesseract 可以同时提取文本和边界框(见此处),如果我们将来想向 LLM 提供更多关于其处理的文本的收据格式的信息,这可能会很有用。pdf2image 提供了一种将 pdf 字节转换为 jpeg 图像的方法,而这正是我们要做的。要将 jpeg 字节转换为可视化图像,我们将使用 PIL 软件包。

from abc import ABC, abstractmethod
from pdf2image import convert_from_bytes
import numpy as np
from PyPDF2 import PdfReader
from PIL import Image
import pytesseract
import io
DEFAULT_DPI = 50
class FileBytesToImage(ABC):
    @staticmethod
    @abstractmethod
    def convert_bytes_to_jpeg(file_bytes):
        raise NotImplementedError
    @staticmethod
    @abstractmethod
    def convert_bytes_to_text(file_bytes):
        raise NotImplementedError
class PDFBytesToImage(FileBytesToImage):
    @staticmethod
    def convert_bytes_to_jpeg(file_bytes, dpi=DEFAULT_DPI, return_array=False):
        jpeg_data = convert_from_bytes(file_bytes, fmt="jpeg", dpi=dpi)[0]
        if return_array:
            jpeg_data = np.asarray(jpeg_data)
        return jpeg_data
    @staticmethod
    def convert_bytes_to_text(file_bytes):
        pdf_data = PdfReader(
            stream=io.BytesIO(initial_bytes=file_bytes) 
        )
        # receipt data should only have one page
        page = pdf_data.pages[0]
        return page.extract_text()
class JpegBytesToImage(FileBytesToImage):
    @staticmethod
    def convert_bytes_to_jpeg(file_bytes, dpi=DEFAULT_DPI, return_array=False):
        jpeg_data = Image.open(io.BytesIO(file_bytes))
        if return_array:
            jpeg_data = np.array(jpeg_data)
        return jpeg_data
    @staticmethod
    def convert_bytes_to_text(file_bytes):
        jpeg_data = Image.open(io.BytesIO(file_bytes))
        text_data = pytesseract.image_to_string(image=jpeg_data, nice=1)
        return text_data

上面的代码使用了抽象基类的概念来提高可扩展性。假设我们将来想添加对另一种文件类型的支持。如果我们编写关联类并从 FileBytesToImage 继承,我们就不得不在其中编写 convert_bytes_too_image 和 convert_bytes_too_text 方法。这样,在大型应用程序中,我们的类就不太可能在下游引入错误。

代码的使用方法如下:

bytes_to_image = PDFBytesToImage()
image = PDFBytesToImage.convert_bytes_to_jpeg(pdf_bytes)
text = PDFBytesToImage.convert_bytes_to_jpeg(pdf_bytes)

5

4. 使用 gpt-4-vision 提取信息

现在,让我们使用 Langchain 来促使 gpt-4-vision 从我们的收据中提取一些信息。首先,我们可以使用 Langchain 对 Pydantic 的支持为输出创建一个模型。

from langchain_core.pydantic_v1 import BaseModel, Field
from typing import List
class ReceiptItem(BaseModel):
    """Information about a single item on a reciept"""
    item_name: str = Field("The name of the purchased item")
    item_cost: str = Field("The cost of the item")
class ReceiptInformation(BaseModel):
    """Information extracted from a receipt"""
    vendor_name: str = Field(
        description="The name of the company who issued the reciept"
    )
    vendor_address: str = Field(
        description="The street address of the company who issued the reciept"
    )
    datetime: str = Field(
        description="The date and time that the receipt was printed in MM/DD/YY HH:MM format"
    )
    items_purchased: List[ReceiptItem] = Field(description="List of purchased items")
    subtotal: str = Field(description="The total cost before tax was applied")
    tax_rate: str = Field(description="The tax rate applied")
    total_after_tax: str = Field(description="The total cost after tax")

这一点非常强大,因为 Langchain 可以使用这个 Pydantic 模型来为 LLM 构建格式指令,这些指令可以包含在提示中,以强制它生成带有指定字段的 json 输出。添加新字段就像更新模型类一样简单。

接下来,让我们构建一个静态的提示符:

from dataclasses import dataclass
@dataclass
class VisionReceiptExtractionPrompt:
    template: str = """
       You are an expert at information extraction from images of receipts.
       Given this of a receipt, extract the following information:
       - The name and address of the vendor
       - The names and costs of each of the items that were purchased
       - The date and time that the receipt was issued. This must be formatted like 'MM/DD/YY HH:MM'
       - The subtotal (i.e. the total cost before tax)
       - The tax rate
       - The total cost after tax
       Do not guess. If some information is missing just return "N/A" in the relevant field.
       If you determine that the image is not of a receipt, just set all the fields in the formatting instructions to "N/A". 
       
       You must obey the output format under all circumstances. Please follow the formatting instructions exactly.
       Do not return any additional comments or explanation. 
       """

现在,我们需要创建一个类,它将接收图像并将图像连同提示和格式说明一起发送给 LLM。

from langchain.chains import TransformChain
from langchain_core.messages import HumanMessage
from langchain_core.runnables import chain
from langchain_core.output_parsers import JsonOutputParser
import base64
from langchain.callbacks import get_openai_callback
class VisionReceiptExtractionChain:
    def __init__(self, llm):
        self.llm = llm
        self.chain = self.set_up_chain()
    @staticmethod
    def load_image(path: dict) -> dict:
        """Load image and encode it as base64."""
        def encode_image(path):
            with open(path, "rb") as image_file:
                return base64.b64encode(image_file.read()).decode("utf-8")
        image_base64 = encode_image(path["image_path"])
        return {"image": image_base64}
    def set_up_chain(self):
        extraction_model = self.llm
        prompt = VisionReceiptExtractionPrompt()
        parser = JsonOutputParser(pydantic_object=ReceiptInformation)
        load_image_chain = TransformChain(
            input_variables=["image_path"],
            output_variables=["image"],
            transform=self.load_image,
        )
        # build custom chain that includes an image
        @chain
        def receipt_model_chain(inputs: dict) -> dict:
            """Invoke model"""
            msg = extraction_model.invoke(
                [
                    HumanMessage(
                        content=[
                            {"type": "text", "text": prompt.template},
                            {"type": "text", "text": parser.get_format_instructions()},
                            {
                                "type": "image_url",
                                "image_url": {
                                    "url": f_"data:image/jpeg;base64,{inputs['image']}"
                                },
                            },
                        ]
                    )
                ]
            )
            return msg.content
        return load_image_chain | receipt_model_chain | JsonOutputParser()
    def run_and_count_tokens(self, input_dict: dict):
        with get_openai_callback() as cb:
            result = self.chain.invoke(input_dict)
        return result, cb

请注意,我们还使用了 openai 回调来计算每次调用相关的令牌和花费。

要运行此程序,我们可以执行以下操作:

from langchain_openai import ChatOpenAI
from tempfile import NamedTemporaryFile
model = ChatOpenAI(
  api_key={your open_ai api key},
  temperature=0, model="gpt-4-vision-preview", 
  max_tokens=1024
)
extractor = VisionReceiptExtractionChain(model)
# image from PDFBytesToImage.convert_bytes_to_jpeg()
prepared_data = {
    "image": image
}
with NamedTemporaryFile(suffix=".jpeg") as temp_file:
    prepared_data["image"].save(temp_file.name)
    res, cb = extractor.run_and_count_tokens(
        {"image_path": temp_file.name}
    )

根据上述随机文件,结果如下所示:

{'vendor_name': 'N/A',
 'vendor_address': 'N/A',
 'datetime': 'N/A',
 'items_purchased': [],
 'subtotal': 'N/A',
 'tax_rate': 'N/A',
 'total_after_tax': 'N/A'}

虽然不太令人兴奋,但至少其结构是正确的!当提供有效收据时,这些字段就会被填写,我对不同收据进行了几次测试,结果表明它非常准确。

我们的回调是这样的:

Tokens Used: 1170
Prompt Tokens: 1104
Completion Tokens: 66
Successful Requests: 1
Total Cost (USD): $0.01302

这对跟踪成本至关重要,因为在测试类似 gpt-4 的模型时,成本可能会迅速增长。

5. 使用 gpt-3.5-turbo 提取信息

假设我们使用第 4 部分中的步骤生成了一些示例,并将其保存为 json 文件。每个示例都包含一些提取的文本和我们的 ReceiptInformation Pydantic 模型所定义的相应关键信息。现在,我们要将这些示例注入到 gpt-3.5-turbo 的调用中,希望它能将从这些示例中学到的知识推广到新的收据中。快速学习是提示工程中的一个强大工具,如果它能发挥作用,将非常适合本使用案例,因为每当检测到一种新的收据格式时,我们就可以使用 gpt-4-vision 生成一个示例,并将其添加到用于提示 gpt-3.5-turbo 的示例列表中。然后,当出现类似格式的收据时,就可以使用 gpt-3.5-turbo 提取其内容。在某种程度上,这就像模板匹配,但无需手动定义模板。

有很多方法可以鼓励基于文本的 LLM 从文本块中提取结构化信息。我在 Langchain 文档中发现了一种最新、最强大的方法。其原理是创建一个包含一些示例占位符的提示符,然后将示例注入提示符中,就好像这些示例是由 LLM 调用的某个函数返回的一样。这是通过 model.with_structured_output() 功能实现的。

让我们看看代码是如何实现的。我们首先编写提示。

from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
@dataclass
class TextReceiptExtractionPrompt:
    system: str = """
       You are an expert at information extraction from images of receipts.
       Given this of a receipt, extract the following information:
       - The name and address of the vendor
       - The names and costs of each of the items that were purchased
       - The date and time that the receipt was issued. This must be formatted like 'MM/DD/YY HH:MM'
       - The subtotal (i.e. the total cost before tax)
       - The tax rate
       - The total cost after tax
       Do not guess. If some information is missing just return "N/A" in the relevant field.
       If you determine that the image is not of a receipt, just set all the fields in the formatting instructions to "N/A". 
       
       You must obey the output format under all circumstances. Please follow the formatting instructions exactly.
       Do not return any additional comments or explanation.
       """
    prompt: ChatPromptTemplate = ChatPromptTemplate.from_messages(
        [
            (
                "system",
                system,
            ),
            MessagesPlaceholder("examples"),
            ("human", "{input}"),
        ]
    )

提示文本与第 4 节中的文本完全相同,只是我们现在有了一个 MessagesPlaceholder 来放置我们要插入的示例。

class Example(TypedDict):
    """A representation of an example consisting of text input and expected tool calls.
    For extraction, the tool calls are represented as instances of pydantic model.
    """
    input: str
    tool_calls: List[BaseModel]
class TextReceiptExtractionChain:
    def __init__(self, llm, examples: List):
        self.llm = llm
        self.raw_examples = examples
        self.prompt = TextReceiptExtractionPrompt()
        self.chain, self.examples = self.set_up_chain()
    @staticmethod
    def tool_example_to_messages(example: Example) -> List[BaseMessage]:
        """Convert an example into a list of messages that can be fed into an LLM.
        This code is an adapter that converts our example to a list of messages
        that can be fed into a chat model.
        The list of messages per example corresponds to:
        1) HumanMessage: contains the content from which content should be extracted.
        2) AIMessage: contains the extracted information from the model
        3) ToolMessage: contains confirmation to the model that the model requested a tool correctly.
        The ToolMessage is required because some of the chat models are hyper-optimized for agents
        rather than for an extraction use case.
        """
        messages: List[BaseMessage] = [HumanMessage(content=example["input"])]
        openai_tool_calls = []
        for tool_call in example["tool_calls"]:
            openai_tool_calls.append(
                {
                    "id": str(uuid.uuid4()),
                    "type": "function",
                    "function": {
                        # The name of the function right now corresponds
                        # to the name of the pydantic model
                        # This is implicit in the API right now,
                        # and will be improved over time.
                        "name": tool_call.__class__.__name__,
                        "arguments": tool_call.json(),
                    },
                }
            )
        messages.append(
            AIMessage(content="", additional_kwargs={"tool_calls": openai_tool_calls})
        )
        tool_outputs = example.get("tool_outputs") or [
            "You have correctly called this tool."
        ] * len(openai_tool_calls)
        for output, tool_call in zip(tool_outputs, openai_tool_calls):
            messages.append(ToolMessage(content=output, tool_call_id=tool_call["id"]))
        return messages
    def set_up_examples(self):
        examples = [
            (
                example["input"],
                ReceiptInformation(
                    vendor_name=example["output"]["vendor_name"],
                    vendor_address=example["output"]["vendor_address"],
                    datetime=example["output"]["datetime"],
                    items_purchased=[
                        ReceiptItem(
                            item_name=example["output"]["items_purchased"][i][
                                "item_name"
                            ],
                            item_cost=example["output"]["items_purchased"][i][
                                "item_cost"
                            ],
                        )
                        for i in range(len(example["output"]["items_purchased"]))
                    ],
                    subtotal=example["output"]["subtotal"],
                    tax_rate=example["output"]["tax_rate"],
                    total_after_tax=example["output"]["total_after_tax"],
                ),
            )
            for example in self.raw_examples
        ]
        messages = []
        for text, tool_call in examples:
            messages.extend(
                self.tool_example_to_messages(
                    {"input": text, "tool_calls": [tool_call]}
                )
            )
        return messages
    def set_up_chain(self):
        extraction_model = self.llm
        prompt = self.prompt.prompt
        examples = self.set_up_examples()
        runnable = prompt | extraction_model.with_structured_output(
            schema=ReceiptInformation,
            method="function_calling",
            include_raw=False,
        )
        return runnable, examples
    def run_and_count_tokens(self, input_dict: dict):
        # inject the examples here
        input_dict["examples"] = self.examples
        with get_openai_callback() as cb:
            result = self.chain.invoke(input_dict)
        return result, cb

TextReceiptExtractionChain 将接收一个示例列表,每个示例都有输入和输出键(请注意 set_up_examples 方法是如何使用这些键的)。我们将为每个示例创建一个 ReceiptInformation 对象。然后,我们将结果格式化为可传入提示符的信息列表。tool_examples_to_messages 中的所有工作都是为了在不同的 Langchain 格式之间进行转换。

运行这个过程与我们在视觉模型中的操作非常相似:

# Load the examples 
EXAMPLES_PATH = "receiptchat/datasets/example_extractions.json"
with open(EXAMPLES_PATH) as f:
    loaded_examples = json.load(f)
loaded_examples = [
    {"input": x["file_details"]["extracted_text"], "output": x}
    for x in loaded_examples
]
# Set up the LLM caller
llm = ChatOpenAI(
  api_key=secrets["OPENAI_API_KEY"], 
  temperature=0, 
  model="gpt-3.5-turbo"
)
extractor = TextReceiptExtractionChain(llm, loaded_examples)
# convert a PDF file form Google Drive into text
text = PDFBytesToImage.convert_bytes_to_text(downloaded_data)
extracted_information, cb = extractor.run_and_count_tokens(
            {"input": text}
)

即使有 10 个示例,该调用的成本也不到 gpt-4-vision 的一半,而且返回速度也更快。随着示例数量的增加,你可能需要使用 gpt-3.5-turbo-16k 来避免超出上下文窗口。

输出数据集

收集了一些收据后,你可以运行第 4 和第 5 节中描述的提取方法,并将结果收集到一个数据帧中。然后将其存储起来,每当 Google Drive 中出现新的收据时,就可以对其进行追加。

6

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/589380.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

【大模型应用】使用 Windows 窗体作为 Copilot 应用程序的 Ollama AI 前端(测试llava视觉问答)...

项目 “WinForm_Ollama_Copilot” 是一个使用Windows Forms作为前端的Ollama AI Copilot应用程序。这个项目的目的是提供一个用户界面(UI),通过它,用户可以与Ollama AI进行交互。以下是该项目的一些关键特点和功能: Ollama Copilot: 这是一个…

SSM+Vue在线OA办公系统

在线办公分三个用户登录,管理员,经理,员工。 SSM架构,maven管理工具,数据库Mysql,系统有文档,可有偿安装调试及讲解,项目保证质量。需要划到 最底 下可以联系到我。 功能如下&am…

免安装SQL管理工具HeidiSQL建库如何选Collation字符校对

免安装SQL管理工具HeidiSQL 文章目录 免安装SQL管理工具HeidiSQL一、安装二、建库因此,通常我们选择: 一、安装 到官方网址:https://www.heidisql.com/ 下载后按不同版本安装或解压,运行目录中的heidisql应用程序。 该工具可以对…

万界星空科技商业开源MES+项目合作+商业开源低代码平台

今天我想和大家分享的是一套商业开源的 MES制造执行管理系统带源码。对于制造业而言,MES 是一个至关重要的系统,它可以帮助企业提高生产效率、优化资源利用、提高产品质量,从而增强市场竞争力。 什么是 MES? MES 是指通过计算机技…

Luminar开始为沃尔沃生产下一代激光雷达传感器

在自动驾驶技术的浪潮中,激光雷达(LiDAR)传感器以其高精度和强大的环境感知能力,逐渐成为了该领域的技术之星。Luminar(路安达)公司作为自动驾驶技术的领军企业,近日宣布已开始为沃尔沃汽车生产…

Git使用指北

目录 创建一个Git仓库本地仓库添加文件文件提交到本地仓库缓冲区添加远程仓库地址本地仓库推送到远程仓库创建新的分支拉取代码同步删除缓冲区的文件,远程仓库的文件.gitignore文件 创建一个Git仓库 Git仓库分为远程和本地两种,远程仓库如Githu上创建的…

Themis新篇章:老牌衍生品协议登陆Blast L2,探索全新经济模型

本文将深入分析 Themis 的最新经济模型,探讨其核心概念和机制、优势与创新之处、风险与挑战。 一、引言 随着区块链技术的不断发展,DeFi 衍生品项目逐渐成为市场的焦点。而用户体验的革新,进一步的金融创新,去中心化治理方案的优…

Golang | Leetcode Golang题解之第63题不同路径II

题目&#xff1a; 题解&#xff1a; func uniquePathsWithObstacles(obstacleGrid [][]int) int {n, m : len(obstacleGrid), len(obstacleGrid[0])f : make([]int, m)if obstacleGrid[0][0] 0 {f[0] 1}for i : 0; i < n; i {for j : 0; j < m; j {if obstacleGrid[i]…

Java中使用Redis实现分布式锁的三种方式

1. 导语 随着软件开发领域的不断演进,并发性已经成为一个至关重要的方面,特别是在资源跨多个进程共享的分布式系统中。 在Java中,管理并发性对于确保数据一致性和防止竞态条件至关重要。 Redis作为一个强大的内存数据存储,为在Java应用程序中实现分布式锁提供了一种高效的…

go-mysql-transfer 同步数据到es

同步数据需要注意的事项 前提条件 1 要同步的mysql 表必须包含主键 2 mysql binlog 必须是row 模式 3 不支持程序运行过程中修改表结构 4 要赋予连接mysql 账号的权限 reload, replication super 权限 如果是root 权限则不需要 安装 go-mysql-transfer ​ git clone…

和丰多媒体信息发布系统 QH.aspx 文件上传漏洞复现

0x01 免责声明 请勿利用文章内的相关技术从事非法测试&#xff0c;由于传播、利用此文所提供的信息而造成的任何直接或者间接的后果及损失&#xff0c;均由使用者本人负责&#xff0c;作者不为此承担任何责任。工具来自网络&#xff0c;安全性自测&#xff0c;如有侵权请联系删…

《十二》Qt各种对话框之FileDialog文件对话框及QMessageBox 消息对话框

QFileDialog 对话框 选择打开一个文件 若要打开一个文件&#xff0c;可调用静态函数 QFileDialog::getOpenFileName()&#xff0c;“打开一个文件”按钮的响应代码如下&#xff1a; void Dialog::on_btnOpen_clicked() { //选择单个文件QString curPathQDir::currentPath()…

【Docker】如何注册Hub账号并上传镜像到Hub仓库

一、创建Hub账户 浏览器访问&#xff1a;hub.docker.com 点击【Sign up】注册账号 输入【邮箱】【用户名】【密码】 ps&#xff1a;用户名要有字母数字&#xff1b;订阅不用勾选 点击【Sign up】注册即可 点击【Sign in】登录账号 输入【邮箱】【密码】 点击【Continue】登录 二…

大数据之数据仓库技术:ETL工具和Kettle简介

大数据之数据仓库技术&#xff1a;ETL工具和Kettle简介 ETL简介ETL工具和KettleKettle家族 Kettle资源KettlePack 任务调度工具 ETL简介 ETL(Extract-Transform-Load): 在大数据技术领域内&#xff0c;用来描述将数据从 来源端 经过 抽取(extract), 转换(transform), 加载(loa…

cefsharp实现资源替换如网页背景、移除替换标签、html标识、执行javascript脚本学习笔记(含源码说明)

(一)实现测试(仅供学习参考) 1.1 目标系统页面(登录页)和登录后首页面中2处(一个替换一个移除) 1.2 实现后效果(使用cefsharp自定义浏览器实现以上功能) 1.3 登录后页面替换和移除 系统名称和一个功能菜单li (二)通过分析代码实现脚本编写 2.1 分开处理,设置了…

C语言/数据结构——每日一题(反转链表)

一.前言 大家好&#xff01;今天又是每日一题环节。今天我为大家分享了一道单链表题——反转链表。 废话不多说&#xff0c;让我们直接进入正题吧。 二.正文 1.1题目信息 这是一道leetCode上面的一道题&#xff1a;https://leetcode.cn/problems/reverse-linked-list 1.2解…

Linux 第十八章

&#x1f436;博主主页&#xff1a;ᰔᩚ. 一怀明月ꦿ ❤️‍&#x1f525;专栏系列&#xff1a;线性代数&#xff0c;C初学者入门训练&#xff0c;题解C&#xff0c;C的使用文章&#xff0c;「初学」C&#xff0c;linux &#x1f525;座右铭&#xff1a;“不要等到什么都没有了…

一周零碎时间练习微服务(nacos,rq,springcloud,es等)内容

目录 1 总览1.1 技术架构1.2 其他1.2.1 数据库1.2.2 后端部分1.2.2.1 复习feign1.2.2.2 复习下网关网关的核心功能特性&#xff1a;网关路由的流程断言工厂过滤器工厂全局过滤器 过滤器执行顺序解决跨域问题 1.2.2.3 es部分复习 1.2.3 前端部分 2 day1 配置网关2.1 任务2.2 网关…

UI-Diffuser——使用生成性人工智能的UI原型设计

概述。 移动UI是影响参与度的一个重要因素&#xff0c;例如用户对应用的熟悉程度和使用的便利性。如果你有一个类似的应用程序&#xff0c;你可能会选择一个具有现代、好看的设计的应用程序&#xff0c;而不是一个旧的设计。然而&#xff0c;要从头开始研究什么样的UI最适合应…

JavaEE >> Spring MVC(1)

MVC MVC&#xff1a;Model View Controller 的缩写&#xff0c;是一种软件架构模式&#xff0c;将软件系统分为模型、视图和控制器三个部分。 Mode&#xff08;模型&#xff09;&#xff1a;是应⽤程序中⽤于处理应⽤程序数据逻辑的部分。通常模型对象负责在数据库中存取数据…