当前位置: 首页 > news >正文

hg transformers pipeline使用

什么是hg transformers pipeline?

在Hugging Face的transformers库中,pipeline是一个高级API,它提供了一种简便的方式来使用预训练模型进行各种NLP任务,比如情感分析、文本生成、翻译、问答等。通过pipeline,你可以在几行代码内实现复杂的NLP任务。pipeline会自动加载用于指定任务的默认模型和tokenizer,如果需要,用户也可以指定使用特定的模型和tokenizer

在创建pipeline时,除了可以指定任务类型和模型外,还可以设置其他参数,比如使用的深度学习框架("pt"代表PyTorch,"tf"代表TensorFlow)、设备(CPU或GPU)、批量处理大小等 。pipeline背后的实现包括初始化Tokenizer、Model,并进行数据预处理

以下是对pipelines主要特点和功能的总结:

  1. 任务特定: Pipelines为多种NLP任务提供了特定的接口,如文本分类、命名实体识别、问答、文本生成、翻译、摘要和情感分析等。
  2. 模型自动加载: 用户无需关心背后的模型细节,pipelines会自动加载适合任务的预训练模型和tokenizer。
  3. 易于使用: Pipelines提供了简洁的API,用户只需几行代码即可加载模型并进行任务处理。
  4. 自动分词: Pipelines内部处理文本的分词,将文本转换为模型能理解的格式。
  5. 批处理: Pipelines支持批处理,可以同时处理多条文本数据。
  6. 动态调整: Pipelines可以根据输入数据的需要自动调整模型输入,如填充(padding)和截断(truncation)。
  7. 自定义模型和分词器: 用户可以指定自定义的模型和分词器,以适应特定的需求。
  8. 模型微调: 在使用pipelines进行任务之前,用户还可以对模型进行微调,以适应特定的数据集。
  9. 多语言支持: 许多pipelines支持多种语言,使得跨语言的NLP任务成为可能。
  10. 可扩展性: 用户可以根据自己的需求,使用pipelines作为构建块,构建更复杂的NLP流程。
  11. 性能优化: Pipelines针对常见用例进行了优化,以提供高性能的NLP任务处理。
  12. 错误处理: Pipelines提供了错误处理机制,以应对加载模型或处理文本时可能出现的问题。

通过使用pipelines,研究人员和开发者可以快速原型开发和部署NLP应用,而无需深入了解模型的内部工作原理。简而言之,pipelines是Hugging Face Transformers库中一个强大且灵活的工具,用于简化NLP任务的处理流程。

支持的任务分类

可用于音频、计算机视觉、自然语言处理和多模态任务

