Kimi-VL-A3B-Thinking代码实例:Python调用vLLM API实现批量图片问答脚本

news2026/4/3 14:58:17
Kimi-VL-A3B-Thinking代码实例Python调用vLLM API实现批量图片问答脚本1. 引言从手动提问到批量处理如果你已经通过vLLM部署了Kimi-VL-A3B-Thinking模型并且体验过Chainlit前端那种一问一答的交互方式可能会发现一个问题每次只能处理一张图片、一个问题。当你有几十张产品图片需要分析或者有成百上千的文档截图需要识别时这种手动操作的方式就显得效率低下了。想象一下这样的场景电商团队需要分析竞品店铺的装修风格手头有几百张店铺截图内容审核团队需要识别用户上传图片中的违规信息每天要处理数千张图片研究人员需要从大量图表中提取数据一张张手动上传太费时间。这时候一个能够批量处理图片问答的脚本就显得尤为重要。本文将带你一步步实现一个Python脚本通过直接调用vLLM的API接口实现对多张图片的批量问答处理。这个脚本不仅能大幅提升工作效率还能让你更深入地理解模型的后端调用机制。无论你是开发者、数据分析师还是业务运营人员掌握这个技能都能让你的工作事半功倍。2. 环境准备与基础概念2.1 你需要准备什么在开始编写代码之前确保你已经具备以下条件已部署的Kimi-VL-A3B-Thinking模型通过vLLM成功部署了模型服务并且能够通过Chainlit前端正常访问Python环境建议使用Python 3.8或更高版本必要的Python库主要是requests库用于HTTP请求PIL或opencv-python用于图片处理模型服务的API地址通常是http://localhost:8000/v1具体地址根据你的部署配置而定如果你还没有安装必要的库可以通过以下命令快速安装pip install requests pillow2.2 理解vLLM的API接口vLLM提供了一个标准的OpenAI兼容的API接口这意味着你可以像调用ChatGPT API一样调用本地部署的模型。对于Kimi-VL这样的多模态模型API调用需要特殊处理图片数据。简单来说调用过程分为三步将图片转换为base64编码的字符串构建包含图片和问题的请求数据发送HTTP请求到模型服务并获取响应2.3 脚本设计思路我们的批量处理脚本需要实现以下功能读取指定文件夹中的所有图片对每张图片提出相同或不同的问题批量发送请求到模型服务收集并整理所有回答结果将结果保存到文件供后续分析3. 核心代码实现3.1 基础的单图片问答函数让我们先从最简单的单张图片问答开始这是整个批量处理的基础。import base64 import requests import json from pathlib import Path from PIL import Image import io def ask_image_single(image_path, question, api_urlhttp://localhost:8000/v1): 单张图片问答函数 参数: image_path: 图片文件路径 question: 要问的问题 api_url: vLLM API地址默认为本地8000端口 返回: 模型的回答文本 # 1. 读取并编码图片 try: with open(image_path, rb) as image_file: # 将图片转换为base64字符串 encoded_image base64.b64encode(image_file.read()).decode(utf-8) except FileNotFoundError: print(f错误找不到图片文件 {image_path}) return None except Exception as e: print(f读取图片时出错: {e}) return None # 2. 构建请求数据 # 注意多模态模型的请求格式与纯文本模型不同 request_data { model: kimi-vl-a3b-thinking, # 模型名称根据实际部署调整 messages: [ { role: user, content: [ { type: text, text: question }, { type: image_url, image_url: { url: fdata:image/jpeg;base64,{encoded_image} } } ] } ], max_tokens: 512, # 最大生成token数 temperature: 0.7, # 温度参数控制随机性 } # 3. 发送请求 try: response requests.post( f{api_url}/chat/completions, headers{Content-Type: application/json}, datajson.dumps(request_data) ) # 检查响应状态 if response.status_code 200: result response.json() # 提取回答内容 answer result[choices][0][message][content] return answer else: print(fAPI请求失败状态码: {response.status_code}) print(f错误信息: {response.text}) return None except requests.exceptions.ConnectionError: print(连接失败请检查模型服务是否已启动) return None except Exception as e: print(f请求过程中出错: {e}) return None # 测试单张图片问答 if __name__ __main__: # 测试代码 - 使用示例图片和问题 test_image test_image.jpg # 替换为你的测试图片路径 test_question 图中店铺名称是什么 answer ask_image_single(test_image, test_question) if answer: print(f问题: {test_question}) print(f回答: {answer})这个基础函数已经能够完成单张图片的问答。你可以先运行这个测试代码确保能够正常连接到你的模型服务。3.2 批量处理脚本完整实现现在让我们扩展这个基础函数实现完整的批量处理功能。import base64 import requests import json import os from pathlib import Path import time from datetime import datetime import csv class BatchImageQA: 批量图片问答处理类 def __init__(self, api_urlhttp://localhost:8000/v1, model_namekimi-vl-a3b-thinking): 初始化批量处理类 参数: api_url: vLLM API地址 model_name: 模型名称 self.api_url api_url self.model_name model_name self.supported_formats [.jpg, .jpeg, .png, .bmp, .gif] def encode_image(self, image_path): 将图片编码为base64字符串 参数: image_path: 图片文件路径 返回: base64编码的图片字符串 try: with open(image_path, rb) as image_file: encoded_string base64.b64encode(image_file.read()).decode(utf-8) return encoded_string except Exception as e: print(f编码图片 {image_path} 时出错: {e}) return None def ask_single_image(self, image_path, question, max_tokens512, temperature0.7): 单张图片问答 参数: image_path: 图片路径 question: 问题文本 max_tokens: 最大生成token数 temperature: 温度参数 返回: 字典包含图片名、问题、回答、处理状态 # 编码图片 encoded_image self.encode_image(image_path) if not encoded_image: return { image_name: os.path.basename(image_path), question: question, answer: None, status: error, error: 图片编码失败 } # 构建请求 request_data { model: self.model_name, messages: [ { role: user, content: [ {type: text, text: question}, { type: image_url, image_url: { url: fdata:image/jpeg;base64,{encoded_image} } } ] } ], max_tokens: max_tokens, temperature: temperature, } # 发送请求 try: start_time time.time() response requests.post( f{self.api_url}/chat/completions, headers{Content-Type: application/json}, datajson.dumps(request_data), timeout60 # 60秒超时 ) end_time time.time() if response.status_code 200: result response.json() answer result[choices][0][message][content] return { image_name: os.path.basename(image_path), question: question, answer: answer, status: success, processing_time: round(end_time - start_time, 2) } else: return { image_name: os.path.basename(image_path), question: question, answer: None, status: error, error: fAPI错误: {response.status_code}, response_text: response.text[:200] # 只保留前200字符 } except requests.exceptions.Timeout: return { image_name: os.path.basename(image_path), question: question, answer: None, status: error, error: 请求超时 } except Exception as e: return { image_name: os.path.basename(image_path), question: question, answer: None, status: error, error: str(e) } def batch_process(self, image_folder, questions, output_fileresults.csv, delay1): 批量处理文件夹中的图片 参数: image_folder: 图片文件夹路径 questions: 问题列表或字典图片名-问题 output_file: 输出结果文件 delay: 请求间隔秒避免过快请求 返回: 处理结果列表 # 获取所有支持的图片文件 image_files [] for ext in self.supported_formats: image_files.extend(Path(image_folder).glob(f*{ext})) image_files.extend(Path(image_folder).glob(f*{ext.upper()})) if not image_files: print(f在文件夹 {image_folder} 中未找到支持的图片文件) return [] print(f找到 {len(image_files)} 张图片) results [] # 处理每张图片 for i, image_path in enumerate(image_files, 1): print(f处理第 {i}/{len(image_files)} 张: {image_path.name}) # 确定问题 if isinstance(questions, dict): # 如果questions是字典按图片名查找对应问题 question questions.get(image_path.name, questions.get(default, 描述这张图片)) elif isinstance(questions, list): # 如果questions是列表按顺序使用或循环使用 question questions[(i-1) % len(questions)] else: # 如果questions是字符串所有图片问相同问题 question questions # 发送请求 result self.ask_single_image(image_path, question) results.append(result) # 显示处理结果 if result[status] success: print(f 成功: {result[answer][:50]}...) else: print(f 失败: {result.get(error, 未知错误)}) # 保存进度每处理5张图片保存一次 if i % 5 0: self.save_results(results, output_file) print(f已保存进度到 {output_file}) # 延迟避免请求过快 if i len(image_files): time.sleep(delay) # 最终保存所有结果 self.save_results(results, output_file) print(f处理完成结果已保存到 {output_file}) # 打印统计信息 success_count sum(1 for r in results if r[status] success) print(f\n处理统计:) print(f 总图片数: {len(results)}) print(f 成功: {success_count}) print(f 失败: {len(results) - success_count}) return results def save_results(self, results, output_file): 保存结果到CSV文件 参数: results: 结果列表 output_file: 输出文件路径 if not results: return # 确定CSV文件的列 fieldnames [image_name, question, answer, status] # 如果有错误信息添加到列中 if any(error in r for r in results): fieldnames.append(error) if any(processing_time in r for r in results): fieldnames.append(processing_time) # 写入CSV文件 with open(output_file, w, newline, encodingutf-8) as csvfile: writer csv.DictWriter(csvfile, fieldnamesfieldnames) writer.writeheader() for result in results: # 只写入需要的字段 row {field: result.get(field, ) for field in fieldnames} writer.writerow(row) # 使用示例 def main(): 批量处理示例 # 1. 创建处理器实例 processor BatchImageQA( api_urlhttp://localhost:8000/v1, # 根据你的部署调整 model_namekimi-vl-a3b-thinking ) # 2. 定义问题和处理方式 # 方式一所有图片问相同问题 same_question 描述这张图片的主要内容 # 方式二不同图片问不同问题使用字典 specific_questions { shop1.jpg: 图中店铺名称是什么, shop2.jpg: 这家店主要卖什么产品, product1.png: 这个产品的特点是什么, default: 简单描述这张图片 # 默认问题 } # 方式三按顺序使用问题列表 question_list [ 图片中有文字吗如果有是什么内容, 这张图片是什么场景, 图片的主要颜色是什么 ] # 3. 执行批量处理 results processor.batch_process( image_folder./images, # 你的图片文件夹路径 questionssame_question, # 可以选择上面任意一种方式 output_filebatch_results.csv, delay0.5 # 请求间隔0.5秒 ) # 4. 查看结果摘要 print(\n 处理结果摘要 ) for result in results[:5]: # 显示前5个结果 if result[status] success: print(f{result[image_name]}: {result[answer][:100]}...) else: print(f{result[image_name]}: 处理失败 - {result.get(error, 未知错误)}) if __name__ __main__: main()4. 实际应用场景示例4.1 电商图片分析实战假设你是一个电商运营需要分析竞品店铺的装修风格和产品展示。你可以这样使用我们的脚本def analyze_ecommerce_images(): 电商图片分析示例 processor BatchImageQA() # 针对电商图片的特定问题 ecommerce_questions { shop_interior.jpg: 这家店铺的装修风格是什么主要使用了哪些颜色, product_display.jpg: 产品是如何展示的有哪些促销信息, customer_service.jpg: 图片中显示了哪些客户服务信息, payment_methods.jpg: 支持哪些支付方式, default: 这张图片对顾客的吸引力如何有哪些可以改进的地方 } # 批量分析店铺截图 results processor.batch_process( image_folder./shop_screenshots, questionsecommerce_questions, output_fileecommerce_analysis.csv, delay0.3 ) # 生成分析报告 print( 电商店铺分析报告 ) for result in results: if result[status] success]: print(f\n图片: {result[image_name]}) print(f分析: {result[answer]}) print(- * 50) # 运行电商分析 analyze_ecommerce_images()4.2 文档图片OCR与信息提取如果你有很多扫描的文档或截图需要提取文字信息def extract_document_info(): 文档信息提取示例 processor BatchImageQA() # 文档处理问题 document_questions [ 提取图片中的所有文字内容, 这是什么类型的文档如合同、发票、报告等, 文档的标题或主题是什么, 有哪些重要的数字或日期, 文档的签发单位或个人是谁 ] # 批量处理文档图片 results processor.batch_process( image_folder./documents, questionsdocument_questions, # 循环使用问题列表 output_filedocument_extraction.csv ) # 整理提取的信息 extracted_texts [] for result in results: if result[status] success] and 提取 in result[question]: extracted_texts.append({ file: result[image_name], text: result[answer] }) # 保存提取的文本 with open(extracted_texts.txt, w, encodingutf-8) as f: for item in extracted_texts: f.write(f {item[file]} \n) f.write(item[text] \n\n) print(f已提取 {len(extracted_texts)} 个文档的文字内容) # 运行文档提取 extract_document_info()4.3 社交媒体内容审核对于需要审核用户上传图片的场景def content_moderation_batch(): 内容审核批量处理示例 processor BatchImageQA() # 内容审核相关问题 moderation_questions 这张图片是否包含不适当内容请详细说明原因。 # 批量审核图片 results processor.batch_process( image_folder./user_uploads, questionsmoderation_questions, output_filemoderation_results.csv ) # 统计审核结果 flagged_content [] for result in results: if result[status] success]: answer_lower result[answer].lower() # 根据回答判断是否需要人工审核 if any(keyword in answer_lower for keyword in [不适当, 违规, 敏感, 暴力, 色情]): flagged_content.append({ image: result[image_name], reason: result[answer], timestamp: datetime.now().strftime(%Y-%m-%d %H:%M:%S) }) # 生成审核报告 print(f\n 内容审核报告 ) print(f总图片数: {len(results)}) print(f需要人工审核: {len(flagged_content)}) print(f通过自动审核: {len(results) - len(flagged_content)}) if flagged_content: print(\n需要人工审核的图片:) for item in flagged_content: print(f- {item[image]}: {item[reason][:100]}...) # 运行内容审核 content_moderation_batch()5. 高级功能与优化建议5.1 并发处理提升效率上面的脚本是顺序处理的如果图片很多处理时间会很长。我们可以使用多线程来加速处理import concurrent.futures from threading import Lock class ConcurrentBatchImageQA(BatchImageQA): 支持并发处理的批量图片问答类 def __init__(self, api_urlhttp://localhost:8000/v1, max_workers3): super().__init__(api_url) self.max_workers max_workers self.results_lock Lock() self.results [] def process_single_concurrent(self, args): 单张图片处理的并发版本 image_path, question args result self.ask_single_image(image_path, question) # 线程安全地添加结果 with self.results_lock: self.results.append(result) return result def batch_process_concurrent(self, image_folder, questions, output_fileresults_concurrent.csv): 并发批量处理 # 获取所有图片文件 image_files [] for ext in self.supported_formats: image_files.extend(Path(image_folder).glob(f*{ext})) if not image_files: print(未找到图片文件) return [] print(f找到 {len(image_files)} 张图片开始并发处理...) # 准备任务参数 tasks [] for i, image_path in enumerate(image_files): # 确定问题简化逻辑实际使用时可以根据需要调整 if isinstance(questions, str): question questions elif isinstance(questions, list): question questions[i % len(questions)] else: question 描述这张图片 tasks.append((image_path, question)) # 使用线程池并发处理 with concurrent.futures.ThreadPoolExecutor(max_workersself.max_workers) as executor: # 提交所有任务 future_to_task {executor.submit(self.process_single_concurrent, task): task for task in tasks} # 显示进度 completed 0 for future in concurrent.futures.as_completed(future_to_task): completed 1 if completed % 5 0: print(f已处理 {completed}/{len(tasks)} 张图片) # 保存结果 self.save_results(self.results, output_file) print(f处理完成结果已保存到 {output_file}) return self.results # 使用并发处理 def concurrent_example(): processor ConcurrentBatchImageQA(max_workers5) # 5个并发线程 results processor.batch_process_concurrent( image_folder./large_image_collection, questions描述这张图片的主要内容, output_fileconcurrent_results.csv ) print(f并发处理完成共处理 {len(results)} 张图片) # 运行并发示例 # concurrent_example()5.2 错误处理与重试机制在实际使用中网络波动或服务暂时不可用是常见问题。添加重试机制可以提高脚本的稳定性def ask_with_retry(self, image_path, question, max_retries3, retry_delay2): 带重试机制的图片问答 参数: image_path: 图片路径 question: 问题 max_retries: 最大重试次数 retry_delay: 重试延迟秒 返回: 处理结果 for attempt in range(max_retries): try: result self.ask_single_image(image_path, question) if result[status] success: return result elif attempt max_retries - 1: # 不是最后一次尝试 print(f第{attempt1}次尝试失败{retry_delay}秒后重试...) time.sleep(retry_delay) retry_delay * 1.5 # 指数退避 else: return result except Exception as e: if attempt max_retries - 1: print(f请求异常: {e}{retry_delay}秒后重试...) time.sleep(retry_delay) retry_delay * 1.5 else: return { image_name: os.path.basename(image_path), question: question, answer: None, status: error, error: f重试{max_retries}次后失败: {str(e)} } return { image_name: os.path.basename(image_path), question: question, answer: None, status: error, error: 达到最大重试次数 }5.3 结果分析与可视化处理完成后我们可能需要对结果进行进一步分析import pandas as pd import matplotlib.pyplot as plt from wordcloud import WordCloud def analyze_results(results_filebatch_results.csv): 分析处理结果 # 读取结果 df pd.read_csv(results_file) print( 结果分析 ) print(f总处理数: {len(df)}) print(f成功率: {(df[status] success).sum() / len(df) * 100:.1f}%) if processing_time in df.columns: avg_time df[df[processing_time] 0][processing_time].mean() print(f平均处理时间: {avg_time:.2f}秒) # 成功结果分析 success_df df[df[status] success] if len(success_df) 0: # 回答长度分析 success_df[answer_length] success_df[answer].str.len() print(f\n回答长度统计:) print(f 最短: {success_df[answer_length].min()} 字符) print(f 最长: {success_df[answer_length].max()} 字符) print(f 平均: {success_df[answer_length].mean():.1f} 字符) # 生成词云 all_text .join(success_df[answer].dropna()) if all_text: wordcloud WordCloud( width800, height400, background_colorwhite, max_words100 ).generate(all_text) plt.figure(figsize(10, 5)) plt.imshow(wordcloud, interpolationbilinear) plt.axis(off) plt.title(回答内容词云) plt.savefig(wordcloud.png, dpi300, bbox_inchestight) print(词云图已保存为 wordcloud.png) # 错误分析 error_df df[df[status] error] if len(error_df) 0: print(f\n错误分析:) error_counts error_df[error].value_counts() for error, count in error_counts.items(): print(f {error}: {count}次) return df # 运行分析 # analyze_results(batch_results.csv)6. 常见问题与解决方案6.1 连接问题问题脚本无法连接到模型服务解决方案检查模型服务是否正常运行cat /root/workspace/llm.log确认API地址是否正确默认是http://localhost:8000/v1检查防火墙或网络设置确保端口8000可访问尝试使用curl测试连接curl http://localhost:8000/v1/models6.2 图片处理问题问题某些图片无法正常处理解决方案确保图片格式受支持jpg、png、bmp、gif检查图片文件是否损坏对于超大图片可以先压缩或调整尺寸添加图片预处理代码def preprocess_image(image_path, max_size(1024, 1024)): 预处理图片调整大小、转换格式 from PIL import Image try: img Image.open(image_path) # 调整大小保持宽高比 img.thumbnail(max_size, Image.Resampling.LANCZOS) # 转换为RGB模式处理RGBA或CMYK图片 if img.mode in (RGBA, LA, P): rgb_img Image.new(RGB, img.size, (255, 255, 255)) rgb_img.paste(img, maskimg.split()[-1] if img.mode RGBA else None) img rgb_img elif img.mode ! RGB: img img.convert(RGB) # 保存为临时文件 temp_path ftemp_{os.path.basename(image_path)} img.save(temp_path, JPEG, quality85) return temp_path except Exception as e: print(f预处理图片失败: {e}) return image_path # 返回原路径6.3 性能优化问题处理速度太慢优化建议使用并发处理如上面的ConcurrentBatchImageQA类调整请求间隔找到最佳平衡点批量编码图片减少重复操作使用连接池复用HTTP连接6.4 结果质量提升问题模型回答不够准确或详细改进方法优化问题表述更具体明确调整temperature参数较低值更确定较高值更有创造性增加max_tokens让模型生成更详细的回答使用思维链提示Chain-of-Thought promptingdef ask_with_cot(self, image_path, question): 使用思维链提示获得更详细的回答 cot_prompt f请仔细分析这张图片然后回答以下问题{question} 请按照以下步骤思考 1. 首先描述你看到的图片内容 2. 然后分析图片中的关键元素 3. 最后基于分析回答具体问题 请确保回答详细且准确。 return self.ask_single_image(image_path, cot_prompt, max_tokens1024)7. 总结与下一步建议通过本文的代码实例你已经掌握了如何使用Python调用vLLM API来实现Kimi-VL-A3B-Thinking模型的批量图片问答。这个脚本不仅能够大幅提升处理效率还能让你更灵活地应用这个强大的多模态模型。7.1 关键收获回顾基础调用掌握学会了如何通过API与Kimi-VL模型交互理解了多模态请求的构建方式批量处理实现实现了对多张图片的自动化处理支持不同的问题策略实用功能扩展添加了错误处理、并发处理、结果分析等实用功能实际应用场景看到了脚本在电商分析、文档处理、内容审核等场景下的应用7.2 你可以尝试的改进添加进度条使用tqdm库为批量处理添加美观的进度条支持更多格式扩展支持PDF、Word文档中的图片提取和处理集成到工作流将脚本集成到现有的数据处理流程中实现自动化构建Web界面使用Flask或Streamlit创建一个简单的Web界面方便非技术人员使用添加缓存机制对相同的图片和问题组合缓存结果避免重复处理7.3 性能调优建议批量大小调整根据你的硬件配置调整并发数找到最佳性能点图片预处理在处理前统一图片尺寸和格式减少传输数据量结果后处理添加对模型回答的自动总结、分类或情感分析监控与日志添加详细的日志记录方便问题排查和性能分析7.4 开始你的项目现在你可以基于这个脚本开始自己的项目了。无论是分析产品图片、处理文档扫描件还是审核用户上传内容这个工具都能为你节省大量时间。记住最好的学习方式就是动手实践——尝试修改代码添加新功能应用到你的实际工作中。如果你在使用的过程中遇到问题或者有改进的想法欢迎分享和交流。技术的价值在于应用而应用的魅力在于创造。开始你的批量图片分析之旅吧获取更多AI镜像想探索更多AI镜像和应用场景访问 CSDN星图镜像广场提供丰富的预置镜像覆盖大模型推理、图像生成、视频生成、模型微调等多个领域支持一键部署。

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

