Commit e2f9c348 authored by 武继龙's avatar 武继龙

add one function

parent f94a4f95
No preview for this file type
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/onnx.iml" filepath="$PROJECT_DIR$/.idea/onnx.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/onnx_infer/yolo3" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
This diff is collapsed.
...@@ -24,8 +24,6 @@ class Main: ...@@ -24,8 +24,6 @@ class Main:
self.colorOnnx_path = colorOnnx_path self.colorOnnx_path = colorOnnx_path
self.yoloOnnx_path = yoloOnnx_path self.yoloOnnx_path = yoloOnnx_path
self.image_path = image_path self.image_path = image_path
self.anchor_path = 'model_data/yolo_anchors.txt'
self.classes_path = 'model_data/deepfashion.txt'
self.score = 0.05 self.score = 0.05
self.iou = 0.05 self.iou = 0.05
self.picSize = (416, 416) self.picSize = (416, 416)
...@@ -40,7 +38,7 @@ class Main: ...@@ -40,7 +38,7 @@ class Main:
feature = [] feature = []
for f in precit: for f in precit:
feature.append(tf.convert_to_tensor(f)) feature.append(tf.convert_to_tensor(f))
sup = Supress(self.anchor_path, self.classes_path, self.score, self.iou, feature) sup = Supress(self.score, self.iou, feature)
box, score, classes = sup.detect(image) box, score, classes = sup.detect(image)
with tf.Session() as sess: with tf.Session() as sess:
bbox = box.eval()[0] bbox = box.eval()[0]
...@@ -58,6 +56,12 @@ class Main: ...@@ -58,6 +56,12 @@ class Main:
# main test # main test
def get_result(colorOnnx_path, yoloOnnx_path, image_path):
m = Main(colorOnnx_path, yoloOnnx_path, image_path)
color, bbox, category = m.colorAndbboxAndcategory()
return color, bbox, category
if __name__ == '__main__': if __name__ == '__main__':
colorOnnx_path = '/Users/apple/Desktop/color.onnx' colorOnnx_path = '/Users/apple/Desktop/color.onnx'
image_path = '/Users/apple/Desktop/8.jpg' image_path = '/Users/apple/Desktop/8.jpg'
......
long sleeve dress
vest dress
vest
long sleeve outwear
long sleeve top
trousers
short sleeve top
sling dress
skirt
short sleeve dress
shorts
10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326
...@@ -4,9 +4,7 @@ from yolo3.model import yolo_eval ...@@ -4,9 +4,7 @@ from yolo3.model import yolo_eval
import os import os
class Supress: class Supress:
def __init__(self, anchorPath, classPath, score, iou, featureMap): def __init__(self, score, iou, featureMap):
self.anchorPath = anchorPath
self.classPath = classPath
self.score = score self.score = score
self.iou = iou self.iou = iou
self.featureMap = featureMap self.featureMap = featureMap
...@@ -14,18 +12,14 @@ class Supress: ...@@ -14,18 +12,14 @@ class Supress:
def _get_class(self): def _get_class(self):
classes_path = os.path.expanduser(self.classPath) classNames = ['long sleeve dress', 'vest dress', 'vest', 'long sleeve outwear', 'long sleeve top', 'trousers',
with open(classes_path) as f: 'short sleeve top', 'sling dress', 'skirt', 'short sleeve dress', 'shorts']
classNames = f.readlines()
classNames = [x.strip() for x in classNames]
return classNames return classNames
def _get_anchors(self): def _get_anchors(self):
anchorPath = os.path.expanduser(self.anchorPath) anchors = [[10., 13.], [16., 30.], [33., 23.], [30., 61.], [62., 45.],
with open(anchorPath) as f: [59., 119.], [116., 90.], [156., 198.], [373., 326.]]
anchors = f.readline() return np.array(anchors)
anchors = [float(x) for x in anchors.split(',')]
return np.array(anchors).reshape(-1, 2)
def detect(self, image): def detect(self, image):
anchors = self._get_anchors() anchors = self._get_anchors()
......
#!/user/bin/python
from setuptools import setup, find_packages
setup(
name = 'onnx_infer',
version = '0.1.0',
description = 'model inference',
author = 'wjl',
url = 'http://git.wanmeizhensuo.com/wujilong/onnx_model.git',
author_email = 'wujilong@igengmei.com',
license = 'MIT',
packages = ['onnx_infer', 'onnx_infer.yolo3'],
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment