您当前的位置:首页 >> 装修攻略

基于 Serverless 架构的背面漫画风处理小程序

2023-02-23 12:16:30

app()

if 词组name词组 == "词组main词组":

bottle.run(host='localhost', port=8099)

整个编译器是基于 Serverless 虚拟化来进行了部份改良的:

示例初始化的时候,来进行数学模型的启动时,并未有可能的缩减频繁的冷启动随之而来的因素情况; 在线性模式下,往往只有/tmp清单是可写就的,所以关键字但会被缓存到/tmp清单下; 虽然说线性计算是“无正常”的,但是无论如何也有适配的情况,所有图表在传输到tmp的时候来进行了随机命名; 虽然部份幽厂商支持进制的元图表截图,但是大部份的 Serverless 虚拟化对进制截图支持的未必友好,所以这里依旧引入 截图的拟议;

侧面的编译器,更多是和 AI 相关的,除此之外,还须要有一个借助数学模型本表,以及数学模型逆时针等相关信息的硬件:

import bottle

@bottle.route('/system/styles', method='GET')

def styles():

return {

"AI双手机游戏暴风": {

'color': 'red',

'detailList': {

"艺术暴风格1": {

'uri': "images/comic_style",

'name': 'celeba_distill',

'color': 'orange',

'preview': '_20220320105649389392.png'

},

"艺术暴风格2": {

'uri': "images/comic_style",

'name': 'face_paint_512_v1',

'color': 'blue',

'preview': '_20220320105756071508.png'

},

"艺术暴风格3": {

'uri': "images/comic_style",

'name': 'face_paint_512_v2',

'color': 'pink',

'preview': '_20220320105847286510.png'

},

"艺术暴风格4": {

'uri': "images/comic_style",

'name': 'paprika',

'color': 'cyan',

'preview': '_20220320105936594662.png'

},

}

},

}

app = bottle.default_app()

if 词组name词组 == "词组main词组":

bottle.run(host='localhost', port=8099)

可以看到,此时我的过分是,新近增了一个线性作为新近硬件对外暴露,那么为什么之外才刚的这两项中都,降低这样的一个硬件呢?而是要多公共安全一个线性呢?

AI 数学模型启动时速度慢,如果把借助AI处置本表的硬件应用软件进来,势必但会因素该硬件的效能; AI 数学模型所须内置的闪存但会尤其多,而借助 AI 处置本表的硬件所须要的闪存非常少,而闪存但会和刷卡有一定的间的关系,所以隔开有助于效率的降低;

关于第二个硬件(借助 AI 处置本表的硬件),整体而言是尤其简单的,没什么疑虑,但是针对第一个 AI 数学模型的硬件,就有尤其头疼的点:

数学模型所须要的缺少,有可能涉及到一些进制编译的流程,所以导致很难单独跨平台适用; 数学模型元图表尤其大 (所谓的 Pytorch 就超过 800M),线性计算的截图编译器最少才 100M,所以这个这两项很难单独截图;

所以这里须要充分利用 Serverless Devs 这两项来来进行处置:

参看

顺利来进行 s.yaml 的汇编就:

edition: 1.0.0

name: start-ai

access: "default"

vars: # 全局变量

region: cn-hangzhou

service:

name: ai

nasConfig: # NAS内置, 内置后function可以会面指定NAS

userId: 10003 # userID, 匹配为10003

groupId: 10003 # groupID, 匹配为10003

mountPoints: # 清单内置

- serverAddr: 0fe764bf9d-kci94.cn-hangzhou.nas.aliyuncs.com # NAS 服务项目器重定向

nasDir: /python3

fcDir: /mnt/python3

vpcConfig:

vpcId: vpc-bp1rmyncqxoagiyqnbcxk

securityGroupId: sg-bp1dpxwusntfryekord6

vswitchIds:

- vsw-bp1wqgi5lptlmk8nk5yi0

services:

image:

component: fc

props: # 元件的属性值

region: ${vars.region}

service: ${vars.service}

