Midjourney Describe API 使用文档

news2024/10/7 4:31:55

Midjourney Describe API 使用文档

Midjourney Describe API 的主要功能是通过上传图片,获取对图片的描述。使用该 API,只需要传递图片文件,API 会返回图片的详细描述。无需繁琐的参数设置,即可获得高质量的图片描述。
支持多种图片格式:无论是 JPEG、PNG 还是 GIF 等主流图片格式,均能被轻松识别和处理。

本文档将详细介绍 Midjourney Describe API 的对接说明,帮助您轻松集成并充分利用该 API 的强大功能。通过 Midjourney Describe API,您可以轻松实现图片描述的自动化,提高业务效率。

申请流程

要使用 Midjourney Describe API,需要先到 申请页面 Midjourney Describe API 申请相应的服务,进入页面之后,点击「Acquire」按钮,如图所示:

申请页面

如果您尚未登录或注册,会自动跳转到登录页面邀请您来注册和登录,登录注册之后会自动返回当前页面。

首次申请时会有免费额度赠送,可以免费使用该 API。

请求示例

我们以一张图片为例,演示如何使用该 API。假设我们有一张风景图片,接下来演示如何上传该图片并获取描述。

请求示例图

示例图片

设置请求头和请求体

Request Headers 包括:

  • accept:指定接收 JSON 格式的响应结果,这里填写为 application/json
  • authorization:调用 API 的密钥,申请之后可以直接下拉选择。

Request Body 包括:

  • image_url:上传的图片文件地址。

代码示例

CURL
curl -X POST 'https://api.acedata.cloud/midjourney/describe' \
-H 'accept: application/json' \
-H 'authorization: Bearer a25106ab37dc4e1fb49fa30fcfa189c1' \
-H 'content-type: application/json' \
-d '{
  "image_url": "https://mmbiz.qpic.cn/mmbiz_png/KfpsxXibsEXicPX7AicBeqcx1RrlzQFWJTUcCckPVRfsUqicP3AgFIic3kWnEr3d77uc5J9C2FlKwjqaibEc7HpX1ib1w/640?wx_fmt=png&from=appmsg""
}'
Python
import requests

url = "https://api.acedata.cloud/midjourney/describe"

headers = {
    "accept": "application/json",
    "authorization": "Bearer 173186e544784a94a6a1ceee7c98f333",
    "content-type": "application/json"
}

payload = {
    "image_url": "https://mmbiz.qpic.cn/mmbiz_png/KfpsxXibsEXicPX7AicBeqcx1RrlzQFWJTUcCckPVRfsUqicP3AgFIic3kWnEr3d77uc5J9C2FlKwjqaibEc7HpX1ib1w/640?wx_fmt=png&from=appmsg""
}

response = requests.post(url, json=payload, headers=headers)
print(response.text)

响应示例

请求成功后,API 将返回图片的4条描述信息。例如:

{
  "descriptions": [
    "A cross-shaped road sign stands in the middle of an outdoor park, surrounded by trees and grasslands. The background is sunny with warm colors. There is sunlight shining through the leaves onto part of it. On one side of that street post there was also another sign with the lettering \"Kunming Park\", which looked very beautiful. This photo shows how wonderful nature can be. It gives people feelings like relaxation or tranquility in the style of nature. --ar 75:44",
    "A photo of a \"K鬥\" road sign in the park, with trees and grass on both sides. In front is a light yellow metal pole with two signs attached to it. The background features sunlight shining through green leaves onto one side of the street, creating a warm atmosphere. There is also water mist floating around. It was taken in the style of Sony A7R IV camera using Leica M lens. This scene conveys tranquility and harmony between nature and human creation. --ar 75:44",
    "A cross-shaped street sign stands in the middle of an open park, surrounded by trees and grassland. The sun shines through the leaves on part of it, creating a warm light effect. In front is a road leading to another green space. There's also some information about \"Inside Shilin Park\" on one side of that post. This scene gives people feelings of tranquility and harmony with nature. Natural lighting, 3D rendering in the style of Unreal Engine, Realistic photography style. --ar 75:44",
    "A cross-shaped signpost stands in the park, surrounded by lush trees and vibrant green grass under sunlight. Signs say \"VIDEO ANNattacks\" in an unknown language, creating an atmosphere of mystery and intrigue. The scene is captured with high-definition photography using Canon EOS R5 cameras, presenting a stunning visual effect that showcases intricate details in the style of modern photography. --ar 75:44"
  ]
}

错误处理