SpringBoot-17-MyBatis动态SQL标签之常用标签

文章目录 1 代码1.1 实体User.java1.2 接口UserMapper.java1.3 映射UserMapper.xml1.3.1 标签if1.3.2 标签if和where1.3.3 标签choose和when和otherwise1.4 UserController.java2 常用动态SQL标签2.1 标签set2.1.1 UserMapper.java2.1.2 UserMapper.xml2.1.3 UserController.ja…

wordpress后台更新后 前端没变化的解决方法

使用siteground主机的wordpress网站,会出现更新了网站内容和修改了php模板文件、js文件、css文件、图片文件后,网站没有变化的情况。 不熟悉siteground主机的新手,遇到这个问题,就很抓狂,明明是哪都没操作错误&#x…

网络编程(Modbus进阶)

思维导图 Modbus RTU(先学一点理论) 概念 Modbus RTU 是工业自动化领域 最广泛应用的串行通信协议,由 Modicon 公司(现施耐德电气)于 1979 年推出。它以 高效率、强健性、易实现的特点成为工业控制系统的通信标准。 包…

UE5 学习系列(二)用户操作界面及介绍

这篇博客是 UE5 学习系列博客的第二篇,在第一篇的基础上展开这篇内容。博客参考的 B 站视频资料和第一篇的链接如下: 【Note】:如果你已经完成安装等操作,可以只执行第一篇博客中 2. 新建一个空白游戏项目 章节操作,重…

IDEA运行Tomcat出现乱码问题解决汇总

最近正值期末周,有很多同学在写期末Java web作业时,运行tomcat出现乱码问题,经过多次解决与研究,我做了如下整理: 原因: IDEA本身编码与tomcat的编码与Windows编码不同导致,Windows 系统控制台…

利用最小二乘法找圆心和半径

#include <iostream> #include <vector> #include <cmath> #include <Eigen/Dense> // 需安装Eigen库用于矩阵运算 // 定义点结构 struct Point { double x, y; Point(double x_, double y_) : x(x_), y(y_) {} }; // 最小二乘法求圆心和半径 …

使用docker在3台服务器上搭建基于redis 6.x的一主两从三台均是哨兵模式

一、环境及版本说明 如果服务器已经安装了docker,则忽略此步骤,如果没有安装,则可以按照一下方式安装: 1. 在线安装(有互联网环境): 请看我这篇文章 传送阵>> 点我查看 2. 离线安装(内网环境):请看我这篇文章 传送阵>> 点我查看 说明&#xff1a;假设每台服务器已…

XML Group端口详解

在XML数据映射过程中&#xff0c;经常需要对数据进行分组聚合操作。例如&#xff0c;当处理包含多个物料明细的XML文件时&#xff0c;可能需要将相同物料号的明细归为一组&#xff0c;或对相同物料号的数量进行求和计算。传统实现方式通常需要编写脚本代码&#xff0c;增加了开…

