Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
BoxuanXu
/
FlaskDriverMXNet2SeetaNet
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 3b86b54a
authored
Sep 04, 2017
by
BoxuanXu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add mysql clock class
1 parent
cb4f8291
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
98 additions
and
19 deletions
src/Drive_Converter.py
src/GProgress.py
src/config.py
src/converter.py
src/mysql_glock.py
src/Drive_Converter.py
View file @
3b86b54
...
...
@@ -16,6 +16,8 @@ from flask import Flask,request
from
jenkinsapi.jenkins
import
Jenkins
from
mysql_glock
import
Mysql_lock
import
GProgress
as
GP
import
Queue
...
...
@@ -57,12 +59,20 @@ db_atlas = pymysql.connect("192.168.1.127","defaultUser","magician","seetaAtlas"
curl_atlas
=
db_atlas
.
cursor
()
curl_atlas_exe
=
db_atlas
.
cursor
()
db_l
=
Mysql_lock
()
lock_name
=
'db_queue'
def
get_path_from_db
(
modelid
,
seetanet_model
):
curl_atlas
.
execute
(
"select path from seetaAtlas.model where id='
%
s'"
%
modelid
)
result_atlas
=
curl_atlas
.
fetchall
()
#curl_atlas.execute("select path from seetaAtlas.model where id='%s'" % modelid)
ret
=
db_l
.
lock
(
lock_name
,
10
)
if
ret
!=
True
:
logging
.
info
(
"Can't get lock! exit!"
)
quit
()
ret
=
db_l
.
_execute
(
"select path from seetaAtlas.model where id='
%
s'"
%
modelid
)
result_atlas
=
db_l
.
cursor
.
fetchall
()
db_l
.
unlock
(
lock_name
)
if
len
(
result_atlas
)
!=
1
:
logging
.
info
(
'get wrong mxnet model path'
)
...
...
@@ -119,13 +129,12 @@ def get_path_from_db(modelid,seetanet_model):
GP
.
set_progress_var
(
10
)
GP
.
Post_return
()
#Driver converter model by params and model graph
#Driver converter model by params and model graph
result
=
Run_Converter
(
params_name
,
graph_name
,
seetanet_model
)
if
result
is
true
:
if
result
is
"true"
:
return
None
,
None
#Run_Converter("model-0015.params","model-symbol.json",seetanet_model)
return
params_name
,
graph_name
def
upload_filetoFastDFS
(
params_name
,
graph_name
,
seetanet_model
):
...
...
src/GProgress.py
View file @
3b86b54
...
...
@@ -9,8 +9,8 @@ __Date__ = "20170812"
import
requests
#post_url = "http://192.168
l.1.170:1234/API
"
post_url
=
"http://192.168.1.
244:5000/result
"
#post_url = "http://192.168
.1.244:5000/result
"
post_url
=
"http://192.168.1.
127:1234/API
"
class
GProgress_Var
:
posttype
=
None
;
...
...
@@ -32,5 +32,6 @@ def set_err_msg_var(err_msg):
def
Post_return
():
post_return
=
{
"posttype"
:
GProgress_Var
.
posttype
,
"progress"
:
GProgress_Var
.
progress
,
"pool_id"
:
GProgress_Var
.
pool_id
,
"err_msg"
:
GProgress_Var
.
err_msg
}
print
(
post_return
)
requests
.
post
(
post_url
,
data
=
post_return
)
src/config.py
View file @
3b86b54
DATA_NAME
=
'data'
DATA_NAME
=
'data
_0
'
OUTPUT_LAYER
=
''
#MODEL_PARAM = '/home/dev01/workshop/projects/MXNet2SeetaNet/model-0015.params'
#MODEL_JSON = '/home/dev01/workshop/projects/MXNet2SeetaNet/model-symbol.json'
...
...
src/converter.py
View file @
3b86b54
...
...
@@ -64,6 +64,7 @@ class Converter(object):
'Scale'
:
self
.
convert_scale
,
'Activation'
:
self
.
convert_activation
,
'add_n'
:
self
.
convert_add_n
,
'elemwise_add'
:
self
.
convert_add_n
,
'Convolution'
:
self
.
convert_conv
,
'FullyConnected'
:
self
.
convert_fc
,
# 'Flatten': self.convert_bn,
...
...
@@ -238,15 +239,19 @@ class Converter(object):
raise
NotImplementedError
pad
=
parse_tuple
(
attr
[
'pad'
])
# TODO:现在强制VALID=True,后续有mxnet使用其他pool padding的方式时再修改
pool
.
valid
=
True
pool
.
pad_height
=
pad
[
0
]
pool
.
pad_width
=
pad
[
1
]
kernel
=
parse_tuple
(
attr
[
'kernel'
])
pool
.
kernel_height
=
kernel
[
0
]
pool
.
kernel_width
=
kernel
[
1
]
stride
=
parse_tuple
(
attr
[
'stride'
])
pool
.
stride_height
=
stride
[
0
]
pool
.
stride_width
=
stride
[
1
]
try
:
stride
=
parse_tuple
(
attr
[
'stride'
])
pool
.
stride_height
=
stride
[
0
]
pool
.
stride_width
=
stride
[
1
]
pad
=
parse_tuple
(
attr
[
'pad'
])
pool
.
valid
=
True
pool
.
pad_height
=
pad
[
0
]
pool
.
pad_width
=
pad
[
1
]
except
:
logging
.
info
(
'layer:
%
s is global pooling !!!'
%
layer
.
name
)
pool
.
global_pooling
=
True
pool
.
stride_height
=
kernel
[
0
]
pool
.
stride_width
=
kernel
[
1
]
return
wapper
def
convert_activation
(
self
,
layer
):
...
...
@@ -415,6 +420,9 @@ def Run_Converter(model_param,model_json,seetanet_model):
#parser.add_argument('--model_param',type=str,default = None)
#parser.add_argument('--model_json',type=str,default = None)
#args = parser.parse_args()
#model_param = "wKgB6Fmo2w2ASRqpBky2APcM8zs.params"
#model_json = "wKgB6Vmo2w2AXrJbAAGjO2NrZLE75.json"
#seetanet_model = "model_test"
try
:
sym
,
arg_params
,
aux_params
=
\
load_checkpoint
(
model_param
,
model_json
)
...
...
@@ -426,3 +434,4 @@ def Run_Converter(model_param,model_json,seetanet_model):
return
true
except
Exception
,
e
:
return
None
#print(e)
src/mysql_glock.py
0 → 100644
View file @
3b86b54
#!/usr/bin/env python
#_*_ coding: UTF-8 _*_
import
pymysql.cursors
import
logging
import
time
__website__
=
"www.seetatech.com"
__author__
=
"seetatech"
__editor__
=
"xuboxuan"
__Date__
=
"20170904"
#initlization the logging
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
"[
%(asctime)
s]
%(name)
s:
%(levelname)
s:
%(message)
s"
)
db_atlas
=
pymysql
.
connect
(
"192.168.1.127"
,
"defaultUser"
,
"magician"
,
"seetaAtlas"
,
3306
)
class
Mysql_lock
:
def
__init__
(
self
):
self
.
db
=
db_atlas
self
.
cursor
=
db_atlas
.
cursor
()
def
_execute
(
self
,
sql
):
cursor
=
self
.
db
.
cursor
()
try
:
ret
=
self
.
cursor
.
execute
(
sql
)
return
ret
except
Exception
,
ex
:
logging
.
info
(
"Execute sql
\"
%
s
\"
failed! Exception:
%
s"
,
sql
,
str
(
ex
))
#cursor.close()
return
None
def
lock
(
self
,
lockstr
,
timeout
):
sql
=
"SELECT GET_LOCK('
%
s',
%
s)"
%
(
lockstr
,
timeout
)
ret
=
self
.
_execute
(
sql
)
if
ret
==
0
:
logging
.
info
(
"Another client has previously locked '
%
s'."
,
lockstr
)
return
False
elif
ret
==
1
:
logging
.
info
(
"The lock '
%
s' was obtained successfully."
,
lockstr
)
return
True
else
:
logging
.
info
(
"Error occurred!"
)
return
None
def
unlock
(
self
,
lockstr
):
sql
=
"SELECT RELEASE_LOCK('
%
s')"
%
(
lockstr
)
ret
=
self
.
_execute
(
sql
)
if
ret
==
0
:
logging
.
info
(
"The lock '
%
s' the lock is not released(the lock was not established by this thread)."
,
lockstr
)
return
False
elif
ret
==
1
:
logging
.
info
(
"The lock '
%
s' the lock was released."
,
lockstr
)
return
True
else
:
logging
.
info
(
"The lock '
%
s' did not exist."
,
lockstr
)
return
None
Write
Preview
Markdown
is supported
Attach a file
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 post a comment