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

黑色网站绿叶网站怎么做

黑色网站,绿叶网站怎么做,网络规划与设计心得体会,做电商网站费用基于现有的API平台做一些实用的AI小应用。 API服务商#xff1a;阿里云百炼 云服务器#xff1a;阿里云#xff08;2核2GB#xff09; 部署框架#xff1a;gradio 调用框架#xff1a;openai 语言#xff1a;Python #xff08;注#xff1a;若搭建网站或API接口…基于现有的API平台做一些实用的AI小应用。 API服务商阿里云百炼 云服务器阿里云2核2GB 部署框架gradio 调用框架openai 语言Python 注若搭建网站或API接口出现调用异常会立即关闭停止使用 1、搭建个人DeepSeek-v3、R1网站 搭建代码DeepSeek-v3如下目前DP官网无法充值后续其官网稳定可以使用官网API进行调用当下使用阿里云百炼中集成的接口进行调用 import gradio as gr from openai import OpenAI import yamldef get_apikey(path apikey.yaml):with open(path, r) as f:config yaml.safe_load(f)res config[apikey]return resdef deepseek_academic_repeat(question):client OpenAI(api_key get_apikey()[dashscope],base_url https://dashscope.aliyuncs.com/compatible-mode/v1)response client.chat.completions.create(modeldeepseek-v3,messages[{role: user, content: f{question}},],max_tokens4096,temperature1.0,streamFalse)# print(response.choices[0].message.content)return response.choices[0].message.contentinterface gr.Interface(fndeepseek_academic_repeat, # 润色函数inputs[gr.Textbox(label输入, placeholder问题输入,lines20),],# 输入框outputsgr.Textbox(labelDeepSeek-v3回复,lines20), # 输出框title临时DeepSeek, # 应用标题description基于阿里云Dashscope中集成的DeepSeek-v3接口实现对DP-v3的使用 # 应用描述 )if __name__ __main__:interface.launch(server_name0.0.0.0, server_port5566, shareTrue) # 指定端口号结果如下 公网可直接访问 DeepSeek-v3临时DeepSeekhttp://47.94.104.2:5566/http://47.94.104.2:5566/DeepSeek-r1 临时DeepSeek-R1http://47.94.104.2:3344/http://47.94.104.2:3344/ 2、基于文本生成模型搭建学术风格润色网站 基于大语言模型实现学术风格润色网站。使用DeepSeek-v3模型。 搭建代码如下 import gradio as gr from openai import OpenAI import yamldef get_apikey(path apikey.yaml):with open(path, r) as f:config yaml.safe_load(f)res config[apikey]return resdef deepseek_academic_repeat(question):client OpenAI(api_key get_apikey()[dashscope],base_url https://dashscope.aliyuncs.com/compatible-mode/v1)academic_prompt # 角色 # 你是一个学术科技论文修改专家你需要对用户输入论文进行润色或修改使其符合学术写作规范。# 任务 # 对用户上传文本进行润色和修改主要从以下几个角度进行1、使用正式的学术语言避免口语化表达确保逻辑清晰。2、论述严谨增强论证的说服力。3、确保描述的视角的一致性保持与笔者的描述视角相同。4、改进句子结构使其更简洁和规范。5、增强术语的使用确保准确表达领域内的概念和观点。6、检查拼写、语法和标点符号错误确保文本的语言准确无误。# 限制 # 不得编造。输出语言与输入语言保持严格一致。# 输出 # 只输出润色的结果不输入任何其他的无关内容。response client.chat.completions.create(modeldeepseek-v3,messages[{role: system, content: academic_prompt},{role: user, content: f{question}},],max_tokens2024,temperature0.15,streamFalse)# print(response.choices[0].message.content)return response.choices[0].message.contentinterface gr.Interface(fndeepseek_academic_repeat, # 润色函数inputs[gr.Textbox(label输入文本, placeholder请输入需要润色的文本,lines20),],# 输入框outputsgr.Textbox(label润色后的文本,lines20), # 输出框title文本润色工具, # 应用标题description在左侧输入需要润色的文本右侧将显示润色后的文本。 # 应用描述 )if __name__ __main__:interface.launch(server_name0.0.0.0, server_port8443, shareTrue) # 指定端口号公网可直接访问 文本润色工具 文本润色工具http://47.94.104.2:8443/http://47.94.104.2:8443/ 3、结合OCR实现PDF全文润色并输出本地 第一步在云服务上开发功能并将该功能部署为API接口。 主要需要实现的功能包括图片文字提取OCR润色大模型并输出。OCR使用Qwen的视觉大模型Qwen-VL实现润色使用Qwen-Max实现。 功能开发如下 from openai import OpenAI import time import yaml,json from fastapi import FastAPI from pydantic import BaseModel import uvicornapp FastAPI()def get_apikey(path /root/MyProj/apikey.yaml):with open(path, r) as f:config yaml.safe_load(f)res config[apikey]return resdef qwen_ocr(base64_image_code,addr_type):# 获取今天的年月日today time.strftime(%Y-%m-%d, time.localtime())# print(today)if today 2025-05-03:print(free test is ending!)return {res: free test is ending!}client OpenAI(api_keyget_apikey()[dashscope],base_urlhttps://dashscope.aliyuncs.com/compatible-mode/v1,)completion client.chat.completions.create(modelqwen-vl-ocr,messages[{role: user,content: [{type: image_url,image_url: fdata:image/{addr_type};base64,{base64_image_code},min_pixels: 28 * 28 * 4,max_pixels: 1280 * 784},# 目前为保证识别效果模型内部会统一使用Read all the text in the image.作为text的值用户输入的文本不会生效。{type: text, text: Read all the text in the image.},]}])res_dict json.loads(completion.model_dump_json())res_text res_dict[choices][0][message][content]return {ocr_res: res_text}def qwen_max_repeat(content):client OpenAI(api_keyget_apikey()[dashscope],base_urlhttps://dashscope.aliyuncs.com/compatible-mode/v1,)completion client.chat.completions.create(modelqwen-max-2025-01-25,messages[{role: system,content: # 角色 # 你是一个学术科技论文修改专家你需要对用户输入论文进行润色或修改使其符合学术写作规范。# 任务 # 对用户上传文本进行润色和修改主要从以下几个角度进行1、使用正式的学术语言避免口语化表达确保逻辑清晰。2、论述严谨增强论证的说服力。3、确保描述的视角的一致性保持与笔者的描述视角相同。4、改进句子结构使其更简洁和规范删除不必要的重复内容或过于冗长的表述。5、增强术语的使用确保准确表达领域内的概念和观点。6、检查拼写、错别字、语法和标点符号错误确保文本的语言准确无误。# 限制 # 不得编造。输出语言与输入语言保持严格一致。# 输出 # 只输出润色的结果不输入任何其他的无关内容。并整理输出的排版与格式包括缩进和换行等。},{role: user,content: f{content}}],max_tokens4096,temperature0.12,streamFalse)res json.loads(completion.model_dump_json())return {response: res[choices][0][message][content]}class paper_revision_input(BaseModel):base64_image_code: straddr_type: strapp.post(/paper_revision) def main_process(func_input: paper_revision_input):content qwen_ocr(func_input.base64_image_code, func_input.addr_type)out qwen_max_repeat(content)return out[response]if __name__ __main__:uvicorn.run(app, host0.0.0.0, port99) 接口为http://47.94.104.2:99/paper_revision 第二步在本地调用此服务 技术流程为pdf读取--分割图像--图像文字识别--润色--输出 import io from PIL import Image import base64 import requests from tqdm import tqdm# pdf2img optional Method 1 # # from pdf2image import convert_from_path # 该方法需要安装popplerlinux下较为方便在win则较为麻烦win下建议使用方法2。 # def read_pdf2ImgLs(pdf_path) - list: # images_ls convert_from_path(pdf_path,dpi300) # return images_ls# pdf2img optional Method 2 # import fitz # pip install pymupdf def read_pdf2ImgLs(pdf_path) - list:pdf fitz.open(pdf_path)images_ls []zoom_x 2.0zoom_y 2.0for i,pg in enumerate(pdf):mat fitz.Matrix(zoom_x, zoom_y)pix pg.get_pixmap(matrixmat)img Image.frombytes(RGB, [pix.width, pix.height], pix.samples)images_ls.append(img)return images_lsdef PILimage2base64(image):buffered io.BytesIO()image_type PNGimage.save(buffered, formatimage_type)return base64.b64encode(buffered.getvalue()).decode(),image_typedef paper_revision(pdf_path):# 设置输出txt路径output_txt output.txtimage_ls read_pdf2ImgLs(pdf_path)for page,image in enumerate(tqdm(image_ls, descProcessing pages)):base64code,addr_type PILimage2base64(image)input_data {base64_image_code: base64code,addr_type: addr_type,}repeat_response requests.post(http://47.94.104.2:99/paper_revision,jsoninput_data,)assert repeat_response.status_code 200result repeat_response.content.decode(utf-8)cleaned_string result.strip()decoded_string cleaned_string.replace(\\n, \n).replace(\\\\, \\)with open(output_txt, a, encodingutf-8) as f:f.write(decoded_string\n)f.write(f(page:{page1})\n)if __name__ __main__:paper_revision(test_file.pdf) 调用结果 输出结果 原始pdf 大模型输出结果 以上欢迎交流及批评。  拥抱变化探索未知。 共勉。
http://www.w-s-a.com/news/891716/

相关文章:

  • 泰安网站建设哪里有公司如何注册网站
  • 做网站开专票税钱是多少个点上海市有哪些公司
  • 寿县有做网站开发的吗宁波网站建设方式
  • 网站建设和网站推广服务器怎么发布网站
  • 比较好的摄影网站雅安市政建设公司网站
  • 网站与微信区别wordpress 站内信
  • 宁夏网站开发设计说明书源码下载脚本之家
  • 邱县做网站百度搜索排名机制
  • 运城个人网站建设智慧团建系统官方网站登录
  • 公司营业执照可以做几个网站一家专门做母婴的网站
  • 网站建设商标属于哪个类别搜狗seo快速排名公司
  • 织梦做商城网站企业网络建站
  • 网站后期维护都有什么wordpress首页加图片
  • 展会网站怎么做网页设计与制作教程版徐洪亮课后答案
  • 石景山网站建设设计公司建设网站怎么建立服务器
  • 本地生活服务平台app网站关键词优化原理
  • 建网站的公司叫什么重庆论坛建站模板
  • 湖北网站制作公司银川网站建设哪家不错
  • 网站后台演示地址服装网站建设公司推荐
  • 湖北钟祥建设局网站旅游哪个网站最好
  • 浙江建设工程信息网站辽宁建设工程信息网场内业绩什么意思
  • 郑州做网站公司 汉狮网络专业图片搜集网站怎么做
  • 网站托管是什么品牌推广营销平台
  • 制作网站的难度贵州省兴义市建设局网站
  • 永春建设局网站室内设计师培训班学费多少
  • 做仿站如何获取网站源码windows2012做网站
  • 网站建设最好的公司东莞外贸网站
  • 普兰店网站建设一般做网站什么价格
  • 网站建设的发展目标甘肃网站设计公司
  • 常州西站建设规划室内装修设计学校哪里好