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

做火影网站背景图微网站建设的现状

做火影网站背景图,微网站建设的现状,常州金坛建设局网站,东莞网站开发哪家强参考链接地址:如何使用Qwen-VL模型_大模型服务平台百炼(Model Studio)-阿里云帮助中心 在windows下,使用python语言测试,版本:Python 3.8.9 一. 使用QVQ模型解决图片数学难题 import os import base64 import requests# base 64 …

参考链接地址:如何使用Qwen-VL模型_大模型服务平台百炼(Model Studio)-阿里云帮助中心

在windows下,使用python语言测试,版本:Python 3.8.9

一. 使用QVQ模型解决图片数学难题

import os
import base64
import requests#  base 64 编码格式
def encode_image(image_path):with open(image_path, "rb") as image_file:return base64.b64encode(image_file.read()).decode("utf-8")# 将xxxx/test.png替换为你本地图像的绝对路径
base64_image = encode_image("D:\\AI\\Ali_AI\\test1.png")
# 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx"
#api_key = os.getenv("DASHSCOPE_API_KEY")
#qwen-vl-max-latest
api_key="sk-cb1a12c560fa441eabefdb2938c6cdff"
headers = {"Content-Type": "application/json", "Authorization": f"Bearer {api_key}"}
payload = {"model": "qwen-vl-max-latest","messages": [{"role": "system","content": [{"type":"text","text": "You are a helpful assistant."}]},{"role": "user","content": [{"type": "image_url",# 需要注意,传入Base64,图像格式(即image/{format})需要与支持的图片列表中的Content Type保持一致。"f"是字符串格式化的方法。# PNG图像:  f"data:image/png;base64,{base64_image}"# JPEG图像: f"data:image/jpeg;base64,{base64_image}"# WEBP图像: f"data:image/webp;base64,{base64_image}""image_url": {"url": f"data:image/png;base64,{base64_image}"},},{"type": "text", "text": "识别图片中的内容并输出"},],}],
}
response = requests.post("https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",headers=headers,json=payload,
)content1=response.json()["choices"][0]["message"]["content"]
print(content1)
payload = {"model": "qwen2-math-72b-instruct","messages": [{"role": "system","content": "You are a helpful assistant."},{"role": "user", "content": f"{content1},给出正确的答案,不需要过程分析"}],
}
response = requests.post("https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",headers=headers,json=payload,
)
print(response.json()["choices"][0]["message"]["content"]) 

1.先获取图片内容

使用模型:qwen-vl-max-latest

2.对数学难题进行解答

使用模型:qwen2-math-72b-instruct

二. 调用API实现图片内容提取

测试源码如下:

import os
import base64
import requests#  base 64 编码格式
def encode_image(image_path):with open(image_path, "rb") as image_file:return base64.b64encode(image_file.read()).decode("utf-8")# 将xxxx/test.png替换为你本地图像的绝对路径
base64_image = encode_image("D:\\AI\\Ali_AI\\test.jpg")
# 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx"
#api_key = os.getenv("DASHSCOPE_API_KEY")
api_key="sk-d9b2178c495e4ea7bd3a11e0fc71984a"
headers = {"Content-Type": "application/json", "Authorization": f"Bearer {api_key}"}
payload = {"model": "qwen-vl-max-latest","messages": [{"role": "system","content": [{"type":"text","text": "You are a helpful assistant."}]},{"role": "user","content": [{"type": "image_url",# 需要注意,传入Base64,图像格式(即image/{format})需要与支持的图片列表中的Content Type保持一致。"f"是字符串格式化的方法。# PNG图像:  f"data:image/png;base64,{base64_image}"# JPEG图像: f"data:image/jpeg;base64,{base64_image}"# WEBP图像: f"data:image/webp;base64,{base64_image}""image_url": {"url": f"data:image/png;base64,{base64_image}"},},{"type": "text", "text": "请扫描图片中的文字并输出?"},],}],
}
response = requests.post("https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",headers=headers,json=payload,
)
print(response.json()["choices"][0]["message"]["content"])

文件放置路径:

运行结果如下:

http://www.dtcms.com/wzjs/815250.html

相关文章:

  • 自动做网页的网站鹤岗网站建设
  • 广州公司网站制作招聘信息知更鸟wordpress
  • 车陂手机网站建设个人博客页面设计图
  • 学做美食视频在哪个网站手机网络营销策划方案
  • 网站备案 需要什么郑州网站建设兼职
  • 怎么建论坛网站长沙网站制作策划
  • 摄影素材库网站甘南北京网站建设
  • 觉得自己做的网站土怎么办成都建设银行网站首页
  • 作文网站源码自己做的网站出现iis7
  • 江苏 做网站产品seo基础优化
  • 免费注册网站域名做娱乐网站彩票代理
  • 武邑县建设局网站关键词规划师
  • 崇信门户网站留言回复创网科技
  • 哪家网站游戏做的比较好网页免费制作网站
  • 织梦dedecms绿色led照明公司企业网站模板 下载建设网站程序
  • 基于c 的网站开发做棋牌网站违法吗
  • 广州网站搭建哪家好民族服装的网站建设
  • app商城开发网站建设用什么网站做动感相册
  • 设计师可以做兼职的网站有哪些网站 建设 业务需求表
  • 上海网站搜索优化wordpress一片空白
  • 建站用什么平台好云相册网站怎么做
  • 网站推广的基本方法wordpress原创主题简单
  • 织梦移动网站后缀html企业整站模板网站
  • 哪个网站做logo好长春做网络推广的公司
  • 冷水滩城乡建设局网站小视频网站建设
  • 做英文简历的网站重庆广告制作加工厂
  • 网站备案丢失景观设计师
  • 2018年网站风格网站建设评选打分
  • 正规做网站的公司山东汽车行业网站开发
  • 高端品牌的推广关键词seo优化服务