|
@@ -23,6 +23,7 @@
|
|
|
inputBase64Url: "",
|
|
|
taskId: "", // 图生图任务ID
|
|
|
img2imgTimer: null,
|
|
|
+ outTimer: null,
|
|
|
imageWidth: 750,
|
|
|
imageHeight: 448,
|
|
|
showAIFlag:false,//继续生成状态切换标志
|
|
@@ -30,7 +31,7 @@
|
|
|
shottingImg:'',
|
|
|
count:0,
|
|
|
random:1,
|
|
|
- disableAble:false,
|
|
|
+ // disableAble:false,
|
|
|
spaceTypes: [{
|
|
|
icon: "",
|
|
|
title: "卧室",
|
|
@@ -108,6 +109,100 @@
|
|
|
loadingMsg:'',
|
|
|
screenWidth:0,
|
|
|
screenHeight:0,
|
|
|
+ modelType:2, //当前模型类型,1指创意设计 2指精准设计 默认2
|
|
|
+ themeIndex:0,
|
|
|
+ themeList:[
|
|
|
+ {
|
|
|
+ id:1,
|
|
|
+ text:'默认',
|
|
|
+ prot:'',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id:2,
|
|
|
+ leftColor:'#F4EBDE',
|
|
|
+ rightColor:'#C1C9B4',
|
|
|
+ text:'莫兰素雅',
|
|
|
+ prot:'Soft grays, warm earth tones, subtle blues, soft pinks,',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id:3,
|
|
|
+ leftColor:'#1F1F1F',
|
|
|
+ rightColor:'#FFFFFF',
|
|
|
+ text:'经典黑白',
|
|
|
+ prot:'Classic black and pure white,',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id:4,
|
|
|
+ leftColor:'#6FA5BE',
|
|
|
+ rightColor:'#E2CCC5',
|
|
|
+ text:'海岸珊瑚',
|
|
|
+ prot:'Deep ocean blue paired with vibrant coral red,',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id:5,
|
|
|
+ leftColor:'#849059',
|
|
|
+ rightColor:'#E6CEB4',
|
|
|
+ text:'森林璀璨',
|
|
|
+ prot:'Deep forest green paired with luxurious gold,'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id:6,
|
|
|
+ leftColor:'#A1BACB',
|
|
|
+ rightColor:'#E6DFD8',
|
|
|
+ text:'梦幻静谧',
|
|
|
+ prot:'Dreamy powder blue paired with neutral gray,'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id:7,
|
|
|
+ leftColor:'#303B2B',
|
|
|
+ rightColor:'#D8C8A6',
|
|
|
+ text:'自然和谐',
|
|
|
+ prot:'Natural olive green paired with warm beige,'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id:8,
|
|
|
+ leftColor:'#652C30',
|
|
|
+ rightColor:'#D5C3B0',
|
|
|
+ text:'醇酒乳香',
|
|
|
+ prot:'Rich burgundy paired with soft cream,'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id:9,
|
|
|
+ leftColor:'#E3C7C5',
|
|
|
+ rightColor:'#EDE4DB',
|
|
|
+ text:'雅致浪漫',
|
|
|
+ prot:'Understated taupe paired with romantic pink,'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id:10,
|
|
|
+ leftColor:'#2C3C6E',
|
|
|
+ rightColor:'#F0DBBD',
|
|
|
+ text:'夜空璀璨',
|
|
|
+ prot:'Elegant navy blue paired with glamorous gold,'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id:11,
|
|
|
+ leftColor:'#ACC9A1',
|
|
|
+ rightColor:'#E6DCC6',
|
|
|
+ text:'复古翠绿',
|
|
|
+ prot:'Vintage tan paired with vibrant green,'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id:12,
|
|
|
+ leftColor:'#AAA8A7',
|
|
|
+ rightColor:'#D8A176',
|
|
|
+ text:'暖阳灰影',
|
|
|
+ prot:'Warm orange paired with cool gray,'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id:13,
|
|
|
+ leftColor:'#413D41',
|
|
|
+ rightColor:'#D1B687',
|
|
|
+ text:'耀眼黑金',
|
|
|
+ prot:'black and gold,'
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ timeOut:20000, //超时时间
|
|
|
}
|
|
|
},
|
|
|
props:{
|
|
@@ -198,13 +293,29 @@
|
|
|
}
|
|
|
};
|
|
|
util.trackRequest(param);
|
|
|
- // setTimeout(()=> {
|
|
|
- // if(this.showAIImage==true){
|
|
|
- // this.$parent.clearHandle()
|
|
|
- // }else{
|
|
|
- // this.$parent.attendEvent()
|
|
|
- // }
|
|
|
- // }, 100);
|
|
|
+ },
|
|
|
+ //空间或者风格切换
|
|
|
+ selectAction(selItem,type,index) {
|
|
|
+ console.log('点击动作111:', selItem,type,index)
|
|
|
+ var self = this;
|
|
|
+ if(this.themeIndex == index){
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ this.themeIndex = index;
|
|
|
+ let param = {
|
|
|
+ type: 'CLK', //埋点类型
|
|
|
+ clkId: 'clk_2cmina_23112701', //点击ID
|
|
|
+ clkName: 'AIstyle_theme_clk', //点击前往的页面名称
|
|
|
+ clkParams: {
|
|
|
+ locusName: "AI 主题",
|
|
|
+ type:this.themeList[this.themeIndex].text
|
|
|
+ }
|
|
|
+ };
|
|
|
+ util.trackRequest(param);
|
|
|
+ },
|
|
|
+ //切换模式
|
|
|
+ changeModel(){
|
|
|
+ this.modelType = (this.modelType + 1) >2 ? 1 : 2;
|
|
|
},
|
|
|
//保存到相册
|
|
|
save() {
|
|
@@ -268,7 +379,7 @@
|
|
|
this.downloadIamge(_resultImg);
|
|
|
},
|
|
|
|
|
|
- //选项变更
|
|
|
+ //点赞喜欢
|
|
|
changeAIImg() {
|
|
|
// let lastPage = getCurrentPages()[getCurrentPages().length - 2] ? getCurrentPages()[getCurrentPages().length - 2].$vm : null;
|
|
|
this.checked = !this.checked;//变更选项
|
|
@@ -334,13 +445,6 @@
|
|
|
}else{
|
|
|
this.$message.warning("敬请期待");
|
|
|
}
|
|
|
- // setTimeout(()=> {
|
|
|
- // if(this.showAIImage==true){
|
|
|
- // this.$parent.clearHandle()
|
|
|
- // }else{
|
|
|
- // this.$parent.attendEvent()
|
|
|
- // }
|
|
|
- // }, 100);
|
|
|
}
|
|
|
},
|
|
|
catchTapEvent:function(){
|
|
@@ -360,14 +464,14 @@
|
|
|
this.styleList = list;
|
|
|
}
|
|
|
if(!this.styleList || this.styleList.length==0){
|
|
|
- this.disableAble = true;//不能点击-没有风格
|
|
|
+ // this.disableAble = true;//不能点击-没有风格
|
|
|
let unit = this.screenWidth / 750;//单位rpm 对应 px 的值
|
|
|
this.$parent.canvasHeight = this.screenHeight - (208 * unit);
|
|
|
this.$parent.camera.aspect = this.screenWidth / this.$parent.canvasHeight;
|
|
|
this.$parent.camera.updateProjectionMatrix();
|
|
|
this.$parent.renderer.setSize(this.screenWidth, this.$parent.canvasHeight);
|
|
|
}else{
|
|
|
- this.disableAble = false;//可以点击
|
|
|
+ // this.disableAble = false;//可以点击
|
|
|
}
|
|
|
},
|
|
|
clearInterval() {
|
|
@@ -492,26 +596,7 @@
|
|
|
if(isRepeat && self.inputBase64Url){//重复使用
|
|
|
self.startServer();
|
|
|
}else{
|
|
|
- // self.inputBase64Url = Base64Url;
|
|
|
- // console.log("生成inputBase64Url");
|
|
|
self.startServer();
|
|
|
- // this.image2Base64(url).then(base64 => {
|
|
|
- // self.inputBase64Url = base64;
|
|
|
- // self.startServer();
|
|
|
- // })
|
|
|
- // uni.request({
|
|
|
- // url: url,
|
|
|
- // method: "GET",
|
|
|
- // responseType: "arraybuffer",
|
|
|
- // success: async (res) => {
|
|
|
- // let base64 = wx.arrayBufferToBase64(res.data);
|
|
|
- // let Base64Url = "data:image/jpeg;base64," + base64;
|
|
|
- // // console.log('base64:', Base64Url);
|
|
|
- // self.inputBase64Url = Base64Url;
|
|
|
- // console.log("生成inputBase64Url");
|
|
|
- // self.startServer();
|
|
|
- // },
|
|
|
- // });
|
|
|
}
|
|
|
},
|
|
|
//开始图生图流程
|
|
@@ -520,68 +605,11 @@
|
|
|
return false
|
|
|
}
|
|
|
let imgUrl = this.styleList[this.curStyleIndex].imgUrl;
|
|
|
- // let base64Url = await this.image2Base64(imgUrl);
|
|
|
- // let data = {
|
|
|
- // "configType": "AI_Biography",
|
|
|
- // "keyvalue": "ControlNet_IpAdapter",
|
|
|
- // "model": "ip-adapter_xl [4209e9f7]",
|
|
|
- // "cpu": "ip-adapter_clip_sdxl",
|
|
|
- // "session_hash": Date.now(),
|
|
|
- // "weight": 1.5,
|
|
|
- // "number1": -1,
|
|
|
- // "number2": -1,
|
|
|
- // "number3": 0,
|
|
|
- // "number4": 1,
|
|
|
- // // "imageBase64": base64Url,
|
|
|
- // "imageUrl":imgUrl,
|
|
|
- // }
|
|
|
- // let res1 = await requestConfig("AIuploadImgControlNet", data);
|
|
|
- // if(!res1 || !res1.single){
|
|
|
- // this.showToast("渲染失败,请重试");
|
|
|
- // this.aiFlag = false;
|
|
|
- // this.aiImage = "";
|
|
|
- // this.myloading = false;
|
|
|
- // return false;
|
|
|
- // }
|
|
|
- // let session_hash = data.session_hash;
|
|
|
- // data.model = "sai_xl_canny_256lora [566f20af]";
|
|
|
- // data.keyvalue = "ControlNet_Canny";
|
|
|
- // data.cpu = "canny";
|
|
|
- // data.weight = 0.8;
|
|
|
- // data.number1 = 100;
|
|
|
- // data.number2 = 200;
|
|
|
- // data.number3 = 0;
|
|
|
- // data.number4 = 1;
|
|
|
- // data.imageBase64 = this.inputBase64Url;
|
|
|
|
|
|
- // let res2 = await requestConfig("AIuploadImgControlNet", data);
|
|
|
- // if(!res2 || !res2.success){
|
|
|
- // this.showToast("渲染失败,请重试");
|
|
|
- // this.aiFlag = false;
|
|
|
- // this.aiImage = "";
|
|
|
- // this.myloading = false;
|
|
|
- // return false;
|
|
|
- // }
|
|
|
- // data.model = "t2iadapter_seg_sd14v1 [6387afb5]";
|
|
|
- // data.keyvalue = "ControlNet_Seg";
|
|
|
- // data.cpu = "seg_ofade20k";
|
|
|
- // data.weight = 0.8;
|
|
|
- // data.number1 = -1;
|
|
|
- // data.number2 = -1;
|
|
|
- // data.number3 = 0;
|
|
|
- // data.number4 = 1;
|
|
|
- // data.imageBase64 = this.inputBase64Url;
|
|
|
- // let res3 = await requestConfig("AIuploadImgControlNet", data);
|
|
|
- // if(!res3 || !res3.success){
|
|
|
- // this.showToast("渲染失败,请重试");
|
|
|
- // this.aiFlag = false;
|
|
|
- // this.aiImage = "";
|
|
|
- // this.myloading = false;
|
|
|
- // return false;
|
|
|
- // }
|
|
|
let session_hash = Date.now();
|
|
|
- const prompt = this.styleList[this.curStyleIndex].prompt;
|
|
|
- const noPromot = this.styleList[this.curStyleIndex].negativePrompt;
|
|
|
+ let theme = this.themeList[this.themeIndex];//主题数据
|
|
|
+ let prompt = this.styleList[this.curStyleIndex].prompt + theme.prot;
|
|
|
+ let noPromot = this.styleList[this.curStyleIndex].negativePrompt;
|
|
|
let unit = 768 / this.screenWidth;
|
|
|
this.imageWidth = parseInt((this.screenWidth * unit).toFixed());
|
|
|
this.imageHeight = parseInt((this.$parent.canvasHeight * unit).toFixed());
|
|
@@ -601,8 +629,9 @@
|
|
|
image:this.shottingImg,
|
|
|
styleImage:imgUrl,
|
|
|
keyword: "replicate",
|
|
|
- model: "lucataco/ssd-1b",
|
|
|
+ model: this.modelType==1? "lucataco/ssd-1b" : 'catio-apps/controlnet-interior-design',
|
|
|
};
|
|
|
+ this.timeOut = this.modelType==1? 20000: 40000;
|
|
|
let res = await requestConfig("generateTaskImgToImgForAliyun", parmas);
|
|
|
console.log("图生图结果:", res);
|
|
|
if(this.$parent.pvCurPageName!="room_show"){//说明用户切换页面了
|
|
@@ -612,7 +641,6 @@
|
|
|
let that = this;
|
|
|
if (res.success && res.single) {
|
|
|
if(typeof(res.single)=="object"){
|
|
|
- // if(true){
|
|
|
let cot = res.single.queueCount || 1;
|
|
|
this.showToast("正有"+cot+"人排队,预计等待"+cot*25+"秒",10000);
|
|
|
this.aiImage = "";
|
|
@@ -628,13 +656,31 @@
|
|
|
this.count ++;
|
|
|
this.getResultForImgToImg();
|
|
|
}, 1000);
|
|
|
+ this.setOutTimer();
|
|
|
}
|
|
|
}else{
|
|
|
+ this.clearInterval()
|
|
|
this.aiFlag = false;
|
|
|
this.aiImage = "";
|
|
|
this.showToast("渲染失败,请重试")
|
|
|
}
|
|
|
},
|
|
|
+ //设置一个超时逻辑,到底指定时间后停止轮询,当前是90s
|
|
|
+ setOutTimer() {
|
|
|
+ if (this.outTimer) {
|
|
|
+ clearTimeout(this.outTimer)
|
|
|
+ this.outTimer = null
|
|
|
+ }
|
|
|
+ var self = this;
|
|
|
+ this.outTimer = setTimeout(function() {
|
|
|
+ if (self.img2imgTimer) {
|
|
|
+ self.clearInterval();//停止轮询
|
|
|
+ self.$message.warning("AI开了个小差,请稍后再试");
|
|
|
+ }
|
|
|
+ clearTimeout(self.outTimer);
|
|
|
+ self.outTimer = null
|
|
|
+ }, this.timeOut);
|
|
|
+ },
|
|
|
// 轮询获取图片结果
|
|
|
async getResultForImgToImg() {
|
|
|
var parmas = {
|