当前位置: 首页>>代码示例>>Python>>正文


Python build.TFNet方法代码示例

本文整理汇总了Python中darkflow.net.build.TFNet方法的典型用法代码示例。如果您正苦于以下问题:Python build.TFNet方法的具体用法?Python build.TFNet怎么用?Python build.TFNet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在darkflow.net.build的用法示例。


在下文中一共展示了build.TFNet方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from darkflow.net import build [as 别名]
# 或者: from darkflow.net.build import TFNet [as 别名]
def __init__(self, env_spec, policy, options=None, darkflow_path=None, im_is_rgb=False, **kwargs):
        super(FoodLabeller, self).__init__(env_spec, policy)

        if options is None:
            options = {"model": "cfg/yolo.cfg", "load": "bin/yolov2.weights", "threshold": 1.e-2, "gpu": True}
        if darkflow_path is None:
            darkflow_path = os.path.join(str(Path.home()), 'darkflow')
        old_cwd = os.getcwd()
        os.chdir(darkflow_path)
        self._tfnet = TFNet(options)
        os.chdir(old_cwd)
        self._labels = []
        for key in self._env_spec.goal_spec:
            if key[-5:] == '_diff':
                self._labels.append(key[:-5])
        self._im_is_rgb = im_is_rgb 
开发者ID:gkahn13,项目名称:GtS,代码行数:18,代码来源:food_labeller.py

示例2: __init__

# 需要导入模块: from darkflow.net import build [as 别名]
# 或者: from darkflow.net.build import TFNet [as 别名]
def __init__(self,video=False):
        self.config = json.load(open('../config3.json'))
        self.video=video
        print(self.config)
        self.options = self.config['yoloConfig']
        self.tfnet = TFNet(self.options)
        self.predictThresh = 0.4
        self.getAnnotations()
        if self.video:
            self.cap = cv2.VideoCapture(0) 
开发者ID:AmeyaWagh,项目名称:Traffic_sign_detection_YOLO,代码行数:12,代码来源:objectDetectorYOLO.py

示例3: test_RETURNPREDICT_PBLOAD_YOLOv2

# 需要导入模块: from darkflow.net import build [as 别名]
# 或者: from darkflow.net.build import TFNet [as 别名]
def test_RETURNPREDICT_PBLOAD_YOLOv2():
    #Test the .pb and .meta files generated in the previous step
    #NOTE: This test verifies that the code executes properly, and the .pb and .meta files that were created are able to be loaded and used for inference.
    #      The predictions that are generated will be compared against expected predictions.

    options = {"pbLoad": pbPath, "metaLoad": metaPath, "threshold": 0.4}
    tfnet = TFNet(options)
    imgcv = cv2.imread(testImg["path"])
    loadedPredictions = tfnet.return_predict(imgcv)

    assert compareObjectData(testImg["expected-objects"]["yolo"], loadedPredictions, testImg["width"], testImg["height"], threshCompareThreshold, posCompareThreshold), "Generated object predictions from return_predict() were not within margin of error compared to expected values."

#TESTS FOR TRAINING 
开发者ID:AmeyaWagh,项目名称:Traffic_sign_detection_YOLO,代码行数:15,代码来源:test_darkflow.py

示例4: test_TRAIN_FROM_WEIGHTS_CLI__LOAD_CHECKPOINT_RETURNPREDICT_YOLOv2

# 需要导入模块: from darkflow.net import build [as 别名]
# 或者: from darkflow.net.build import TFNet [as 别名]
def test_TRAIN_FROM_WEIGHTS_CLI__LOAD_CHECKPOINT_RETURNPREDICT_YOLOv2():
    #Test training using pre-generated weights for tiny-yolo-voc
    #NOTE: This test verifies that the code executes properly, and that the expected checkpoint file (tiny-yolo-voc-20.meta in this case) is generated.
    #      In addition, predictions are generated using the checkpoint file to verify that training completed successfully.

    testString = "flow --model {0} --load {1} --train --dataset {2} --annotation {3} --epoch 20".format(tiny_yolo_voc_CfgPath, tiny_yolo_voc_WeightPath, os.path.join(buildPath, "test", "training", "images"), os.path.join(buildPath, "test", "training", "annotations"))
    with pytest.raises(SystemExit):
        executeCLI(testString)

    checkpointPath = os.path.join(buildPath, "ckpt", "tiny-yolo-voc-20.meta")
    assert os.path.exists(checkpointPath), "Expected output checkpoint file: {0} was not found.".format(checkpointPath)

    #Using trained weights
    options = {"model": tiny_yolo_voc_CfgPath, "load": 20, "config": generalConfigPath, "threshold": 0.1}
    tfnet = TFNet(options)

    #Make sure predictions very roughly match the expected values for image with bike and person
    imgcv = cv2.imread(trainImgBikePerson["path"])
    loadedPredictions = tfnet.return_predict(imgcv)
    assert compareObjectData(trainImgBikePerson["expected-objects"]["tiny-yolo-voc"], loadedPredictions, trainImgBikePerson["width"], trainImgBikePerson["height"], 0.7, 0.25), "Generated object predictions from training (for image with person on the bike) were not anywhere close to what they are expected to be.\nTraining may not have completed successfully."
    differentThanExpectedBike = compareObjectData(trainImgBikePerson["expected-objects"]["tiny-yolo-voc"], loadedPredictions, trainImgBikePerson["width"], trainImgBikePerson["height"], 0.01, 0.001)

    #Make sure predictions very roughly match the expected values for image with horse and person
    imgcv = cv2.imread(trainImgHorsePerson["path"])
    loadedPredictions = tfnet.return_predict(imgcv)
    assert compareObjectData(trainImgHorsePerson["expected-objects"]["tiny-yolo-voc"], loadedPredictions, trainImgHorsePerson["width"], trainImgHorsePerson["height"], 0.7, 0.25), "Generated object predictions from training (for image with person on the horse) were not anywhere close to what they are expected to be.\nTraining may not have completed successfully."
    differentThanExpectedHorse = compareObjectData(trainImgHorsePerson["expected-objects"]["tiny-yolo-voc"], loadedPredictions, trainImgHorsePerson["width"], trainImgHorsePerson["height"], 0.01, 0.001)

    assert not (differentThanExpectedBike and differentThanExpectedHorse), "The generated object predictions for both images appear to be exactly the same as the ones generated with the original weights.\nTraining may not have completed successfully.\n\nNOTE: It is possible this is a fluke error and training did complete properly (try running this build again to confirm) - but most likely something is wrong." 
开发者ID:AmeyaWagh,项目名称:Traffic_sign_detection_YOLO,代码行数:31,代码来源:test_darkflow.py

示例5: __init__

# 需要导入模块: from darkflow.net import build [as 别名]
# 或者: from darkflow.net.build import TFNet [as 别名]
def __init__(self,video=False):
        self.config = json.load(open('../config3.json'))
        self.video=video
        print(self.config)
        self.options = self.config['yoloConfig']
        self.tfnet = TFNet(self.options)
        self.predictThresh = 0.05
        self.getAnnotations()
        print(self.anotations_list)
        if self.video:
            # self.cap = cv2.VideoCapture(0)
            self.cap = cv2.VideoCapture('../../WPI_vdo.mov')
            self.out = cv2.VideoWriter('output.avi',-1, 20.0, (640,480)) 
开发者ID:AmeyaWagh,项目名称:Traffic_sign_detection_YOLO,代码行数:15,代码来源:YOLOtest.py

示例6: create

# 需要导入模块: from darkflow.net import build [as 别名]
# 或者: from darkflow.net.build import TFNet [as 别名]
def create(self):
        self.tfnet = TFNet(self.engine_options) 
开发者ID:DT42,项目名称:BerryNet,代码行数:4,代码来源:darkflow_engine.py

示例7: main

# 需要导入模块: from darkflow.net import build [as 别名]
# 或者: from darkflow.net.build import TFNet [as 别名]
def main():
    options = {
        "model": "cfg/tiny-yolo.cfg",
        "load": "bin/tiny-yolo.weights",
        'verbalise': True,
        #"threshold": 0.1
    }
    tfnet = TFNet(options)
    _logging('model dir: {}'.format(options['load']))
    _logging('config dir: {}'.format(options['model']))

    server(tfnet) 
开发者ID:DT42,项目名称:BerryNet,代码行数:14,代码来源:detection_server.py

示例8: run_va_over_video_folder

# 需要导入模块: from darkflow.net import build [as 别名]
# 或者: from darkflow.net.build import TFNet [as 别名]
def run_va_over_video_folder():

    # Create a single darkflow object to be reused by each video analyzer.
    start_total_time = time.time()
    tfnet = TFNet(TFNET_OPTIONS)
    video_info_list = list()

    # Perform video analysis over all the videos in the video directory.
    for file_name in os.listdir('videos'):

        # Skip the files that do not contain a .mp4 extension.
        if "mp4" not in file_name:
            continue
        video_location = "{:s}/{:s}".format('videos', file_name)
        va = video_analysis.VideoAnalyzer(video_location,
            tfnet, args.show_flag)
        video_info_list.append(va.standard_test())

    # Calculate the overall video statistics
    print("====TOTAL STATS====")
    match_times, match_labels, match_ports = list(), list(), list()
    for video_info in video_info_list:
        match_times.extend(video_info['match_times'])
        match_labels.extend(video_info['match_labels'])
        match_ports.extend([j for i in video_info['match_ports'] for j in i])

    # Calculate time statistics.
    avg_time = sum(match_times)//len(match_times)
    print("Average match time {:}:{:02d}".format(avg_time//60, avg_time%60))

    # Calculate stage statistics.
    label_list = ["battlefield", "dreamland", "finaldest",
        "fountain", "pokemon", "yoshis"]
    for label in label_list:
        label_percentage = 100*match_labels.count(label)/len(match_labels)
        print("Stage {:}: {:.2f}%".format(label, label_percentage))

    # Calculate port number statistics.
    for i in [1, 2, 3, 4]:
        port_percentage = 100*match_ports.count(i)/len(match_ports)
        print("Port {:}: {:.2f}%".format(i, port_percentage))

    util.display_total_time(start_total_time, "Analyze") 
开发者ID:jpnaterer,项目名称:smashscan,代码行数:45,代码来源:test.py


注:本文中的darkflow.net.build.TFNet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。