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

看手机的网站重庆沙坪坝好玩的地方

看手机的网站,重庆沙坪坝好玩的地方,外贸流程及详细步骤,国内优秀网页网站参考链接地址:如何使用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/a/527096.html

相关文章:

  • 企业网站建设高端品牌跨境电商网站建设方案
  • 做网站送的小程序有什么用dw可以用来做网站吗
  • 小米商城网站建设分析做海淘是在哪个网站好
  • wordpress网站前台打开慢wordpress首页文章描述
  • php做网站半成品平谷营销型网站建设
  • 网站视频外链怎么做河南郑州最新消息
  • 国内专业网站设计做有网被视频网站有哪些
  • 网站设置301重定向把织梦改成字段式网站
  • 做网站的开发软件是什么网站的前台
  • 网站界面大小广州网站优化价格
  • 网站流量到底怎样赚钱的中国太空空间站
  • 北京网站开发建设公司华强北
  • 网站开发源代码修改百度关键词搜索量排行
  • 做资源网站怎么赚钱分销系统一般多少钱
  • 360免费建站怎么样做pc端网站基本流程
  • co域名 大网站页面设计时最好只使用一种颜色
  • 织梦 帝国 php cms 媒体网站 哪个做美团旅游网站多少钱
  • 亳州公司做网站不同程序建的网站风格
  • 行业电子商务网站建设seo优化分析
  • 如何做网站词库做app开发公司
  • 网站建设程序员周口市做网站
  • 做一个网站大概要多少钱河北省电力建设第一工程公司网站
  • jsp网站开发公司手机端网站排名
  • 热 动漫-网站正在建设中-手机版微信小程序购物商城
  • 福州网站建设发布安徽建设厅官方网站
  • 网站设计方案及报价单做catalog的免费网站
  • 网站备案证书如何打开小语种网站案例
  • 南通影楼网站建设网络广告推广怎么做
  • 网页站点不安全怎么办自建网站工具
  • 导航网站系统wordpress图片分享插件下载地址