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

视频网站空间教育类的网站案例

视频网站空间,教育类的网站案例,百度热搜关键词排行榜,做网站多少钱 网络服务一、ImageModel简介 1、Image Model ImageModel API 抽象了应用程序通过模型调用实现“文生图”的交互过程,即应用程序接收文本,调用模型生成图片。 ImageModel 的入参为包装类型 ImagePrompt,输出类型为 ImageResponse。 二、ImageModel…

一、ImageModel简介

1、Image Model

ImageModel API 抽象了应用程序通过模型调用实现“文生图”的交互过程,即应用程序接收文本,调用模型生成图片。

ImageModel 的入参为包装类型 ImagePrompt,输出类型为 ImageResponse。

二、ImageModel使用

Spring AI Alibaba对话模型(Chat Model):https://java2ai.com/docs/1.0.0-M5.1/tutorials/chat-model/

Spring AI Alibaba 支持Model 抽象与通义系列模型的适配,并通过 spring-ai-alibaba-starter AutoConfiguration 自动初始化了默认实例,因此我们可以在应用程序中直接注入 ChatModel、ImageModel 等 bean,当然在需要的时候也可以自定义 Model 实例。

在这里插入图片描述

1、编写 Controller接口

在普通 Controller Bean 中注入 ImageModel 实例,实现“文生图”功能:

  • 简单调用
  • 自定义 LLMs ImageOptions 参数调用
@Slf4j
@RestController
@RequestMapping("/dashscope/image-model")
public class DashScopeImageController {private static final String DEFAULT_PROMPT = "为人工智能生成一张富有科技感的图片!";private final ImageModel imageModel;/*** 使用如下的方式自动注入 ImageModel** @param imageModel*/public DashScopeImageController(ImageModel imageModel) {this.imageModel = imageModel;}/*** 简单调用*/@GetMapping("/simple/image")public void simpleImage(HttpServletResponse response, String userInputPrompt) {if (StringUtils.isBlank(userInputPrompt)) {userInputPrompt = DEFAULT_PROMPT;}// 默认使用的是 wanx-v1模型ImageResponse imageResponse = imageModel.call(new ImagePrompt(userInputPrompt));Image image = imageResponse.getResult().getOutput();// 获取图片的 URL。String imageUrl = image.getUrl();// 获取图片的 Base64 编码String b64Json = image.getB64Json(); log.info(" simpleImage --> userInputPrompt = {}, imageUrl = {}", userInputPrompt, imageUrl);log.info(" simpleImage --> userInputPrompt = {}, b64Json = {}", userInputPrompt, b64Json);try {URL url = URI.create(imageUrl).toURL();InputStream in = url.openStream();response.setHeader("Content-Type", MediaType.IMAGE_PNG_VALUE);response.getOutputStream().write(in.readAllBytes());response.getOutputStream().flush();} catch (IOException e) {response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);}}/*** 使用编程方式自定义 LLMs ImageOptions 参数,* {@link com.alibaba.cloud.ai.dashscope.image.DashScopeImageOptions}* 优先级高于在 application.yml 中配置的 LLMs 参数!*/@GetMapping("/customOptions/image")public List<String> customOptionsImage(String userInputPrompt) {if (StringUtils.isBlank(userInputPrompt)) {userInputPrompt = DEFAULT_PROMPT;}// 自定义 LLMs ImageOptions 参数DashScopeImageOptions customOptions = DashScopeImageOptions.builder()// 默认使用的是 wanx-v1模型.withWidth(1024).withHeight(1024).withN(2) // 生成图片的数量.build();ImageResponse imageResponse = imageModel.call(new ImagePrompt(userInputPrompt, customOptions));List<ImageGeneration> imageGenerationList = imageResponse.getResults();List<String> imageUrlList = new ArrayList<>();for (ImageGeneration imageGeneration : imageGenerationList) {Image image = imageGeneration.getOutput();// 获取图片的 URLString imageUrl = image.getUrl();// 获取图片的 Base64 编码//String b64Json = image.getB64Json();log.info(" customOptionsImage --> userInputPrompt = {}, imageUrl = {}", userInputPrompt, imageUrl);imageUrlList.add(imageUrl);}return imageUrlList;}}

启动项目,访问接口与 AI 大模型智能对话。

在这里插入图片描述
在这里插入图片描述

注意: dashscope 文生图返回的 图片url是有过期时间的(有效期一天),我们及时下载下来。

田园茶叶特写提示词:
超写实摄影风格,云南深山古树茶园清晨场景,苍劲虬曲的茶树特写,嫩绿茶叶上挂满晶莹露珠,晨光穿透薄雾洒在叶片上,茶农身着靛蓝布衣、头戴斗笠采摘茶叶,竹篓中堆满新鲜茶芽,背景是云雾缭绕的梯田与远山,色彩以翠绿、乳白、深褐为主,晨光暖金色点缀,画面宁静充满田园诗意,突出茶叶天然品质与手工采摘的传统感。

在这里插入图片描述

– 求知若饥,虚心若愚。


文章转载自:

http://okQN2zx3.cxryx.cn
http://2p260Xqj.cxryx.cn
http://Re1xsqG1.cxryx.cn
http://wiqL1l9Q.cxryx.cn
http://YYTW57wM.cxryx.cn
http://yKcEM7Dq.cxryx.cn
http://1UnxL8Yz.cxryx.cn
http://SJ4IFLCa.cxryx.cn
http://dN1cBjkz.cxryx.cn
http://GotleYAp.cxryx.cn
http://CdXFZANt.cxryx.cn
http://QnOYB0pE.cxryx.cn
http://1Rq00SyG.cxryx.cn
http://GVRdyWAL.cxryx.cn
http://VnkloPR7.cxryx.cn
http://YOrvuP3e.cxryx.cn
http://YgEY7LS0.cxryx.cn
http://QNzls0uF.cxryx.cn
http://05mRKnrM.cxryx.cn
http://HeRLvqTh.cxryx.cn
http://vbzdWFXm.cxryx.cn
http://ACCsdWbK.cxryx.cn
http://MZpIXl5C.cxryx.cn
http://cH00F5zY.cxryx.cn
http://R1proXJY.cxryx.cn
http://oEt1AerQ.cxryx.cn
http://AA1IwtxE.cxryx.cn
http://fqnfbwpx.cxryx.cn
http://hpyqaAY4.cxryx.cn
http://iZMD97eN.cxryx.cn
http://www.dtcms.com/wzjs/758627.html

相关文章:

  • o2o型网站长沙排名推广
  • 泉州网站建设公司推荐在线制作图片纹身
  • 做消费网站流程平面网页设计培训教程
  • 用动物做网站名策划一场活动的流程
  • cdr做的网站效果怎么直接用怎样让公司网站更吸引人
  • 杭州城乡建设厅网站开放平台直播
  • 各大网站收录入口建设网站学习
  • 廊坊企业免费建站企业展厅设计图
  • 一般做公司网站需要哪几点如何申请公司域名
  • 专做奢侈品的网站软件开发外包公司排
  • 营销型网站是啥意思英文企业网站开发
  • 网站设计规划的目的和要求目前做哪些网站致富
  • 网站建设性能指标搜索引擎优化自然排名的区别
  • 如何自建公司网站网络专业的网站建设价格低
  • 网站信息登记表做片头片尾比较好的网站
  • 广东住房和城乡建设部网站企业logo标志设计免费
  • 小程序商城怎么开通seo优化网站技术排名百度推广
  • 项目信息网站哪个好深圳市建设股份有限公司
  • 南京网站微信建设非小号是根据国外哪个网站做的
  • 优化seo网站做网站教程第一课
  • 网站建设及照片使用保密协议网站建设有哪些费用
  • 微信网站的建立湛江企业模板建站
  • 建设网站需要什么软件公司制作一个网站要多少钱
  • 邢台做网站服务商百度一下首页网页
  • 华为企业网站建设需求分析南通市建设监理协会网站
  • 租车网站模板响应式网站的制作
  • 深圳松岗 网站建设深圳宣传片制作服务
  • 山西住房和城乡建设部网站怎样做网站搜索推广电话成都
  • 网站建设与设计pptai智能写作平台
  • 礼物网站模板唐山网站建设最好的