TASK_ALIASES = {  "sentiment-analysis": "text-classification",  "ner": "token-classification",  "vqa": "visual-question-answering",  "text-to-speech": "text-to-audio",  
}  
SUPPORTED_TASKS = {  "audio-classification": {  "impl": AudioClassificationPipeline,  "tf": (),  "pt": (AutoModelForAudioClassification,) if is_torch_available() else (),  "default": {"model": {"pt": ("superb/wav2vec2-base-superb-ks", "372e048")}},  "type": "audio",  },  "automatic-speech-recognition": {  "impl": AutomaticSpeechRecognitionPipeline,  "tf": (),  "pt": (AutoModelForCTC, AutoModelForSpeechSeq2Seq) if is_torch_available() else (),  "default": {"model": {"pt": ("facebook/wav2vec2-base-960h", "55bb623")}},  "type": "multimodal",  },  "text-to-audio": {  "impl": TextToAudioPipeline,  "tf": (),  "pt": (AutoModelForTextToWaveform, AutoModelForTextToSpectrogram) if is_torch_available() else (),  "default": {"model": {"pt": ("suno/bark-small", "645cfba")}},  "type": "text",  },  "feature-extraction": {  "impl": FeatureExtractionPipeline,  "tf": (TFAutoModel,) if is_tf_available() else (),  "pt": (AutoModel,) if is_torch_available() else (),  "default": {  "model": {  "pt": ("distilbert/distilbert-base-cased", "935ac13"),  "tf": ("distilbert/distilbert-base-cased", "935ac13"),  }  },  "type": "multimodal",  },  "text-classification": {  "impl": TextClassificationPipeline,  "tf": (TFAutoModelForSequenceClassification,) if is_tf_available() else (),  "pt": (AutoModelForSequenceClassification,) if is_torch_available() else (),  "default": {  "model": {  "pt": ("distilbert/distilbert-base-uncased-finetuned-sst-2-english", "af0f99b"),  "tf": ("distilbert/distilbert-base-uncased-finetuned-sst-2-english", "af0f99b"),  },  },  "type": "text",  },  "token-classification": {  "impl": TokenClassificationPipeline,  "tf": (TFAutoModelForTokenClassification,) if is_tf_available() else (),  "pt": (AutoModelForTokenClassification,) if is_torch_available() else (),  "default": {  "model": {  "pt": ("dbmdz/bert-large-cased-finetuned-conll03-english", "f2482bf"),  "tf": ("dbmdz/bert-large-cased-finetuned-conll03-english", "f2482bf"),  },  },  "type": "text",  },  "question-answering": {  "impl": QuestionAnsweringPipeline,  "tf": (TFAutoModelForQuestionAnswering,) if is_tf_available() else (),  "pt": (AutoModelForQuestionAnswering,) if is_torch_available() else (),  "default": {  "model": {  "pt": ("distilbert/distilbert-base-cased-distilled-squad", "626af31"),  "tf": ("distilbert/distilbert-base-cased-distilled-squad", "626af31"),  },  },  "type": "text",  },  "table-question-answering": {  "impl": TableQuestionAnsweringPipeline,  "pt": (AutoModelForTableQuestionAnswering,) if is_torch_available() else (),  "tf": (TFAutoModelForTableQuestionAnswering,) if is_tf_available() else (),  "default": {  "model": {  "pt": ("google/tapas-base-finetuned-wtq", "69ceee2"),  "tf": ("google/tapas-base-finetuned-wtq", "69ceee2"),  },  },  "type": "text",  },  "visual-question-answering": {  "impl": VisualQuestionAnsweringPipeline,  "pt": (AutoModelForVisualQuestionAnswering,) if is_torch_available() else (),  "tf": (),  "default": {  "model": {"pt": ("dandelin/vilt-b32-finetuned-vqa", "4355f59")},  },  "type": "multimodal",  },  "document-question-answering": {  "impl": DocumentQuestionAnsweringPipeline,  "pt": (AutoModelForDocumentQuestionAnswering,) if is_torch_available() else (),  "tf": (),  "default": {  "model": {"pt": ("impira/layoutlm-document-qa", "52e01b3")},  },  "type": "multimodal",  },  "fill-mask": {  "impl": FillMaskPipeline,  "tf": (TFAutoModelForMaskedLM,) if is_tf_available() else (),  "pt": (AutoModelForMaskedLM,) if is_torch_available() else (),  "default": {  "model": {  "pt": ("distilbert/distilroberta-base", "ec58a5b"),  "tf": ("distilbert/distilroberta-base", "ec58a5b"),  }  },  "type": "text",  },  "summarization": {  "impl": SummarizationPipeline,  "tf": (TFAutoModelForSeq2SeqLM,) if is_tf_available() else (),  "pt": (AutoModelForSeq2SeqLM,) if is_torch_available() else (),  "default": {  "model": {"pt": ("sshleifer/distilbart-cnn-12-6", "a4f8f3e"), "tf": ("google-t5/t5-small", "d769bba")}  },  "type": "text",  },  # This task is a special case as it's parametrized by SRC, TGT languages.  "translation": {  "impl": TranslationPipeline,  "tf": (TFAutoModelForSeq2SeqLM,) if is_tf_available() else (),  "pt": (AutoModelForSeq2SeqLM,) if is_torch_available() else (),  "default": {  ("en", "fr"): {"model": {"pt": ("google-t5/t5-base", "686f1db"), "tf": ("google-t5/t5-base", "686f1db")}},  ("en", "de"): {"model": {"pt": ("google-t5/t5-base", "686f1db"), "tf": ("google-t5/t5-base", "686f1db")}},  ("en", "ro"): {"model": {"pt": ("google-t5/t5-base", "686f1db"), "tf": ("google-t5/t5-base", "686f1db")}},  },  "type": "text",  },  "text2text-generation": {  "impl": Text2TextGenerationPipeline,  "tf": (TFAutoModelForSeq2SeqLM,) if is_tf_available() else (),  "pt": (AutoModelForSeq2SeqLM,) if is_torch_available() else (),  "default": {"model": {"pt": ("google-t5/t5-base", "686f1db"), "tf": ("google-t5/t5-base", "686f1db")}},  "type": "text",  },  "text-generation": {  "impl": TextGenerationPipeline,  "tf": (TFAutoModelForCausalLM,) if is_tf_available() else (),  "pt": (AutoModelForCausalLM,) if is_torch_available() else (),  "default": {"model": {"pt": ("openai-community/gpt2", "6c0e608"), "tf": ("openai-community/gpt2", "6c0e608")}},  "type": "text",  },  "zero-shot-classification": {  "impl": ZeroShotClassificationPipeline,  "tf": (TFAutoModelForSequenceClassification,) if is_tf_available() else (),  "pt": (AutoModelForSequenceClassification,) if is_torch_available() else (),  "default": {  "model": {  "pt": ("facebook/bart-large-mnli", "c626438"),  "tf": ("FacebookAI/roberta-large-mnli", "130fb28"),  },  "config": {  "pt": ("facebook/bart-large-mnli", "c626438"),  "tf": ("FacebookAI/roberta-large-mnli", "130fb28"),  },  },  "type": "text",  },  "zero-shot-image-classification": {  "impl": ZeroShotImageClassificationPipeline,  "tf": (TFAutoModelForZeroShotImageClassification,) if is_tf_available() else (),  "pt": (AutoModelForZeroShotImageClassification,) if is_torch_available() else (),  "default": {  "model": {  "pt": ("openai/clip-vit-base-patch32", "f4881ba"),  "tf": ("openai/clip-vit-base-patch32", "f4881ba"),  }  },  "type": "multimodal",  },  "zero-shot-audio-classification": {  "impl": ZeroShotAudioClassificationPipeline,  "tf": (),  "pt": (AutoModel,) if is_torch_available() else (),  "default": {  "model": {  "pt": ("laion/clap-htsat-fused", "973b6e5"),  }  },  "type": "multimodal",  },  "conversational": {  "impl": ConversationalPipeline,  "tf": (TFAutoModelForSeq2SeqLM, TFAutoModelForCausalLM) if is_tf_available() else (),  "pt": (AutoModelForSeq2SeqLM, AutoModelForCausalLM) if is_torch_available() else (),  "default": {  "model": {"pt": ("microsoft/DialoGPT-medium", "8bada3b"), "tf": ("microsoft/DialoGPT-medium", "8bada3b")}  },  "type": "text",  },  "image-classification": {  "impl": ImageClassificationPipeline,  "tf": (TFAutoModelForImageClassification,) if is_tf_available() else (),  "pt": (AutoModelForImageClassification,) if is_torch_available() else (),  "default": {  "model": {  "pt": ("google/vit-base-patch16-224", "5dca96d"),  "tf": ("google/vit-base-patch16-224", "5dca96d"),  }  },  "type": "image",  },  "image-feature-extraction": {  "impl": ImageFeatureExtractionPipeline,  "tf": (TFAutoModel,) if is_tf_available() else (),  "pt": (AutoModel,) if is_torch_available() else (),  "default": {  "model": {  "pt": ("google/vit-base-patch16-224", "3f49326"),  "tf": ("google/vit-base-patch16-224", "3f49326"),  }  },  "type": "image",  },  "image-segmentation": {  "impl": ImageSegmentationPipeline,  "tf": (),  "pt": (AutoModelForImageSegmentation, AutoModelForSemanticSegmentation) if is_torch_available() else (),  "default": {"model": {"pt": ("facebook/detr-resnet-50-panoptic", "fc15262")}},  "type": "multimodal",  },  "image-to-text": {  "impl": ImageToTextPipeline,  "tf": (TFAutoModelForVision2Seq,) if is_tf_available() else (),  "pt": (AutoModelForVision2Seq,) if is_torch_available() else (),  "default": {  "model": {  "pt": ("ydshieh/vit-gpt2-coco-en", "65636df"),  "tf": ("ydshieh/vit-gpt2-coco-en", "65636df"),  }  },  "type": "multimodal",  },  "object-detection": {  "impl": ObjectDetectionPipeline,  "tf": (),  "pt": (AutoModelForObjectDetection,) if is_torch_available() else (),  "default": {"model": {"pt": ("facebook/detr-resnet-50", "2729413")}},  "type": "multimodal",  },  "zero-shot-object-detection": {  "impl": ZeroShotObjectDetectionPipeline,  "tf": (),  "pt": (AutoModelForZeroShotObjectDetection,) if is_torch_available() else (),  "default": {"model": {"pt": ("google/owlvit-base-patch32", "17740e1")}},  "type": "multimodal",  },  "depth-estimation": {  "impl": DepthEstimationPipeline,  "tf": (),  "pt": (AutoModelForDepthEstimation,) if is_torch_available() else (),  "default": {"model": {"pt": ("Intel/dpt-large", "e93beec")}},  "type": "image",  },  "video-classification": {  "impl": VideoClassificationPipeline,  "tf": (),  "pt": (AutoModelForVideoClassification,) if is_torch_available() else (),  "default": {"model": {"pt": ("MCG-NJU/videomae-base-finetuned-kinetics", "4800870")}},  "type": "video",  },  "mask-generation": {  "impl": MaskGenerationPipeline,  "tf": (),  "pt": (AutoModelForMaskGeneration,) if is_torch_available() else (),  "default": {"model": {"pt": ("facebook/sam-vit-huge", "997b15")}},  "type": "multimodal",  },  "image-to-image": {  "impl": ImageToImagePipeline,  "tf": (),  "pt": (AutoModelForImageToImage,) if is_torch_available() else (),  "default": {"model": {"pt": ("caidas/swin2SR-classical-sr-x2-64", "4aaedcb")}},  "type": "image",  },  
}

