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 a65da8d1
authored
Sep 04, 2017
by
BoxuanXu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add mysql clock class
1 parent
ff5da1c0
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
9 deletions
src/Drive_Converter.py
src/converter.py
src/mysql_glock.py
src/Drive_Converter.py
View file @
a65da8d
...
@@ -16,6 +16,8 @@ from flask import Flask,request
...
@@ -16,6 +16,8 @@ from flask import Flask,request
from
jenkinsapi.jenkins
import
Jenkins
from
jenkinsapi.jenkins
import
Jenkins
from
mysql_glock
import
Mysql_lock
import
GProgress
as
GP
import
GProgress
as
GP
import
Queue
import
Queue
...
@@ -57,11 +59,19 @@ db_atlas = pymysql.connect("192.168.1.127","defaultUser","magician","seetaAtlas"
...
@@ -57,11 +59,19 @@ db_atlas = pymysql.connect("192.168.1.127","defaultUser","magician","seetaAtlas"
curl_atlas
=
db_atlas
.
cursor
()
curl_atlas
=
db_atlas
.
cursor
()
curl_atlas_exe
=
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
):
def
get_path_from_db
(
modelid
,
seetanet_model
):
curl_atlas
.
execute
(
"select path from seetaAtlas.model where id='
%
s'"
%
modelid
)
#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
()
result_atlas
=
curl_atlas
.
fetchall
()
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
:
if
len
(
result_atlas
)
!=
1
:
...
@@ -121,11 +131,14 @@ def get_path_from_db(modelid,seetanet_model):
...
@@ -121,11 +131,14 @@ def get_path_from_db(modelid,seetanet_model):
#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
)
result
=
Run_Converter
(
params_name
,
graph_name
,
seetanet_model
)
<<<<<<<
HEAD
if
result
is
"true"
:
=======
if
result
is
true
:
if
result
is
true
:
>>>>>>>
ff5da1c0fae179995c0a806eb77fe2667ccc191a
return
None
,
None
return
None
,
None
#Run_Converter("model-0015.params","model-symbol.json",seetanet_model)
#Run_Converter("model-0015.params","model-symbol.json",seetanet_model)
return
params_name
,
graph_name
return
params_name
,
graph_name
def
upload_filetoFastDFS
(
params_name
,
graph_name
,
seetanet_model
):
def
upload_filetoFastDFS
(
params_name
,
graph_name
,
seetanet_model
):
...
...
src/converter.py
View file @
a65da8d
...
@@ -64,6 +64,7 @@ class Converter(object):
...
@@ -64,6 +64,7 @@ class Converter(object):
'Scale'
:
self
.
convert_scale
,
'Scale'
:
self
.
convert_scale
,
'Activation'
:
self
.
convert_activation
,
'Activation'
:
self
.
convert_activation
,
'add_n'
:
self
.
convert_add_n
,
'add_n'
:
self
.
convert_add_n
,
'elemwise_add'
:
self
.
convert_add_n
,
'Convolution'
:
self
.
convert_conv
,
'Convolution'
:
self
.
convert_conv
,
'FullyConnected'
:
self
.
convert_fc
,
'FullyConnected'
:
self
.
convert_fc
,
# 'Flatten': self.convert_bn,
# 'Flatten': self.convert_bn,
...
@@ -238,15 +239,19 @@ class Converter(object):
...
@@ -238,15 +239,19 @@ class Converter(object):
raise
NotImplementedError
raise
NotImplementedError
pad
=
parse_tuple
(
attr
[
'pad'
])
pad
=
parse_tuple
(
attr
[
'pad'
])
# TODO:现在强制VALID=True,后续有mxnet使用其他pool padding的方式时再修改
# TODO:现在强制VALID=True,后续有mxnet使用其他pool padding的方式时再修改
pool
.
valid
=
True
try
:
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'
])
stride
=
parse_tuple
(
attr
[
'stride'
])
pool
.
stride_height
=
stride
[
0
]
pool
.
stride_height
=
stride
[
0
]
pool
.
stride_width
=
stride
[
1
]
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
return
wapper
def
convert_activation
(
self
,
layer
):
def
convert_activation
(
self
,
layer
):
...
@@ -415,6 +420,9 @@ def Run_Converter(model_param,model_json,seetanet_model):
...
@@ -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_param',type=str,default = None)
#parser.add_argument('--model_json',type=str,default = None)
#parser.add_argument('--model_json',type=str,default = None)
#args = parser.parse_args()
#args = parser.parse_args()
#model_param = "wKgB6Fmo2w2ASRqpBky2APcM8zs.params"
#model_json = "wKgB6Vmo2w2AXrJbAAGjO2NrZLE75.json"
#seetanet_model = "model_test"
try
:
try
:
sym
,
arg_params
,
aux_params
=
\
sym
,
arg_params
,
aux_params
=
\
load_checkpoint
(
model_param
,
model_json
)
load_checkpoint
(
model_param
,
model_json
)
...
@@ -426,3 +434,4 @@ def Run_Converter(model_param,model_json,seetanet_model):
...
@@ -426,3 +434,4 @@ def Run_Converter(model_param,model_json,seetanet_model):
return
true
return
true
except
Exception
,
e
:
except
Exception
,
e
:
return
None
return
None
#print(e)
src/mysql_glock.py
0 → 100644
View file @
a65da8d
#!/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