git clone https: // github. com/ PaddlePaddle/ PaddleSeg. git
cd PaddleSeg
import sys
sys. path. append( '/home/aistudio/work/PaddleSeg' )
import os
folder_path = "/home/aistudio/work/PaddleSeg/configs"
yml_files = { }
for root, dirs, files in os. walk( folder_path) : for file in files: if file . lower( ) . endswith( ".yml" ) : file_path = os. path. join( root, file ) file_name_without_extension = os. path. splitext( file ) [ 0 ] yml_files[ file_name_without_extension] = file_path print ( file_path)
file_to_read = "/home/aistudio/work/PaddleSeg/voc/pascal_voc12_urls_extracted.txt"
url_lines = { }
if os. path. exists( file_to_read) : with open ( file_to_read, 'r' ) as f: lines = f. readlines( ) for line in lines: url = line. strip( ) parsed_name = url. split( "/" ) [ - 2 ] url_lines[ parsed_name] = url print ( url)
else : print ( f"File not found: { file_to_read} " )
base_command = "python tools/predict.py --config {} --model_path {} --image_path /home/aistudio/data/data117064/voctestimg --save_dir {}"
for model_name, model_path in url_lines. items( ) : if model_name in yml_files: config_file = yml_files[ model_name] save_dir = f"output/ { model_name} " os. makedirs( save_dir, exist_ok= True ) command = base_command. format ( config_file, model_path, save_dir) print ( f"Executing: { command} " ) os. system( command) else : print ( f"No matching config file found for model: { model_name} " )