LBE-LEX系列工业语音播放器|预警播报器|喇叭蜂鸣器的上位机配置操作说明

LBE-LEX系列工业语音播放器|预警播报器|喇叭蜂鸣器专为工业环境精心打造&#xff0c;完美适配AGV和无人叉车。同时&#xff0c;集成以太网与语音合成技术&#xff0c;为各类高级系统&#xff08;如MES、调度系统、库位管理、立库等&#xff09;提供高效便捷的语音交互体验。 L…

(LeetCode 每日一题) 3442. 奇偶频次间的最大差值 I (哈希、字符串)

题目&#xff1a;3442. 奇偶频次间的最大差值 I 思路 &#xff1a;哈希&#xff0c;时间复杂度0(n)。 用哈希表来记录每个字符串中字符的分布情况&#xff0c;哈希表这里用数组即可实现。 C版本&#xff1a; class Solution { public:int maxDifference(string s) {int a[26]…

【大模型RAG】拍照搜题技术架构速览:三层管道、两级检索、兜底大模型

摘要 拍照搜题系统采用“三层管道&#xff08;多模态 OCR → 语义检索 → 答案渲染&#xff09;、两级检索&#xff08;倒排 BM25 向量 HNSW&#xff09;并以大语言模型兜底”的整体框架&#xff1a; 多模态 OCR 层 将题目图片经过超分、去噪、倾斜校正后&#xff0c;分别用…

