前言
在这里与Skybox AI一起,一键打造体验无穷的360°天下,这是这个AIGC一键天生全景图的网站接待语。
刚利用它是23年中旬,在没有空去给客户实地拍摄全景图时,可以快速用它天生一些干系的全景图,用作前期沟通的VR demo。其时利用全部都是开放免费的,遗憾的是如今利用多了很多限定,好比很多风格都须要付费,而且天生也须要邪术网络,免费天生次数举行了限定:
最新消息这个平台已经有Unity SDK了,具体见:https://github.com/Blockade-Games/BlockadeLabs-SDK-Unity
这个利用的限定就是必须注册利用API key来天生。
效果
如下是一些Unity中的效果:
数字绘画赛博朋克
数字绘画长城
科幻风格
写实风格
卡透风格
硬核
自制游戏望支持
快速体验
直接访问blockadelabs.com点击体验。
选择一种风格(select a style):
输入对全景图的形貌:
点击天生后,期待一段时间就能在网站中看到效果,点击下载按钮:
产生的全景图是一个2:1的全景图,如下:
下载后导入Unity,假如辨认不出来图片,须要改成jpg。
在unity内新建一个天空盒/Panoramic着色器的材质球,具体设置参照下图:
在场景中新建一个球体Sphere,将材质球拖给它,适当放大球体,将摄像放到球体的正中心,就可以看到全景图的效果。
假如天生的效果不理想得思量更换风格和形貌(这个同Stable Diffusion 的 Prompt 提示词)更改,也可以在此次天生的作品上举行编辑(Edit This)大概再肴杂(Remix This),直到效果满意。不外,假如你是免费的用户得留意次数,否则就得等下个月了:
API接入
这里它提供了API哀求的一系列接口,这些接口着实也可以在Unity内利用UnityWebRequest的方式举行哀求。
起首,您须要一个 API 密钥才华开始利用。 假如您没有,请前往 https://api.blockadelabs.com 申请。
这是它的安全提示:
不发起在应用步伐的前端公开 API 密钥。相反,发起利用我们为您准备的 SDK库之一或开发您本身的后端服务来与前端应用步伐举行通讯,然后利用服务器到服务器的哀求来访问 Blockade Labs API 端点。
您的 API 密钥必须作为参数包罗在 HTTP 哀求标头中:x-api-key
大概,您可以将其作为 url 查询参数api_key发送(此方法不太安全):https://backend.blockadelabs.com/api/v1/skybox?api_key=7J7eD5TIiJR4Gky…
根据您对 POST 哀求的偏好,您可以将参数和值作为 JSON () 或 FormData () 发送。请留意,假如您利用的是 JSON,则须要以 base64 格式对要上传的文件举行编码。application/jsonmultipart/form-data
Unity3d 中你这么写C#脚本:- UnityWebRequest request = new UnityWebRequest(url, reqtype);
- request.SetRequestHeader("x-api-key", "你的key(如:7J7eD5TIiJR4Gky...)");
复制代码 天生天空盒
您须要做的就是向 https://backend.blockadelabs.com/api/v1/skybox 发送一个带有参数的 POST 哀求,须要传参数提示词prompt:- JsonData param = new JsonData();
- param["prompt"] = "你的描述(提示词)";
- request.uploadHandler = (UploadHandler)new UploadHandlerRaw(Encoding.UTF8.GetBytes(param.ToJson()));
复制代码 得到相应示比方下:- {
- "id": 123456, // id of your generation. It can be used to track generation progress or to cancel/delete the generation
- "status": "pending", // initially status is set as 'pending' after you send a generation request. Status will change from one state to another and you will get updates for each one if you are using pusher or webhook: pending -> dispatched -> processing -> complete. Also you can get abort or error.
- "queue_position": 2, // position of your request in a generation queue
- "file_url": "", // full size of generated image url (empty until generation is completed)
- "thumb_url": "", // thumbnail of generated image url (empty until generation is completed)
- "title": "World #123456", // generation title
- "user_id": 1, // your user id
- "username": "user@blockadelabs.com", // your username
- "error_message": null, // if status=error here you should see the error message
- "obfuscated_id": "460370b7328a5cb8dbddd6ef0d1c9dd4", // hash id of your generation
- "pusher_channel": "status_update_460370b7328a5cb8dbddd6ef0d1c9dd4", // pusher channel name used to track generation progress
- "pusher_event": "status_update", // pusher channel event used to track generation progress
- "created_at": "2023-03-18T10:42:19+00:00", // time created
- "updated_at": "2023-03-18T10:42:19+00:00" // time updated}
- }
复制代码 得到相应后,仍须要期待天生器处置处罚图像,由于天生速率没有那么快。
跟踪天生进度
天生图像时,参数将按以下次序更改,直到完成,status如下分析:
pending- 天生在队列中(初始状态)
dispatched- 这一次天生被送到了人工智能工作者那边
processing- AI worker 开始天生
complete- 天生已完成,您可以检索天生的天空盒图像
abort- 这一次天生短命了
error- 天生时出现错误。您可以查察参数以获取更多具体信息。error_message
每当发生更改时,都会通过 Pusher(或可选地通过 webhook)发送相应的变乱消息。
要同步天生进度,有三种方式:
1. Pusher
这是保举方式的同步你天生过程,通过利用官方 Pusher 库(https://pusher.com/docs/channels/channels_libraries/libraries/#official-libraries),您可以将其无缝集成到您的应用步伐中。 在发送天空盒或想象天生哀求时,您将得到可用于跟踪天生进度的相应。
Pusher 哀求参数:- app_id = "1555452"
- key = "a6a7b7662238ce4494d5"
- cluster = "mt1"
复制代码 相应示例:- {
- "pusher_channel": "status_update_460370b7328a5cb8dbddd6ef0d1c9dd4",
- "pusher_event": "status_update",
- }
复制代码 2. Webhook
Webhook 是发送到唯一 URL 的关照。
若要启用 Webhook 状态更新,只需在 Skybox 天生哀求中发送一个附加参数即可。在每次状态更新时,我们都会向您提供的发送带有进度更新消息 (json) 的哀求。webhook_urlPOSTwebhook_url
您可以利用 https://webhook.site/ 测试 Webhook。
3. API数据轮询
不发起利用此方法,由于它大概会触发我们的 API 速率限定器。它只能用于测试目标。
向 API 发出哀求并查抄更改。 这里更具体地表明。
GET https://backend.blockadelabs.com/api/v1/imagine/requests/{id}status
这是状态更新的相应示例:- {
- "id": 123456, // id of your generation. It can be used to track generation progress or to cancel the generation
- "obfuscated_id": "460370b7328a5cb8dbddd6ef0d1c9dd4", // hash id of your generation
- "user_id": 1, // your user id
- "username": "user@blockadelabs.com", // your username
- "status": "pending", // initially status is set as 'pending' after you send a generation request. Status will change from one state to another and you will get updates for each one if you are using pusher or webhook: pending -> dispatched -> processing -> complete. Also you can get abort or error.
- "queue_position": 1, // position of your request in a generation queue
- "pusher_channel": "status_update_460370b7328a5cb8dbddd6ef0d1c9dd4", // pusher channel name used to track generation progress
- "pusher_event": "status_update", // pusher channel event used to track generation progress
- "error_message": null, // if status=error here you should find the error message
-
- "type": "skybox", // type of generation (currently "skybox" is the only one)
- "title": "Imagination #123456", // generation title
- "prompt": "prompt text", // prompt text used to generate skybox
- "skybox_style_id": 10, // skybox style id used to generate skybox
- "skybox_style_name": "SciFi", // skybox style name used to generate skybox
-
- "file_url": "https://blockade-platform-production.s3.amazonaws.com/images/imagine/futuristic_microdetailed_vr_scifi_concept_art_cinematic_vr_neon__dbe7f963dc23699c__2757929_dbe7.jpg?ver=1", // generated skybox image (6144x3072 pixels)
- "thumb_url": "https://blockade-platform-production.s3.amazonaws.com/thumbs/imagine/thumb_futuristic_microdetailed_vr_scifi_concept_art_cinematic_vr_neon__dbe7f963dc23699c__2757929_dbe7.jpg?ver=1", // generated skybox thumbnail (672x336 pixels)
- "depth_map_url": "https://blockade-platform-production.s3.amazonaws.com/depths/imagine/futuristic_microdetailed_vr_scifi_concept_art_cinematic_vr_neon__dbe7f963dc23699c__2757929_dbe7.jpg?ver=1", // generated skybox depyh map image (2048x1024 pixels)
-
- "created_at": "2023-03-18T10:42:19+00:00", // time created
- "updated_at": "2023-03-18T10:42:39+00:00", // time updated
- }
复制代码 下载全景图
全部 API 端点都须要在标头中发送或作为 get 参数发送的 API 密钥。用于导出各种文件范例的天空盒的 API 路由:PNG、HDRI(exr、hdr)、深度图、立方体图、视频(纵向、横向、正方形)。
获取导出范例
GET https://backend.blockadelabs.com/api/v1/skybox/export
返回示例:- [
- {
- "id": 1,
- "name": "JPG",
- "key": "equirectangular-jpg",
- },
- {
- "id": 2,
- "name": "PNG",
- "key": "equirectangular-png",
- }
- ]
复制代码 哀求导出
POST https://backend.blockadelabs.com/api/v1/skybox/export
假如导出哀求已经完成,您将立刻收到相应,并在相应中收到相应。
相应示例(完备)- {
- "file_url": "https://blockade-platform-production.s3.amazonaws.com/depths/imagine/vr360-stunning-beautiful-vibrant-digital-painting-sega-atari_8414305.jpg", // url for the exported file
- "id": "15e8a0ae53d39e2ef518b2c02f9c43ee", // id of your export request. It can be used to track progress or cancel the request
- "type": "depth-map-png", // requested export type
- "type_id": 6, // requested export type id
- "status": "complete", // initially status is set as 'pending' after you send the export request. Status will change from one state to another and you will get updates for each one if you are using pusher or webhook: pending -> dispatched -> processing -> complete. Also you can get abort or error and in some cases (ie. for JPG and Depth Map export) this will be immediately set to 'complete'.
- "queue_position": 0, // position of your request in a export generation queue
- "error_message": null, // if status=error here you should see the error message
- "pusher_channel": "export_status_update_15e8a0ae53d39e2ef518b2c02f9c43ee", // pusher channel name used to track export generation progress
- "pusher_event": "status_update", // pusher channel event used to track generation
- "created_at": "2023-08-21T09:55:28.000000Z"
- }
复制代码 获取下载链接
GET https://backend.blockadelabs.com/api/v1/skybox/export/{你的导出id}
相应示例:- {
- "file_url": "https://blockade-platform-production.s3.amazonaws.com/depths/imagine/vr360-stunning-beautiful-vibrant-digital-painting-sega-atari_8414305.jpg", // url for the exported file
- "id": "15e8a0ae53d39e2ef518b2c02f9c43ee", // id of your export request. It can be used to track progress or cancel the request
- "type": "depth-map-png", // requested export type
- "type_id": 6, // requested export type id
- "status": "complete", // initially status is set as 'pending' after you send the export request. Status will change from one state to another and you will get updates for each one if you are using pusher or webhook: pending -> dispatched -> processing -> complete. Also you can get abort or error and in some cases (ie. for JPG and Depth Map export) this will be immediately set to 'complete'.
- "queue_position": 0, // position of your request in a export generation queue
- "error_message": null, // if status=error here you should see the error message
- "pusher_channel": "export_status_update_15e8a0ae53d39e2ef518b2c02f9c43ee", // pusher channel name used to track export generation progress
- "pusher_event": "status_update", // pusher channel event used to track generation
- "webhook_url": null, // custom webhook where generator will send updates about export
- "created_at": "2023-08-21T09:55:28.000000Z"
- }
复制代码 这里相应的file_url字段就是下载链接的所在。
费用
和客岁相比,这个平台的功能也渐渐完满、强大,体系也从完全开放状态,变化成了接口式的付费利用平台,而且平台的费用分级大概多,具体如下:
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!qidao123.com:ToB企服之家,中国第一个企服评测及软件市场,开放入驻,技术点评得现金 |