function:

name: image_server

description: 关键字处置服务项目

runtime: python3

codeUri: ./

ossBucket: temp-code-cn-hangzhou

handler: index.app

memorySize: 3072

timeout: 300

environmentVariables:

PYTHONUSERBASE: /mnt/python3/python

triggers:

- name: httpTrigger

type: http

config:

authType: anonymous

methods:

- GET

- POST

- PUT

customDomains:

- domainName: avatar.aialbum.net

protocol: HTTP

routeConfigs:

- path: /*

然后来进行:

1、缺少的安装:s build --use-docker

2、这两项的重新近部署:s deploy

3、在 NAS 中都始创清单,截图缺少:

s nas command mkdir /mnt/python3/python

s nas upload -r 本地缺少逆时针 /mnt/python3/python

顺利来进行以后可以通过硬件对这两项来进行测试。

另外,腾讯小程序在须要 https 的一人硬件,所以这里还须要内置 https 相关的特许信息,此处不花钱展开。 小程序在这两项

小程序在这两项依旧引入 colorUi,整个这两项就只有一个关键字:

关键字相关整体设计:

第一步:未必须要关键字

本地截图关键字

借助意味著塑像

* 该网站关键字可浏览,粗大按关键字可编辑

第二步:未必须要关键字处置拟议

wx:for-index="style" bindtap="changeStyle">

{{style}}

wx:for-index="substyle" bindtap="changeStyle" bindlongpress="showModal">

{{substyle}}

* 粗大按艺术暴风格圆点可以浏览模板效果

type="">{{ userChosePhoho ? (getPhotoStatus ? 'AI将花费较粗大时间' : '转化关键字') : '请先未必须要关键字' }}

转化结果

服务项目暂时不能不用,请稍后键入

或关联开源腾讯:zhihuiyushaiqi

* 该网站关键字可浏览,粗大按关键字可保存

自豪的引入 Serverless Devs 搭建

Powered By Anycodes {{""}}

笔记的话

大家好,我是刘宏,很感谢您可以关切和适用这个小程序在,这个小程序在是我用其间花钱的一个塑像转化小机器,基于“人工智障”关键技术,反正现在怎么看怎么别扭,但是我但会努力让这小程序在变得“平板”起来的。如果你有什么好的意见也赞赏关联我邮箱或者腾讯,另外值得一提的是,本这两项基于阿里幽Serverless虚拟化,通过Serverless Devs开源机器新近建。

关闭浏览

关键字逻辑也是尤其简单的:

// index.js

// 借助应用示例

const app = getApp()

Page({

data: {

styleList: {},

currentStyle: "双手机游戏暴风",

currentSubStyle: "v1数学模型",

userChosePhoho: undefined,

resultPhoto: undefined,

previewStyle: undefined,

getPhotoStatus: false

},

// 事件处置线性

bindViewTap() {

wx.navigateTo({

url: '../logs/logs'

})

},

() {

const that = this

wx.showLoading({

title: '启动时中都',

})

app.doRequest(MLT-system/stylesMLT-, {}, option = {

method: "GET"

}).then(function (result) {

wx.hideLoading()

that.setData({

styleList: result,

currentStyle: Object.keys(result)[0],

currentSubStyle: Object.keys(result[Object.keys(result)[0]].detailList)[0],

})

})

},

changeStyle(attr) {

this.setData({

"currentStyle": attr.currentTarget.dataset.style || this.data.currentStyle,

"currentSubStyle": attr.currentTarget.dataset.substyle || Object.keys(this.data.styleList[attr.currentTarget.dataset.style].detailList)[0]

})

},

chosePhoto() {

const that = this

wx.chooseImage({

count: 1,

sizeType: ['compressed'],

sourceType: ['album', 'camera'],

complete(res) {

that.setData({

userChosePhoho: res.tempFilePaths[0],

resultPhoto: undefined

})

}

})

},

headimgHD(imageUrl) {

imageUrl = imageUrl.split('/'); //把塑像的逆时针切成数组

//把一般来说参数为 46 || 64 || 96 || 132 的转换为0

if (imageUrl[imageUrl.length - 1] && (imageUrl[imageUrl.length - 1] == 46 || imageUrl[imageUrl.length - 1] == 64 || imageUrl[imageUrl.length - 1] == 96 || imageUrl[imageUrl.length - 1] == 132)) {

imageUrl[imageUrl.length - 1] = 0;

}

imageUrl = imageUrl.join('/'); //重新近堆砌为字串

return imageUrl;

},

getUserAvatar() {

const that = this

wx.getUserProfile({

desc: "借助您的塑像",

success(res) {

const newAvatar = that.headimgHD(res.userInfo.avatarUrl)

wx.getImageInfo({

src: newAvatar,

success(res) {

that.setData({

userChosePhoho: res.path,

resultPhoto: undefined

})

}

})

}

})

},

previewImage(e) {

wx.previewImage({

urls: [e.currentTarget.dataset.image]

})

},

editImage() {

const that = this

wx.editImage({

src: this.data.userChosePhoho,

success(res) {

that.setData({

userChosePhoho: res.tempFilePath

})

}

})

},

getNewPhoto() {

const that = this

wx.showLoading({

title: '关键字转化中都',

})

this.setData({

getPhotoStatus: true

})

app.doRequest(this.data.styleList[this.data.currentStyle].detailList[this.data.currentSubStyle].uri, {

style: this.data.styleList[this.data.currentStyle].detailList[this.data.currentSubStyle].name,

image: wx.getFileSystemManager().readFileSync(this.data.userChosePhoho, "")

}, option = {

method: "POST"

}).then(function (result) {

wx.hideLoading()

that.setData({

resultPhoto: result.error ? "error" : result.photo,

getPhotoStatus: false

})

})

},

saveImage() {

wx.saveImageToPhotosAlbum({

filePath: this.data.resultPhoto,

success(res) {

wx.showToast({

title: "保存事与愿违"

})

},

fail(res) {

wx.showToast({

title: "极其,稍后键入"

})

}

})

},

onShareAppMessage: function () {

return {

title: "头头是道个性塑像",

}

},

onShareTimeline() {

return {

title: "头头是道个性塑像",

}

},

showModal(e) {

if(e.currentTarget.dataset.target=="Image"){

const previewSubStyle = e.currentTarget.dataset.substyle

const previewSubStyleUrl = this.data.styleList[this.data.currentStyle].detailList[previewSubStyle].preview

if(previewSubStyleUrl){

this.setData({

previewStyle: previewSubStyleUrl

})

}else{

wx.showToast({

title: "均有模板浏览",

icon: "error"

})

return

}

}

this.setData({

modalName: e.currentTarget.dataset.target

})

},

hideModal(e) {

this.setData({

modalName: null

})

},

copyData(e) {

wx.setClipboardData({

data: e.currentTarget.dataset.data,

success(res) {

wx.showModal({

title: '复制顺利来进行',

content: MLT-已将${e.currentTarget.dataset.data}复制到了剪切板MLT-,

})

}

})

},

})

因为这两项但会乞求尤其多次的一人硬件,所以,我将乞求方法来进行额外的直觉:

// 标准化乞求硬件

doRequest: async function (uri, data, option) {

const that = this

return new Promise((resolve, reject) => {

wx.request({

url: that.url + uri,

data: data,

header: {

"Content-Type": 'application/json',

},

method: option && option.method ? option.method : "POST",

success: function (res) {

resolve(res.data)

},

fail: function (res) {

reject(null)

}

})

})

}

顺利来进行以后内置一下一人硬件,披露审核即可。

本文笔记刘宏(花名:江昱)

本文为阿里幽原创内容,未获受限制不得转载。

长沙看牛皮癣哪个医院比较好
腰肌劳损腰疼用什么药好
成都风湿挂号
湖北男科检查费用
辽宁妇科医院哪家比较专业
相关阅读
友情链接