【Axure高保真原型】引导弹窗

今天和大家中分享引导弹窗的原型模板&#xff0c;载入页面后&#xff0c;会显示引导弹窗&#xff0c;适用于引导用户使用页面&#xff0c;点击完成后&#xff0c;会显示下一个引导弹窗&#xff0c;直至最后一个引导弹窗完成后进入首页。具体效果可以点击下方视频观看或打开下方…

接口测试中缓存处理策略

在接口测试中&#xff0c;缓存处理策略是一个关键环节&#xff0c;直接影响测试结果的准确性和可靠性。合理的缓存处理策略能够确保测试环境的一致性&#xff0c;避免因缓存数据导致的测试偏差。以下是接口测试中常见的缓存处理策略及其详细说明&#xff1a; 一、缓存处理的核…

龙虎榜——20250610

上证指数放量收阴线&#xff0c;个股多数下跌&#xff0c;盘中受消息影响大幅波动。 深证指数放量收阴线形成顶分型&#xff0c;指数短线有调整的需求&#xff0c;大概需要一两天。 2025年6月10日龙虎榜行业方向分析 1. 金融科技 代表标的&#xff1a;御银股份、雄帝科技 驱动…

观成科技:隐蔽隧道工具Ligolo-ng加密流量分析

1.工具介绍 Ligolo-ng是一款由go编写的高效隧道工具&#xff0c;该工具基于TUN接口实现其功能&#xff0c;利用反向TCP/TLS连接建立一条隐蔽的通信信道&#xff0c;支持使用Let’s Encrypt自动生成证书。Ligolo-ng的通信隐蔽性体现在其支持多种连接方式&#xff0c;适应复杂网…

