首页 >> 中药养生

基于 Serverless 架构的半身像漫画风处理小程序

发布时间:2022年07月28日 12:18

f 词组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将花费较总长时间' : '分解成相片') : '代为可先必才可相片' }}

分解成结果

服务项目暂时不能不用,代为稍晚键入

或联系Valve微信:zhihuiyushaiqi

* 点击相片可演示,总长按相片可存放

自豪的引入 Serverless Devs 搭建

Powered By Anycodes {{""}}

作者的话

大家好,我是建平,很感谢您可以重视和使用这个小处理程序,这个小处理程序是我用业余时间来作的一个雕像分解成小机器,基于“人工智障”高效率,反正现在怎么看怎么平常,但是我就会共同努力让这小处理程序变得“智能”上去的。如果你有什么好的赞同也欢迎联系我电邮或者微信,另外在在,本新项目基于阿里云Serverless虚拟化,通过Serverless DevsValve机器建设。

封闭演示

关键词演算也是较为简单的:

// 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(在在system/styles在在, {}, 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: 在在已将${e.currentTarget.dataset.data}副本到了剪切板在在,

})

}

})

},

})

因为新项目就会代为求较为多次的一人模块,所以,我将代为求方法来进行额外的具象:

// 实质上代为求模块

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)

}

})

})

}

启动之后可用一下一人模块,发布初审方可。

本文作者建平(说是:江昱)

本文为阿里云原创主旨,未经允许不得转载。

天津牛皮癣正规的医院
宁波妇科医院哪个比较好
深圳牛皮癣医院排行
太原白癜风最好医院是哪个
上海眼科医院哪家专业
友情链接