在调用 API 时,如果遇到错误,API 会返回相应的错误代码和信息。例如:

  • 400 token_mismatched:Bad request, possibly due to missing or invalid parameters.
  • 400 api_not_implemented:Bad request, possibly due to missing or invalid parameters.
  • 401 invalid_token:Unauthorized, invalid or missing authorization token.
  • 429 too_many_requests:Too many requests, you have exceeded the rate limit.
  • 500 api_error:Internal server error, something went wrong on the server.
错误响应示例
{
  "success": false,
  "error": {
    "code": "api_error",
    "message": "fetch failed"
  },
  "trace_id": "2cf86e86-22a4-46e1-ac2f-032c0f2a4e89"
}

结论

通过本文档,您已经了解了如何使用 Midjourney Describe API 进行图片描述。希望本文档能帮助您更好地对接和使用该 API。如有任何问题,请随时联系我们的技术支持团队。

体验站点:

https://chat.morecale.com/describe.html

示例代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Midjourney Describe API Demo</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
            background-color: #f0f0f0;
        }
        .container {
            max-width: 600px;
            width: 100%;
            padding: 20px;
            background: #fff;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            border-radius: 8px;
            margin-bottom: 20px;
            text-align: center;
            position: relative;
        }
        .header {
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .header h1 {
            margin: 0;
        }
        .tooltip {
            margin-left: 10px;
            display: inline-block;
            cursor: pointer;
            position: relative;
        }
        .tooltip .tooltiptext {
            visibility: hidden;
            width: 150px;
            background-color: #555;
            color: #fff;
            text-align: center;
            border-radius: 6px;
            padding: 5px;
            position: absolute;
            z-index: 1;
            bottom: 125%;
            left: 50%;
            margin-left: -75px;
            opacity: 0;
            transition: opacity 0.3s;
            font-size: 12px;
        }
        .tooltip:hover .tooltiptext {
            visibility: visible;
            opacity: 1;
        }
        .tooltip img {
            width: 20px;
            height: 20px;
        }
        input[type="text"], input[type="url"], button {
            width: 100%;
            padding: 10px;
            margin: 10px 0;
            box-sizing: border-box;
        }
        button {
            background-color: #4CAF50;
            color: white;
            border: none;
            cursor: pointer;
        }
        button:hover {
            background-color: #45a049;
        }
        .loading {
            margin-top: 10px;
            color: #666;
            display: none;
        }
        .descriptions {
            margin-top: 20px;
        }
        .description {
            background: #e7e7e7;
            padding: 10px;
            border-radius: 5px;
            margin-bottom: 10px;
        }
        .footer {
            margin-top: 20px;
            text-align: center;
        }
        .footer a {
            color: #4CAF50;
            text-decoration: none;
            margin: 0 10px;
        }
        .footer a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>Midjourney Describe API Demo</h1>
            <a href="https://platform.acedata.cloud/documents/870e973b-712a-4686-ab8b-beae27f129ce?inviter_id=7f5af0eb-5da1-42ee-a1ab-8f420e2ab2c4" target="_blank" class="tooltip">
                <img src="https://img.icons8.com/color/48/000000/arrow.png" alt="info icon">
                <span class="tooltiptext">去申请API KEY</span>
            </a>
        </div>
        <input type="text" id="apiKey" placeholder="Enter API Key" required>
        <input type="url" id="imageUrl" placeholder="Enter Image URL" required>
        <button id="describeButton">Generate Descriptions</button>
        <div id="loading" class="loading">Generating descriptions...</div>
        <div id="result" class="descriptions"></div>
        <div class="footer">
            <a href="https://platform.acedata.cloud/documents/870e973b-712a-4686-ab8b-beae27f129ce?inviter_id=7f5af0eb-5da1-42ee-a1ab-8f420e2ab2c4" target="_blank">Acedata</a>      
           <a href="https://mj.morecale.com" target="_blank">https://mj.morecale.com</a>      
        </div>
    </div>

    <script>
        document.getElementById('describeButton').addEventListener('click', function() {
            const apiKey = document.getElementById('apiKey').value;
            const imageUrl = document.getElementById('imageUrl').value;
            const loading = document.getElementById('loading');
            const resultDiv = document.getElementById('result');

            if (!apiKey || !imageUrl) {
                alert("Please enter both API Key and Image URL.");
                return;
            }

            loading.style.display = 'block';
            resultDiv.innerHTML = '';

            const options = {
                method: "post",
                headers: {
                    "accept": "application/json",
                    "authorization": `Bearer ${apiKey}`,
                    "content-type": "application/json"
                },
                body: JSON.stringify({
                    "image_url": imageUrl
                })
            };

            fetch("https://api.acedata.cloud/midjourney/describe", options)
                .then(response => response.json())
                .then(data => {
                    loading.style.display = 'none';
                    if (data.descriptions && data.descriptions.length > 0) {
                        data.descriptions.forEach(description => {
                            const descDiv = document.createElement('div');
                            descDiv.className = 'description';
                            descDiv.textContent = description;
                            resultDiv.appendChild(descDiv);
                        });
                    } else {
                        resultDiv.textContent = 'No descriptions available.';
                    }
                })
                .catch(err => {
                    loading.style.display = 'none';
                    console.error(err);
                    alert('Error generating descriptions. Please try again.');
                });
        });
    </script>
</body>
</html>

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

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

相关文章

腾讯Java社招面试题真题,最新面试题

Java中synchronized和ReentrantLock有什么区别&#xff1f; 1、锁的实现方式不同&#xff1a; synchronized是JVM层面的锁&#xff0c;主要依赖于监视器对象&#xff08;monitor&#xff09;实现。ReentrantLock是JDK层面的锁&#xff0c;通过Java代码实现&#xff0c;提供了更…

陪跑真正值钱的不是教程,是你遇到那个挡住你的问题时,身边有个靠谱的人

今天分享两个概念&#xff0c;一个是意识决定一切&#xff0c;一个是大道至简&#xff0c;做项目就是按部就班的遵循事情发展规律去做。 先说第一个概念&#xff0c;意识决定一切。我们说的凡事预则立不预则废&#xff0c;就是计划了去做就会有结果。 给你们一个表&#xff0c;…

力扣:1738. 找出第 K 大的异或坐标值

1738. 找出第 K 大的异或坐标值 给你一个二维矩阵 matrix 和一个整数 k &#xff0c;矩阵大小为 m x n 由非负整数组成。 矩阵中坐标 (a, b) 的 值 可由对所有满足 0 < i < a < m 且 0 < j < b < n 的元素 matrix[i][j]&#xff08;下标从 0 开始计数&…

简单的UDP网络程序:多人群聊系统

本章重点 能够实现一个简单的udp客户端/服务器; 1.创建套接字 我们把服务器封装成一个类&#xff0c;当我们定义出一个服务器对象后需要马上初始化服务器&#xff0c;而初始化服务器需要做的第一件事就是创建套接字。 ⭐参数说明&#xff1a; domain&#xff1a;创建套接字的域…

Spring中的Aware接口

Spring中的Aware接口 Aware接口介绍 Aware是Spring中的接口&#xff0c;它的作用是可以让Bean获取到运行环境的相关信息。比如获取到上下文、Bean在容器中的名称等。 Spring中提供了很多Aware接口的子类&#xff0c;具体如下&#xff1a; 常用接口的作用如下&#xff1a; …

设计软件有哪些?建模和造型工具篇(1),渲染100邀请码1a12

之前我们介绍的都是渲染软件&#xff0c;但对于设计师来说建模和造型是在渲染之前&#xff0c;所以从现在开始&#xff0c;我们会介绍一批建模和造型工具。 1、ZBrush ZBrush是由Pixologic公司开发的数字雕刻和绘画软件&#xff0c;专为艺术家和设计师而设计。它结合了3D建模…

Python打包篇-exe

文章目录 pyinstallerauto-py-to-exe pyinstaller 命令行工具&#xff0c;语法自行查看官方help pip install pyinstallerauto-py-to-exe 基于pyinstaller的一款GUI工具&#xff0c;会自行打包py文件中依赖的库 pip install auto-py-to-exe auto-py-to-exe.exe //运行即可

【教程】Linux部署Android安卓模拟器

转载请注明出处&#xff1a;小锋学长生活大爆炸[xfxuezhagn.cn] 如果本文帮助到了你&#xff0c;欢迎[点赞、收藏、关注]哦~ 未完成&#xff0c; 先简单记录下指令。 docker-android https://github.com/budtmo/docker-android 检查系统是否支持&#xff1a; sudo apt instal…

Linux网络编程:HTTPS协议

目录 1.预备知识 1.1.加密和解密 1.2.常见加密方式 1.2.1.对称加密 1.2.2.非对称加密 ​编辑 1.3.数据摘要&#xff08;数据指纹&#xff09;和数据签名 1.4.证书 1.4.1.CA认证 1.4.2.证书和数字签名 2.HTTPS协议 2.1.自行设计HTTPS加密方案 2.1.1.只使用对称加密 …

【微机原理及接口技术】可编程并行接口芯片8255A

【微机原理及接口技术】可编程并行接口芯片8255A 文章目录 【微机原理及接口技术】可编程并行接口芯片8255A前言一、8255A的内部结构和引脚1.与外设接口&#xff08;数据端口&#xff09;2.与处理器接口 二、8255A的工作方式三、8255A的编程1. 写入方式控制字&#xff1a;控制字…

[GUET-CTF2019]encrypt

我自己大致分析的是输入flag然后先 RC4加密再 base64加密&#xff0c;解了一下发现不对。 那就只能仔细分析了&#xff0c;看有没有魔改 嗯&#xff0c;可以动调试试&#xff0c;嗯就是要找其 key 的值 &#xff1a;0x10,0x20,0x30,0x30,0x20,0x10,0x40 aaaaaaaaaa--->dd…

HTML.

HTML:超文本标记语言&#xff08;Hyper Text Markup Language&#xff09; 超文本&#xff1a;不同于普通文本&#xff0c;可以定义图片&#xff0c;音频&#xff0c;视频等内容 标记语言&#xff1a;由标签构成的语言 HTML标签都是预定义好的HTML代码直接在浏览器中运行&#…

Llama 3没能逼出GPT-5!OpenAI怒“卷”To B战场,新企业级 AI 功能重磅推出!

Meta 是本周当之无愧的AI巨星&#xff01;刚刚推出的 Llama 3 凭借着强大的性能和开源生态的优势在 LLM 排行榜上迅速跃升。 按理说&#xff0c;Llama 3在开源的状态下做到了 GPT-3.7 的水平&#xff0c;必然会显得用户&#xff08;尤其是企业用户&#xff0c;他们更具备独立部…

ISCC2024个人挑战赛WP-WEB

&#xff08;非官方解&#xff0c;以下内容均互联网收集的信息和个人思路&#xff0c;仅供学习参考&#xff09; 还没想好名字的塔防游戏 GET /world.js HTTP/1.1 Host: 101.200.138.180:17345 Accept: text/html,application/xhtmlxml,application/xml;q0.9,image/avif,i…

【神经网络结构可视化】使用 Visualkeras 可视化 Keras / TensorFlow 神经网络结构

文章目录 Visualkeras介绍下载安装代码示例1、导入必要的库2、创建VGG16神经网络模型3、可视化神经网络结构4、完整代码5、使用教程 可视化自己创建的神经网络结构1、导入要的库2、创建自己的神经网络模型3、可视化神经网络结构图4、完整代码 Visualkeras介绍 Visualkeras是一…

大数据信用报告查询有哪些作用?哪个平台更好?

大数据信用是基于大数据技术&#xff0c;通过大数据系统生成的大数据信用报告&#xff0c;报告收集了查询人在非银环境下的申贷数据以及履约行为和信用风险的综合性报告。很多人都会问&#xff0c;大数据信用报告查询有哪些作用?哪个查询平台更好的疑问&#xff0c;下文就详细…

【教学类-58-04】黑白三角拼图04(2-10宫格,每个宫格随机1张-6张,带空格纸)

背景需求&#xff1a; 前期制作了黑白三角拼图2*2、3*3、4*4&#xff0c;确定了基本模板&#xff0c;就可以批量制作更多格子数 【教学类-58-01】黑白三角拼图01&#xff08;2*2宫格&#xff09;固定256种随机抽取10张-CSDN博客文章浏览阅读522次&#xff0c;点赞13次&#x…

【JavaEE】深入学习Spring MVC:掌握参数传递与映射

目录 3. 请求传递单个参数传递多个参数传递对象后端参数重命名传递数组传递集合 3. 请求 请求就是要学习如何传参 传递单个参数多个参数对象数组/集合…… 传递单个参数 RequestMapping("/m1") public String m1(String name){return "接收到的参数name:&qu…

python如何把字符串变成小写字母

Python中&#xff0c;将字符串中的字母转换成小写字母&#xff0c;字符串变量提供了2种方法&#xff0c;分别是title()、lower()。 Python title()方法 title()方法用于将字符串中每个单词的首字母转为大写&#xff0c;其他字母全部转为小写&#xff0c;转换完成后&#xff0…

RAG概述(二):Advanced RAG 高级RAG

目录 概述 Advanced RAG Pre-Retrieval预检索 优化索引 增强数据粒度 粗粒度 细粒度 展开说说 优化索引 Chunk策略 Small2Big方法 元数据 引入假设性问题 对齐优化 混合检索 查询优化 查询扩展 查询转换 Post-Retrieval后检索 参考 概述 Native RAG&#…