Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
b777802c
Commit
b777802c
authored
May 11, 2020
by
高宇强
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gyq
parent
5559140d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
178 deletions
+6
-178
ailogo/CreateScene.py
+2
-2
ailogo/GetLogo.py
+4
-4
ailogo/LogoManage.py
+0
-0
ailogo/LogoReqAnalysis.py
+0
-172
No files found.
ailogo/CreateScene.py
View file @
b777802c
...
@@ -20,8 +20,8 @@ def queryscene(api,inputdata):
...
@@ -20,8 +20,8 @@ def queryscene(api,inputdata):
return
""
return
""
def
sceneservers
(
inputdata
):
def
sceneservers
(
inputdata
):
#connection = pymysql.connect(host='172.16.18.140', port=3306, user='root', passwd='x8BOQk./1}bC&=+', db='logo_msg')
connection
=
pymysql
.
connect
(
host
=
'rm-2zey194899z131oufao.mysql.rds.aliyuncs.com'
,
port
=
3306
,
user
=
'root'
,
connection
=
pymysql
.
connect
(
host
=
'43.247.184.94'
,
port
=
8898
,
user
=
'root'
,
passwd
=
'x8BOQk./1}bC&=+'
,
db
=
'logo_msg'
)
passwd
=
'Gongsibao2018'
,
db
=
'logo_msg'
)
# 阿里云
cur
=
connection
.
cursor
(
cursor
=
pymysql
.
cursors
.
DictCursor
)
cur
=
connection
.
cursor
(
cursor
=
pymysql
.
cursors
.
DictCursor
)
try
:
try
:
# 得到gen_json
# 得到gen_json
...
...
ailogo/GetLogo.py
View file @
b777802c
...
@@ -10,8 +10,8 @@ import pymysql
...
@@ -10,8 +10,8 @@ import pymysql
import
re
import
re
def
getLogoUrl
(
inputdata
):
def
getLogoUrl
(
inputdata
):
#connection = pymysql.connect(host='172.16.18.140', port=3306, user='root', passwd='x8BOQk./1}bC&=+', db='logo_msg')
connection
=
pymysql
.
connect
(
host
=
'rm-2zey194899z131oufao.mysql.rds.aliyuncs.com'
,
port
=
3306
,
user
=
'root'
,
connection
=
pymysql
.
connect
(
host
=
'43.247.184.94'
,
port
=
8898
,
user
=
'root'
,
passwd
=
'x8BOQk./1}bC&=+'
,
db
=
'logo_msg'
)
passwd
=
'Gongsibao2018'
,
db
=
'logo_msg'
)
# 阿里云
cur
=
connection
.
cursor
(
cursor
=
pymysql
.
cursors
.
DictCursor
)
cur
=
connection
.
cursor
(
cursor
=
pymysql
.
cursors
.
DictCursor
)
try
:
try
:
#得到gen_json
#得到gen_json
...
@@ -75,8 +75,8 @@ def getLogoUrl(inputdata):
...
@@ -75,8 +75,8 @@ def getLogoUrl(inputdata):
return
False
,{}
return
False
,{}
def
updateData
(
inputdata
):
def
updateData
(
inputdata
):
#connection = pymysql.connect(host='172.16.18.140', port=3306, user='root', passwd='x8BOQk./1}bC&=+', db='logo_msg')
connection
=
pymysql
.
connect
(
host
=
'rm-2zey194899z131oufao.mysql.rds.aliyuncs.com'
,
port
=
3306
,
user
=
'root'
,
connection
=
pymysql
.
connect
(
host
=
'43.247.184.94'
,
port
=
8898
,
user
=
'root'
,
passwd
=
'x8BOQk./1}bC&=+'
,
db
=
'logo_msg'
)
passwd
=
'Gongsibao2018'
,
db
=
'logo_msg'
)
# 阿里云
cur
=
connection
.
cursor
(
cursor
=
pymysql
.
cursors
.
DictCursor
)
cur
=
connection
.
cursor
(
cursor
=
pymysql
.
cursors
.
DictCursor
)
try
:
try
:
#更新数据库中的标记
#更新数据库中的标记
...
...
ailogo/LogoManage.py
View file @
b777802c
This diff is collapsed.
Click to expand it.
ailogo/LogoReqAnalysis.py
deleted
100644 → 0
View file @
5559140d
#!/usr/bin/python3
# -*- coding: utf-8 -*- #文件也为UTF-8
import
json
import
random
import
pymysql
# 客户输入信息
#0.读取配置信息和
connection
=
pymysql
.
connect
(
host
=
'43.247.184.94'
,
port
=
8898
,
user
=
'root'
,
passwd
=
'x8BOQk./1}bC&=+'
,
db
=
'logo_msg'
)
#connection = pymysql.connect(host='172.16.18.140', port=3306, user='root', passwd='x8BOQk./1}bC&=+', db='logo_msg')
cur
=
connection
.
cursor
()
LogoHash
=
{}
#fontlist=["font/cn/hwzs.ttf","font/cn/hwfs.ttf"]
fontlist
=
[
"font/cn/hwzs.ttf"
,
"font/cn/hwfs.ttf"
,
"font/cn/白舟·侍.ttf"
,
"font/cn/白舟隼風.ttf"
,
"font/cn/潮字社風雲繁.ttf"
,
"font/cn/潮字社凌渡鯤鵬繁.ttf"
,
"font/cn/潮字社时光简.ttf"
,
"font/cn/潮字社時光繁.ttf"
,
"font/cn/德彪钢笔行书字库.ttf"
,
"font/cn/郭小语钢笔楷体.ttf"
,
"font/cn/微软vista雅黑.ttf"
]
def
Init
():
#LogoHash加入数据
#字体增加到系统
fontlist
.
append
(
"font/cn/hwzs.ttf"
)
return
""
def
LogoHashInit
():
#实现这个方法,从数据库里获取logo信息
sql
=
'select id,first_color,sec_color,height,width,profession,description,textpos,pic_url,'
\
'originality,logo_id from logo_desc '
cur
.
execute
(
sql
)
data
=
cur
.
fetchall
()
result
=
[]
for
itm
in
data
:
res
=
{}
res
[
"id"
]
=
itm
[
0
]
res
[
"first_color"
]
=
itm
[
1
]
res
[
"sec_color"
]
=
itm
[
2
]
res
[
"height"
]
=
itm
[
3
]
res
[
"width"
]
=
itm
[
4
]
res
[
"profession"
]
=
itm
[
5
]
res
[
"description"
]
=
itm
[
6
]
res
[
"textpso"
]
=
itm
[
7
]
res
[
"pic_url"
]
=
itm
[
8
]
res
[
"originality"
]
=
itm
[
9
]
res
[
"logo_id"
]
=
itm
[
10
]
result
.
append
(
res
)
connection
.
close
()
return
result
def
FontInit
():
#实现这个方法,从数据库里获取字体信息
#从数据库里获取字体名称,放到fontlist里
select_sql
=
'select name from logo_font'
cur
.
execute
(
select_sql
)
datas
=
cur
.
fetchall
()
for
data
in
datas
:
fontlist
.
append
(
data
)
font
=
random
.
sample
(
fontlist
,
1
)
connection
.
close
()
return
font
def
search
(
text
):
logo_res
=
[]
#bc = BertClient()
#textmatrix=bc.encode(['暴风粒子'])
#xx=search(textmatrix)
#处理xx,得到logoIDs
#logo_res.append(logoIDs)
return
logo_res
def
logoFilter
(
logo_res
,
profession
):
logo_res_content
=
[]
for
logoNo
in
logo_res
:
logocontent
=
LogoHash
[
logoNo
]
if
logocontent
[
"profession"
]
==
profession
:
logo_res_content
.
append
(
logocontent
)
return
logo_res_content
def
semanticsAnalysis
(
text
,
profession
):
logo_res
=
[]
logo_res_content
=
[]
#检索得到logo结合
logo_res
=
search
(
text
)
for
logoNo
in
logo_res
:
logocontent
=
LogoHash
[
logoNo
]
logo_res_content
.
append
(
logocontent
)
#1.3分析行业属性,利用行业过滤logo
logo_res_content
=
logoFilter
(
logo_res_content
,
profession
)
#1.5过滤50个
logo_res_content
=
logo_res_content
[
0
:
50
]
return
logo_res
def
templateAnalysis
(
text
,
profession
):
logo_res
=
[]
return
logo_res
def
process
(
inputdata
):
# inputdata = {
# 'title': '微信',
# 'subtitle':'wechat',
# 'profession':'通讯行业',
# 'description':'一款跨平台的通讯工具。支持单人、多人参与。通过手机网络发送语音、图片、视频和文字。'
# }
print
(
inputdata
)
#调用语义引擎进行logo获取
#1.1语义分析(对title进行分析).语义分析有规则
semlogo_res
=
semanticsAnalysis
(
inputdata
[
'title'
],
inputdata
[
'profession'
])
#调用模板引擎进行logo获取
temlogo_res
=
templateAnalysis
(
inputdata
[
'title'
],
inputdata
[
'profession'
])
#logo
semlogo_res
=
semlogo_res
.
append
(
temlogo_res
)
#logo顺序随机
# 随机list
#reslist = random.sample(semlogo_res, len(semlogo_res))
reslist
=
[]
#结果样例
logo_resource
=
{
"logo_id"
:
1
,
"first_color"
:
"(192,52,116)"
,
#logo主色 --title
"sec_color"
:
"(230,231,232)"
,
#logo配色 --subtitle
"height"
:
900
,
#logo高度
"width"
:
900
,
#logo宽度
"profession"
:
"通讯行业"
,
#logo所属行业
"description"
:
"深红色象征着热情,活泼,张扬"
,
#主色描述
"textpos"
:
"right"
,
#文字位置 上下左右
"pic_url"
:
"d:/logo1.png"
,
#logo地址
"originality"
:
"火"
,
#logo创意 带字母的 带山带水等
"groundcolor"
:
"(255,255,255)"
,
#背景色
"people"
:
"qw"
,
#加工人
"type"
:
"standard"
,
#template or standard
"msg_id"
:
1
}
reslist
.
append
(
logo_resource
)
print
(
reslist
)
return
reslist
#inputdata是输入数据
#resitem是一个logo信息
def
TemplateSingleLogoProcess
(
inputdata
):
#5.2 随机一个
randnum
=
random
.
randint
(
0
,
len
(
fontlist
)
-
1
)
font
=
fontlist
[
randnum
]
print
(
font
)
#6.拼结果对象,生成logo
logogendata
=
{}
#输出
logogendata
=
{
'brand_text'
:
inputdata
[
'title'
],
#品牌名称
'brand_font'
:
font
,
#
'brand_color'
:
inputdata
[
'first_color'
],
#字体颜色
'brand_location'
:
inputdata
[
'textpos'
],
#左右上下
'slogan_text'
:
inputdata
[
'subtitle'
],
#标语名称
'slogan_font'
:
font
,
#
'slogan_color'
:
inputdata
[
'sec_color'
],
#标语颜色
'logo_url'
:
inputdata
[
'log_url'
]
#图片地址
}
json_str
=
json
.
dumps
(
logogendata
)
return
json_str
def
StandardSingleLogoProcess
(
inputdata
):
#5.2 随机一个
print
(
"////////////////////"
)
print
(
len
(
fontlist
))
randnum
=
random
.
randint
(
0
,
len
(
fontlist
)
-
1
)
font
=
fontlist
[
randnum
]
#6.拼结果对象,生成logo
logogendata
=
{
'brand_text'
:
inputdata
[
'title'
],
#品牌名称
'brand_font'
:
font
,
#
'brand_color'
:
inputdata
[
'first_color'
],
#字体颜色
'brand_location'
:
inputdata
[
'textpos'
],
#左右上下
'slogan_text'
:
inputdata
[
'subtitle'
],
#标语名称
'slogan_font'
:
font
,
#
'slogan_color'
:
inputdata
[
'sec_color'
],
#标语颜色
'logo_url'
:
inputdata
[
'log_url'
]
#图片地址
}
json_str
=
logogendata
return
json_str
def
SingleLogoProcess
(
inputdata
):
if
inputdata
[
"type"
]
==
"template"
:
return
TemplateSingleLogoProcess
(
inputdata
)
else
:
return
StandardSingleLogoProcess
(
inputdata
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment