2017-03-08 44 views
0

大家,當我測試在Windows ssd_pascal_video.py,我得到了以下錯誤:窗戶SSD朱古力

E:\caffe-ssd-microsoft\Build\x64\Release\pycaffe>python E:\caffe-ssd-microsoft\examples\ssd\ssd_pascal_webcam.py --cpu 
    Traceback (most recent call last): 
    File "E:\caffe-ssd-microsoft\examples\ssd\ssd_pascal_webcam.py", line 151, in <module> 
    for file in os.listdir(snapshot_dir): 
    WindowsError: [Error 3] : 'models/VGGNet/VOC0712/SSD_300x300/*.*' 

然後,我檢查ssd_pascal_video.py,我發現下面的代碼,我不明白其中的含義地址中的「{}」。

# The job name should be same as the name used in examples/ssd/ssd_pascal.py. 
    job_name = "SSD_{}".format(resize) 
    # The name of the model. Modify it if you want. 
    model_name = "VGG_VOC0712_{}".format(job_name) 

    # Directory which stores the model .prototxt file. 
    save_dir = "models/VGGNet/VOC0712/{}_video".format(job_name) 
    # Directory which stores the snapshot of trained models. 
    snapshot_dir = "models/VGGNet/VOC0712/{}".format(job_name) 
    # Directory which stores the job script and log file. 
    job_dir = "jobs/VGGNet/VOC0712/{}_video".format(job_name) 

    # model definition files. 
    test_net_file = "{}/test.prototxt".format(save_dir) 
    # snapshot prefix. 
    snapshot_prefix = "{}/{}".format(snapshot_dir, model_name) 
    # job script path. 
    job_file = "{}/{}.sh".format(job_dir, model_name) 

    # Find most recent snapshot. 
    max_iter = 0 
    for file in os.listdir(snapshot_dir): 
    if file.endswith(".caffemodel"): 
    basename = os.path.splitext(file)[0] 
    iter = int(basename.split("{}_iter_".format(model_name))[1]) 
    if iter > max_iter: 
    max_iter = iter 

回答

0

字符串中的'{}' Python中的.format()操作的一部分。
基本上,每個{}在字符串中被替換爲.format()中的對應值。

+0

你好,Sha!爲什麼它沒有提供完整的地址?我該如何解決這個問題?我是否使用虛假地址? –

+0

@ H.Hao您是否下載過預先訓練好的模型?是否存在''models/VGGNet/VOC0712/SSD_300x300'文件夾(請注意,這是您當前工作目錄的**相對**路徑)? – Shai

+0

我下載了型號,我的地址是型號/ VGGNet/VOC0712/SSD_300×300.但是在ssd_pascal_video.py中我找不到SSD_300×300應該在哪個文件中找到,我剛剛看了官方介紹找到我的地址中的文件。 –

相關問題