技术经验谈 技术经验谈
首页
  • 最佳实践

    • 抓包
    • 数据库操作
  • ui

    • 《JavaScript教程》
    • 《JavaScript高级程序设计》
    • 《ES6 教程》
    • 《Vue》
    • 《React》
    • 《TypeScript 从零实现 axios》
    • 《Git》
    • TypeScript
    • JS设计模式总结
  • 总纲
  • 整体开发框架
  • 技术文档
  • GitHub技巧
  • Nodejs
  • 博客搭建
  • 学习
  • 面试
  • 心情杂货
  • 实用技巧
  • 友情链接
关于
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)

hss01248

一号线程序员
首页
  • 最佳实践

    • 抓包
    • 数据库操作
  • ui

    • 《JavaScript教程》
    • 《JavaScript高级程序设计》
    • 《ES6 教程》
    • 《Vue》
    • 《React》
    • 《TypeScript 从零实现 axios》
    • 《Git》
    • TypeScript
    • JS设计模式总结
  • 总纲
  • 整体开发框架
  • 技术文档
  • GitHub技巧
  • Nodejs
  • 博客搭建
  • 学习
  • 面试
  • 心情杂货
  • 实用技巧
  • 友情链接
关于
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • 日志体系

  • springboot

  • ruoyi-vue-pro

    • ruoyi-vue-pro-oauth2支持不同客户端同时登录
    • 项目运行备忘
    • flutter项目

      • pullToRefresh在pc和web上的兼容问题
      • flutter字体问题汇总
      • flutter语音转文字和文字转语音
      • OCR识别技术选型
      • 语音转写-录音转文字各平台价格对比
      • dio拦截器实现OAuth2体系下登录态的维持
      • chatgpt flutter客户端项目实践
      • chatgpt图片识别描述功能
        • detail参数:
    • spring boot内实现流式代理
  • IT工具链
  • java学习路线和视频链接--尚硅谷
  • JDK动态代理原理和应用
  • jvm一图流
  • linux运维
  • spring boot笔记
  • spring-cloud学习资料和路线
  • springcloud alibaba
  • Springcloud学习笔记
  • 从java编译原理到Android aop
  • 大数据
  • 操作系统原理一图流
  • 汇编语言一图流
  • 泛型
  • 网关
  • 面试题精讲
  • java
  • ruoyi-vue-pro
  • flutter项目
hss01248
2024-02-20
目录

chatgpt图片识别描述功能

# chatGPT图片识别/描述

you can use dall-e-3 to generate images and gpt-4-vision-preview to understand images.

# 模型

使用gpt-4-1106-vision-preview

  • GPT-4 Turbo with vision is the same as the GPT-4 Turbo preview model and performs equally as well on text tasks but has vision capabilities added

# 价格

https://openai.com/pricing

![image-20240220104757258](../../../../../../Library/Application Support/typora-user-images/image-20240220104757258.png)

# 分辨率选择:

720p or 1080p?

从下面的计算对比可以看到,因为取整的缘故,720p和1080p的图一样的价格. 因为1080的图会被openai二次压缩到768*1365.

那么选一个768的整数倍:

image-20240220105106024

image-20240220105035987

而勾选了low resolution时,非常便宜,应该是会压缩到非常小:

image-20240220105414313

比较合适的分辨率: 768*1280

也就是短边压缩到768,长边等比压缩.

image-20240220110150734

# 接口

https://platform.openai.com/docs/guides/vision

curl https://api.openai.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "gpt-4-vision-preview",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "What’s in this image?"
          },
          {
            "type": "image_url",
            "image_url": {
              "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
              "detail": "high"
            }
          }
        ]
      }
    ],
    "max_tokens": 300
  }'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

# detail参数:

For low res mode, we expect a 512px x 512px image. For high res mode, the short side of the image should be less than 768px and the long side should be less than 2,000px.

All images with detail: low cost 85 tokens each. detail: high images are first scaled to fit within a 2048 x 2048 square, maintaining their aspect ratio. Then, they are scaled such that the shortest side of the image is 768px long. Finally, we count how many 512px squares the image consists of. Each of those squares costs 170 tokens. Another 85 tokens are always added to the final total.

image-20240220113300605

# 交互设计

拍照/相册选图

-> 提供裁剪功能

->最后压缩到768*xxx, 如果小于768, 则压缩到515,且请求时设置detail为low

->上传到自己的oss,拿到url

->调用open ai的接口, 添加prompt为:

What’s in this image?
how many people in the image?
...
1
2
3

# 注意事项

图像前置处理:

方向要正确

不要vr图,鱼眼图

文本识别只能处理拉丁语系的语言,不能处理中文,日文,韩文

# 代码库

图片裁剪:

https://pub.dev/packages/crop_your_image

编辑 (opens new window)
上次更新: 2024/03/21, 16:31:32
chatgpt flutter客户端项目实践
spring boot内实现流式代理

← chatgpt flutter客户端项目实践 spring boot内实现流式代理→

最近更新
01
截图后的自动压缩工具
12-27
02
图片视频文件根据exif批量重命名
12-27
03
spring boot内实现流式代理
02-18
更多文章>
Theme by Vdoing | Copyright © 2020-2025 | 粤ICP备20041795号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式