铭豹扩展坞 USB转网口 突然无法识别解决方法

当 USB 转网口扩展坞在一台笔记本上无法识别,但在其他电脑上正常工作时,问题通常出在笔记本自身或其与扩展坞的兼容性上。以下是系统化的定位思路和排查步骤,帮助你快速找到故障原因: 背景: 一个M-pard(铭豹)扩展坞的网卡突然无法识别了,扩展出来的三个USB接口正常。…

未来机器人的大脑:如何用神经网络模拟器实现更智能的决策?

编辑&#xff1a;陈萍萍的公主一点人工一点智能 未来机器人的大脑&#xff1a;如何用神经网络模拟器实现更智能的决策&#xff1f;RWM通过双自回归机制有效解决了复合误差、部分可观测性和随机动力学等关键挑战&#xff0c;在不依赖领域特定归纳偏见的条件下实现了卓越的预测准…

Linux应用开发之网络套接字编程(实例篇)

服务端与客户端单连接 服务端代码 #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <arpa/inet.h> #include <pthread.h> …

华为云AI开发平台ModelArts

华为云ModelArts&#xff1a;重塑AI开发流程的“智能引擎”与“创新加速器”&#xff01; 在人工智能浪潮席卷全球的2025年&#xff0c;企业拥抱AI的意愿空前高涨&#xff0c;但技术门槛高、流程复杂、资源投入巨大的现实&#xff0c;却让许多创新构想止步于实验室。数据科学家…

深度学习在微纳光子学中的应用

深度学习在微纳光子学中的主要应用方向 深度学习与微纳光子学的结合主要集中在以下几个方向&#xff1a; 逆向设计 通过神经网络快速预测微纳结构的光学响应&#xff0c;替代传统耗时的数值模拟方法。例如设计超表面、光子晶体等结构。 特征提取与优化 从复杂的光学数据中自…