使用示例

简单使用示例

from transformers import pipeline  
from transformers.pipelines import get_supported_tasks  
import json  nlp = pipeline("sentiment-analysis")  
# 单次调用  
result = nlp("I hate you")[0]  
print(f"label: {result['label']}, score: {round(result['score'], 4)}")  
# label: NEGATIVE, with score: 0.9991  
result = nlp("I love you")[0]  
print(f"label: {result['label']}, score: {round(result['score'], 4)}")  
# label: POSITIVE, with score  # 多次调用  
result = nlp(["This restaurant is awesome", "This restaurant is awful"])  
print(json.dumps(result))  print(json.dumps(get_supported_tasks()))

执行的输出日志如下:

  • 因为未指定model,默认根据任务分类名称从hg下载对应的模型,sentiment-analysis任务对应的默认模型是:models–distilbert–distilbert-base-uncased-finetuned-sst-2-english,默认是af0f99b
  • 下载的model保存的默认目录是:C:\Users\用户名.cache\huggingface\hub\
  • 不建议在生产环境中不指定model及版本
python.exe Classification.py 
No model was supplied, defaulted to distilbert/distilbert-base-uncased-finetuned-sst-2-english and revision af0f99b (https://huggingface.co/distilbert/distilbert-base-uncased-finetuned-sst-2-english).
Using a pipeline without specifying a model name and revision in production is not recommended.
D:\soft\anaconda3\envs\llm-demo\lib\site-packages\huggingface_hub\file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.warnings.warn(
D:\soft\anaconda3\envs\llm-demo\lib\site-packages\huggingface_hub\file_download.py:157: UserWarning: `huggingface_hub` cache-system uses symlinks by default to efficiently store duplicated files but your machine does not support them in C:\Users\wang\.cache\huggingface\hub\models--distilbert--distilbert-base-uncased-finetuned-sst-2-english. Caching files will still work but in a degraded version that might require more space on your disk. This warning can be disabled by setting the `HF_HUB_DISABLE_SYMLINKS_WARNING` environment variable. For more details, see https://huggingface.co/docs/huggingface_hub/how-to-cache#limitations.
To support symlinks on Windows, you either need to activate Developer Mode or to run Python as an administrator. In order to see activate developer mode, see this article: https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-developmentwarnings.warn(message)
label: NEGATIVE, score: 0.9991
label: POSITIVE, score: 0.9999[{"label": "POSITIVE", "score": 0.9998743534088135}, {"label": "NEGATIVE", "score": 0.9996669292449951}]["audio-classification", "automatic-speech-recognition", "conversational", "depth-estimation", "document-question-answering", "feature-extraction", "fill-mask", "image-classification", "image-feature-extraction", "image-segmentation", "image-to-image", "image-to-text", "mask-generation", "ner", "object-detection", "question-answering", "sentiment-analysis", "summarization", "table-question-answering", "text-classification", "text-generation", "text-to-audio", "text-to-speech", "text2text-generation", "token-classification", "translation", "video-classification", "visual-question-answering", "vqa", "zero-shot-audio-classification", "zero-shot-classification", "zero-shot-image-classification", "zero-shot-object-detection"]

Pipeline batching

from transformers import pipeline  
from transformers.pipelines.pt_utils import KeyDataset  
import datasets  dataset = datasets.load_dataset("imdb", name="plain_text", split="unsupervised")  pipe = pipeline(task="sentiment-analysis")  for out in pipe(KeyDataset(dataset, "text"), batch_size=8, truncation="only_first"):  print(out)

自定义数据集

from transformers import pipeline
from torch.utils.data import Dataset
from tqdm.auto import tqdmpipe = pipeline("text-classification", device=0)class MyDataset(Dataset):def __len__(self):return 5000def __getitem__(self, i):return "This is a test"dataset = MyDataset()for batch_size in [1, 8, 64, 256]:print("-" * 30)print(f"Streaming batch_size={batch_size}")for out in tqdm(pipe(dataset, batch_size=batch_size), total=len(dataset)):pass

文本summary

# use bart in pytorch
summarizer = pipeline("summarization")
summarizer("An apple a day, keeps the doctor away", min_length=5, max_length=20)# use t5 in tf
summarizer = pipeline("summarization", model="google-t5/t5-base", tokenizer="google-t5/t5-base", framework="tf")
summarizer("An apple a day, keeps the doctor away", min_length=5, max_length=20)

学习资料

  • https://huggingface.co/docs/transformers/main_classes/pipelines
  • https://huggingface.co/docs/transformers/task_summary#text-classification

相关文章:

hg transformers pipeline使用

什么是hg transformers pipeline? 在Hugging Face的transformers库中,pipeline是一个高级API,它提供了一种简便的方式来使用预训练模型进行各种NLP任务,比如情感分析、文本生成、翻译、问答等。通过pipeline,你可以在几行代码内…...

高性能内存对象缓存

Memcached概述 一套开源的高性能分布式内存对象缓存系统 所有的数据都存储在内存中 支持任意存储类型的数据 提高网站的访问速度 数据存储方式与数据过期方式 数据存储方式:Slab Allocation 按组分配内存,每次先分配一个Slab,相当于一个大小为1M的页&…...

文件上传-CMS文件上传分析

黑盒思路: 上传点抓包测试 个人用户中心是否存在文件上传功能后台管理系统是否存在文件上传功能字典目录扫描探针文件(eg:upload.php)构造地址字典目录扫描探针编辑器目录构造地址(编辑器目录一般是默认的&#xff09…...

云原生日志Loki

1. Loki简介 1.1 Loki介绍 Loki是 Grafana Labs 团队最新的开源项目,是一个水平可扩展,高可用性,多租户的日志聚合系统。它的设计非常经济高效且易于操作,因为它不会为日志内容编制索引,而是为每个日志流编制一组标签…...

初阶数据结构之直接选择排序和快速排序

直接选择排序 1.在元素集合 array[i]–array[n-1] 中选择关键码最⼤(⼩)的数据元素 2.若它不是这组元素中的最后⼀个(第⼀个)元素,则将它与这组元素中的最后⼀个(第⼀个)元素 交换 3.在剩余的 array[i]–array[n-2](array[i1]–…...

Java语言程序设计——篇十三(4)

🌿🌿🌿跟随博主脚步,从这里开始→博主主页🌿🌿🌿 欢迎大家:这里是我的学习笔记、总结知识的地方,喜欢的话请三连,有问题可以私信🌳🌳&…...

低代码: 组件库测试之渲染和元素获取,触发事件,更新表单,验证事件以及异步请求

组件库测试步骤 渲染组件(怎样将一个组件渲染到测试用例里面) mount 和 shallowMount传递属性元素是否成功的显示 查找元素的不同写法get, getAllfind, findAllfindComponent 和 getComponent触发事件(是click也好,是input也好,让它触发对应的事件) trigger 方法观察测试界面…...

银河麒麟服务器操作系统Kylin-Server-V10-SP3-2403-Release-20240426-x86_64安装步骤

银河麒麟服务器操作系统 Kylin-Server-V10-SP3-2403-Release-20240426-x86_64安装步骤 一、准备工作1. 下载ISO镜像2. 制作安装介质3. 设置BIOS 二、安装过程1. 启动系统2. 选择安装语言3. 选择安装配置4. 配置root密码与创建用户5. 开始安装6. 重启系统7. 同意许可协议 三、系…...

2024年电赛H题全开源

当题目出来的的那一刻,看到了M0芯片,我们实验室只有一块板子,并且我没有接触过M0,电赛只准备了TI的MSP430f5529。但是我并没有放弃,决然的选择了H题。基本上将四问全做出来,可是测试由于使用了感为科技的寻…...

Docker:宿主机可以ping通外网,docker容器内无法ping通外网之解决方法

问题描述 1、宿主机可以ping外网,docker容器内无法ping外网 ping www.baidu.com 提示:unknown host baidu.com 2、宿主机可以wget下载,docker容器内无法wget下载 wget www.baidu.com 提示:unknown host baidu.com 解决方法 1、…...

bootchart抓Android系统启动各阶段性能数据

最近在做Android系统启动优化,首要任务是找到启动过程中各阶段耗时点,进而有针对性地进行优化。主要用bootchart抓开机数据,本文主要记录下工具的使用方法。 1.抓开机数据 adb root adb shell ‘touch /data/bootchart/enabled’ adb rebo…...

使用 Node.js 和 Express 框架通过网页访问GPIO和嵌入式 Linux 系统中使用 GSM/3G/4G 模块

点击上方"蓝字"关注我们 01、前言 想要快速开发嵌入式 Linux 网络应用,控制硬件 GPIO,从而使得用户能够远程控制和监控系统。 主要目的是向读者展示开发使用文件系统控制 GPIO 的 Node 代码、创建用户有好的界面、以及运行基于 Express 框架使用 AJAX 通客户端进…...

IT 行业的就业情况

当前,IT 行业的就业情况呈现出以下特点: 1. 需求持续增长:随着数字化转型的加速,各个行业对信息技术的依赖程度不断提高,推动了对 IT 人才的持续需求。特别是在云计算、大数据、人工智能、物联网等新兴领域&#xff…...

如何快速获取麒麟操作系统版本信息

如何快速获取麒麟操作系统版本信息 一、桌面版系统1. 使用 /etc/kylin-build 文件2. 使用 /etc/.kyinfo 文件 二、服务器版系统1. 使用 /etc/.productinfo 文件2. 使用 nkvers 命令3. 使用 /etc/kylin-release 文件 三、总结 💖The Begin💖点点关注&…...

git提交规范检查husky

一、Eslint 尤雨溪推荐的 prettierrc 配置,句尾不带分号 单引号。 尤雨溪推荐配置:vue-next/.prettierrc lint lint 是最著名的 C 语言工具之一,是由贝尔实验室 SteveJohnson 于 1979 在 PCC(PortableC Compiler) 基础上开发的静态代码分…...

LeetCode 919. 完全二叉树插入器

完全二叉树是每一层(除最后一层外)都是完全填充(即,节点数达到最大)的,并且所有的节点都尽可能地集中在左侧。 设计一个用完全二叉树初始化的数据结构 CBTInserter,它支持以下几种操作&#xf…...

C++密码管理器

先问一句 最近有几个关注我的原力等级为0或-1,文章全是转载,转载时间基本都在2021年,而且关注了很多人,这些是僵尸粉吗? 文末有投票,麻烦参与一下谢谢 实现功能列表 暂时还没做加密功能 打算用openssl/a…...

算法【Java】 —— 滑动窗口

滑动窗口 在上一篇文章中,我们了解到了双指针算法,在双指针算法中我们知道了前后指针法,这篇文章就要提到前后指针法的一个经典的使用 —— 滑动窗口,在前后指针法中,我们知道一个指针在前,一个指针在后&a…...

Spring Aware接口执行时机

一. 介绍 Spring Aware 接口的执行时机有两处,都在 getBean() 中的 initializeBean() 中; 下面我们分析这两处时机; // ----------------------- AbstractAutowireCapableBeanFactory --------------------- protected Object initializeB…...

android FD_SET_chk问题定位

android FD_SET_chk问题定位 一、FD报错二、问题定位2.1 APM定位2.2 adb定位2.3. 代码获取FD数 三、FD优化 一、FD报错 App在运行中记录报错如下,FD_SET,这个问题大概是文件描述符(File Descriptor,简称FD)超过了最大…...

Chapter 39 Python多线程编程

欢迎大家订阅【Python从入门到精通】专栏,一起探索Python的无限可能! 文章目录 前言一、并行执行二、threading模块 前言 现代操作系统如 macOS、UNIX、Linux 和 Windows 等,均支持多任务处理。本篇文章详细讲解了并行执行的概念以及如何在 …...

STM32(二):GPIO

GPIO(General Purpose Input Output)通用输入输出口 1.可配置为8种输入输出模式,引脚电平:0V~3.3V,部分引脚可容忍5V,输出模式下可控制端口输出高低电平,用以驱动LED、控制蜂鸣器、模拟通信协议输出时序等,输入模式下…...

一文入门mysql 数据库

一、对数据库的操作 1.展示所有的数据库 show databases; 2.创建数据库 create database 数据库名 charset utf8; 3.删除数据库 drop database 数据库名; 4.查看当前使用的数据库 select database(); 5.使用数据库 use 数据库名; 二、对数据表的操作 1.展示所有表…...

通义千问( 四 ) Function Call 函数调用

4.2.function call 函数调用 大模型在面对实时性问题、私域知识型问题或数学计算等问题时可能效果不佳。 您可以使用function call功能,通过调用外部工具来提升模型的输出效果。您可以在调用大模型时,通过tools参数传入工具的名称、描述、入参等信息。…...

设置idea中放缩字体大小

由于idea没默认支持ctrl滚轴对字体调节大小,下面一起设置一下吧! 点击 文件 -> 设置 按键映射 -> 编辑器操作 -> 搜索栏输入f 点击减小字体大小 -> 选择增加鼠标快捷键 按着ctrl键,鼠标向下滚动后,点击确定即可 然后…...

frameworks 之getEvent指令

frameworks 之getEvent指令 指令解析源码追溯源码解析1.解析参数2.初始化ufds数组3.添加到poll 并做对应处理 通过 getEvent 可以识别按键基本命令和里面的关键信息 涉及到的类如下 system/core/toolbox/toolbox.csystem/core/toolbox/tools.hsystem/core/toolbox/getevent.c …...

tensorboard显示一片空白解决方案

OK艾瑞巴蒂 不知道看这个视频几个小土堆过来的,今天已经发了一篇博文探讨快速下载tensorboard了 下面用的时候叒出现问题了 from torch.utils.tensorboard import SummaryWriter writer SummaryWriter("logs")# writer.add_image() # Yx for i in range…...

C#编程中,如何实现一个高效的数据排序算法?

在C#编程中&#xff0c;可以使用内置的排序方法来实现高效的数据排序。最常用的方法是使用Array.Sort()和List<T>.Sort()。这些方法内部使用了快速排序算法&#xff08;Quick Sort&#xff09;&#xff0c;它是一种非常高效的排序算法&#xff0c;平均时间复杂度为O(n lo…...

LookupError: Resource averaged_perceptron_tagger not found.解决方案

大家好,我是爱编程的喵喵。双985硕士毕业,现担任全栈工程师一职,热衷于将数据思维应用到工作与生活中。从事机器学习以及相关的前后端开发工作。曾在阿里云、科大讯飞、CCF等比赛获得多次Top名次。现为CSDN博客专家、人工智能领域优质创作者。喜欢通过博客创作的方式对所学的…...

Leetcode JAVA刷刷站(39)组合总和

一、题目概述 二、思路方向 为了解决这个问题&#xff0c;我们可以使用回溯算法来找到所有可能的组合&#xff0c;使得组合中的数字之和等于目标数 target。因为数组中的元素可以无限制地重复选择&#xff0c;所以在回溯过程中&#xff0c;我们不需要跳过已经选择的元素&#x…...

Spring中AbstractAutowireCapableBeanFactory

AbstractAutowireCapableBeanFactory 是 Spring 框架中的一个抽象类&#xff0c;位于 org.springframework.beans.factory.support 包中。它实现了 AutowireCapableBeanFactory 接口&#xff0c;提供了一些通用的方法和逻辑&#xff0c;以支持 Spring 中的自动装配功能。 主要…...

PostgreSQL的walwriter和archiver进程区别

PostgreSQL的walwriter和archiver进程区别 在PostgreSQL中&#xff0c;walwriter和archiver进程是两个重要的后台进程&#xff0c;它们负责管理WAL&#xff08;Write-Ahead Logging&#xff0c;预写日志&#xff09;文件&#xff0c;但它们的职责和功能有所区别。理解这两个进…...

前端字体没有授权,字体版权检测(是否为方正字体)

1.截图系统中的首页和登录页面&#xff0c;主要是有字体的地方 2.在线字体版权检测地址&#xff1a;字体版权自动检测-求字体网 3.上传照片&#xff0c;开始对图片进行检测&#xff0c;每个账号有三次免费次数 4.检测完&#xff0c;直接查看检测报告即可&#xff0c; 报告中…...

在 SOCKS 和 HTTP 代理之间如何选择?

在 SOCKS 和 HTTP 代理之间进行选择需要彻底了解每种代理的工作原理以及它们传达的配置。只有这样&#xff0c;您才能轻松地在不同类型的代理之间进行选择。 本文概述了 HTTP 和 SOCKS 代理是什么、它们如何运作以及它们各自带来的好处。此外&#xff0c;我们将比较这两种代理类…...

C++适配windows和linux下网络编程TCP简单案例

C网络编程 网络协议是计算机网络中通信双方必须遵循的一套规则和约定&#xff0c;用于实现数据的传输、处理和控制。这些规则包括了数据格式、数据交换顺序、数据处理方式、错误检测和纠正等。网络协议是使不同类型的计算机和网络设备能够相互通信的基础&#xff0c;是网络通信…...

OpenDDS的GUID是如何构造的?

1、GUID、RepoID、GUID_t概念和关系 GUID(Global Unique IDentifiers)是RTPS规范约定的DDS对象的唯一性ID;RepoId(Repository IDentifiers)是Repo服务约定的DDS对象的唯一性ID;GUID和RepoId,都是基于GUID_t结构体定义,名称不同,但实质上是一样的。题外话: 无论是GUID还…...

初识MySQL(安装与配置环境)

嗨&#xff01;今天我们进入一个新的领域---数据库。 首先来个小小铺垫。 我们平时存储东西的时候&#xff0c;一般用到文件。为什么有文件了&#xff0c;还继续要这个数据库呢&#xff1f; 很明显&#xff0c;文件有一些不好的地方&#xff0c;需要数据库来进行补充。 文件…...

druid+logback打印sql执行日志

druid 的LogFilter 为我们准备了四种logger类型&#xff0c;对应打印 datasource相关、connection相关、statement相关、resultset相关的日志。 druid.sql.Datasource&#xff1a;打印数据源相关的字段。 druid.sql.Connection&#xff1a;打印应用程序获得数据库连接的过程。…...

C++编程:无锁环形队列 (LockFreeRingQueue)的简单实现、测试和分析

文章目录 0. 概述1. 无锁环形队列概述1.1 无锁环形队列的特点1.2 无锁环形队列的优势与局限 2. LockFreeRingQueue 实现2.1 Enqueue 操作流程图2.2 Dequeue 操作流程图 3. 核心实现细节3.1 环形队列的大小调整3.2 索引计算3.3 原子操作与CAS3.4 线程让步 4. 测试示例程序4.1 实…...

植物生长时为什么会扭动?科学家解开令查尔斯·达尔文困惑的千古之谜

在一项新的研究中&#xff0c;来自美国和以色列的物理学家可能已经弄清了植物生长过程中的一种古怪行为–也是查尔斯-达尔文本人在其生命的最后几十年里所好奇的一个谜&#xff1a;对于许多人类来说&#xff0c;植物可能看起来静止不动&#xff0c;甚至有点无趣。但实际上&…...

SAP LE学习笔记02 - WM和库存管理(IM)之间的关系,保管Lot(Quant)

上一章学习了LE的基础知识。 1&#xff0c;LE的概述&#xff0c;LE里面包含下面3个大的模块 - LE-WM 仓库管理 / - LE-SHP 发货/ - LE-TRA 运输 2&#xff0c;仓库的结构 - 仓库番号 / -保管域Type(存储区域)/ - 保管区画(存储区)/ - 棚番&#xff08;Storage Bin 仓位&…...

Span<T> 是 C# 7.2 引入的重要类型

Span<T> 是 C# 7.2 引入的一个非常重要的类型&#xff0c;它提供了一种低开销、类型安全的方式来操作连续的内存区域。Span<T> 本质上是一个结构体&#xff0c;它封装了一个内存段的引用&#xff08;通过指针&#xff09;以及该内存段的长度。由于它直接操作内存&a…...

Python办公自动化:初识 `openpyxl`

1.1 什么是 openpyxl&#xff1f; openpyxl 是一个用于读写 Excel 2010 xlsx/xlsm/xltx/xltm 文件的 Python 库。它允许我们通过 Python 脚本自动化处理 Excel 文件&#xff0c;包括创建新的工作簿、修改现有的工作簿、格式化单元格、处理公式和图表等功能。这对于办公自动化、…...

Pocketbase实战体验:内置数据库与实时功能如何超越传统MySQL

Pocketbase 是一个开源的实时后端服务器&#xff0c;内置了数据库、实时订阅、用户认证、RESTful API 等功能&#xff0c;而 MySQL 是一个广泛使用的关系数据库管理系统。以下是 Pocketbase 相对于 MySQL 的一些潜在优点&#xff1a; 完整的后端解决方案 一体化&#xff1a;P…...

ChatGPT 3.5/4.0 新手使用手册(详细版)

1. 什么是 ChatGPT&#xff1f; ChatGPT是由 OpenAI 开发的先进人工智能语言模型&#xff0c;能够理解并生成自然语言文本。它可以帮助你进行写作、回答问题、提供建议&#xff0c;甚至参与对话。ChatGPT 3.5 和 4.0 是两个不同版本&#xff0c;它们都拥有强大的语言处理能力&…...

【Java学习】Stream流详解

所属专栏&#xff1a;Java学习 Stream流是JDK 8引入的一个概念&#xff0c;它提供了一种高效且表达力强的方式来处理数据集合&#xff08;如List、Set等&#xff09;或数组。Stream API可以以声明性方式&#xff08;指定做什么&#xff09;来处理数据序列。流操作可以被分为两大…...

Oracle(69)什么是表压缩(Table Compression)?

表压缩&#xff08;Table Compression&#xff09;是一种数据库优化技术&#xff0c;用于减少表数据的存储空间和提高I/O性能。通过压缩表数据&#xff0c;可以显著减少存储需求&#xff0c;并在某些情况下提高查询性能&#xff0c;特别是对于只读或主要是读取操作的表。表压缩…...

java JUC编程

Java并发工具包&#xff08;JUC&#xff09;&#xff0c;全称Java Util Concurrent&#xff0c;是Java提供的一个用于构建多线程应用程序的工具包&#xff0c;位于java.util.concurrent包及其子包中。 并发编程主要解决以下三个经典问题&#xff1a; 1. **原子性问题&#xf…...

vue3+element-plus表格分页选中加默认回显选中

1.需求 某个表单需要选择多条数据&#xff0c;点击选择按钮&#xff0c;弹框出来一个分页列表&#xff0c;选择多条数据&#xff0c;外面表单中显示选中的数据&#xff0c;可以删除数据&#xff0c;再次点击按钮&#xff0c;回显当前选中的数据。 2.解决办法 1.el-table加ro…...

Erupt 项目搭建

创建Spring Boot项目 Maven依赖 Spring Boot版本为 2.7.10&#xff0c;erupt版本为 1.12.14 erupt版本要与Spring Boot版本适配&#xff0c;3.x.x版本Spring Boot暂不适用说是 <properties><erupt.version>1.12.14</erupt.version></properties> <…...