Пример #1
0
import os
import sys
import time
sys.path.append("your/path/to/shared/libraries")
sys.path.append("your/path/to/xstream/xproto/packages")
sys.setdlopenflags(os.RTLD_LAZY | os.RTLD_GLOBAL)

import xstream  # noqa
import vision_type as vt  # noqa
import xproto  # noqa

# it is more like a template
# attributes can be modified while defining workflow
faster_rcnn = xstream.Method("FasterRCNNMethod").inputs(["image"])
mot = xstream.Method("MOTMethod").inputs(["face_box"]) \
    .config_file("face_solution/configs/iou_method_param.json")
grading = xstream.Method("GradingMethod") \
    .inputs(["face_bbox_list", "pose", "lmk"])
snapshot = xstream.Method("SnapShotMethod") \
    .inputs([
        "image", "face_bbox_list", "select_score_list",
        "face_disappeared_track_id_list", "pose", "lmk",
        "face_bbox_list"])
cnn_method = xstream.Method("CNNMethod")


def face_solution(image):
    face_box, lmk, pose = faster_rcnn(
        image,
        outputs=["face_box", "lmk", "pose"],
        config_file="face_solution/configs/face_pose_lmk.json")
Пример #2
0
import sys
import os
import time
sys.path.append("your/path/to/shared/libraries")
sys.path.append("your/path/to/xstream/xproto/packages")
sys.setdlopenflags(os.RTLD_LAZY)
import xstream    # noqa
import vision_type as vt    # noqa

# 定义一个简单的workflow
bbox_method = xstream.Method("BBoxFilter").inputs(["in_bbox"])


def my_workflow(in_bbox):
    bbox_filtered_A = bbox_method(
        in_bbox, outputs=["bbox_filtered_A"],
        config_file="configs/pytest_configs/a_filter.json")
    bbox_filtered_B = bbox_method(
        in_bbox, outputs=["bbox_filtered_B"],
        config_file="configs/pytest_configs/b_filter.json")

    return bbox_filtered_A, bbox_filtered_B


json = xstream.serialize(my_workflow)
print(json)

# 创建session对象
session = xstream.Session(my_workflow)

Пример #3
0
import sys
import os

sys.path.append("your/path/to/shared/libraries")
sys.path.append("your/path/to/xstream/xproto/packages")
sys.setdlopenflags(os.RTLD_LAZY)
import xstream  # noqa

FasterRCNNMethod = xstream.Method("FasterRCNNMethod").inputs(["image"])

# "CNNMethod" 对应MethodFactory中的CNNMethod的名字字符串。
CNNMethod = xstream.Method("CNNMethod")

# 声明inputs和outputs可以赋予输入输出参数以名字,
# 可以在生成的json中体现,让json更加可读
AgeGenderPreProcess = xstream.Method("AgeGenderPreProcess").inputs(
    ["face_bbox_list", "image"]).outputs(["processed_image"])

AgeGenderPostProcess = xstream.Method("AgeGenderPostProcess").inputs(
    ["cnn_out"]).outputs(["age_list", "gender_list"])
# agegender_cnn的配置定义。这里包括框架支撑的属性如thread_count,
# 也包括method自定义的配置如method_conf
age_gender_cnn_conf = {"threadCnt": 3, "methodConfig": "age_gender.json"}


def cnn_workflow(pre_method, post_method, cnn_conf, inputs, name=""):
    # name scope,在这个scope下,所有定义的符号的名字,都会加入scope的前缀
    with xstream.scope(name):
        # 调用 NativeMethod.__call__ 方法。由于scope的存在,
        # 全局的名字为 name + "/" + "pre"
        pre_out0 = pre_method(*inputs, unique_name="pre")
Пример #4
0
import sys
import os
sys.setdlopenflags(os.RTLD_LAZY)
# workflow.py
import xstream  # noqa

# "CNNMethod" 对应MethodFactory中的CNNMethod的名字字符串。
CNNMethod = xstream.Method("CNNMethod")

# 声明inputs和outputs可以赋予输入输出参数以名字,
# 可以在生成的json中体现,让json更加可读
VehiclePreProcess = xstream.Method("VehiclePreProcess").inputs(
    ["image"]).outputs(["processed_image"])

VehiclePostProcess = xstream.Method("VehiclePostProcess").inputs(
    ["cnn_out"]).outputs(["vehicle_out"])
# vehicle_cnn的配置定义。这里包括框架支撑的属性如thread_count,
# 也包括method自定义的配置如method_conf
vehicle_cnn_conf = {"threadCnt": 3, "methodConfig": "vechicle_cfg.json"}

PedestrianPreProcess = xstream.Method("PedestrianPreProcess").inputs(
    ["image"]).outputs(["processed_image"])
PedestrianPostProcess = xstream.Method("PedestrianPostProcess").inputs(
    ["cnn_out"]).outputs(["pedestrian_out"])
pedestrian_cnn_conf = {"threadCnt": 5, "methodConfig": "pedestrian_cfg.json"}


def cnn_workflow(pre_method, post_method, cnn_conf, inputs, name=""):
    # name scope,在这个scope下,所有定义的符号的名字,都会加入scope的前缀
    with xstream.scope(name):
        # 调用 NativeMethod.__call__ 方法。由于scope的存在,
Пример #5
0
import os
import sys
import time
sys.setdlopenflags(os.RTLD_LAZY)

import xstream  # noqa
import vision_type as vt  # noqa
import xproto  # noqa

# it is more like a template
# attributes can be modified while defining workflow
faster_rcnn = xstream.Method("FasterRCNNMethod").inputs(["image"])
mot = xstream.Method("MOTMethod").inputs(["face_box"]) \
    .config_file("configs/method_configs/iou_method_param.json")
merge = xstream.Method("MergeMethod") \
    .config_file("configs/method_configs/merge_head_body.json")


def body_solution(image):
    body_box, head_box, face_box, lmk, pose, kps = faster_rcnn(
        image,
        outputs=["body_box", "head_box", "face_box", "lmk", "pose", "kps"],
        config_file="configs/method_configs/multitask_config.json")
    face_bbox_list, face_disappeared_track_id_list = mot(
        face_box, outputs=["face_bbox_list", "face_disappeared_track_id_list"])
    head_bbox_list, head_disappeared_track_id_list = mot(
        head_box,
        inputs=["head_box"],
        outputs=["head_bbox_list", "head_disappeared_track_id_list"])
    body_bbox_list, body_disappeared_track_id_list = mot(
        body_box,