當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。