Commit c2033cd1 authored by Gilberto Astolfi's avatar Gilberto Astolfi
Browse files

corrigindo erro em notbook

parent cd9a279a
......@@ -93,14 +93,14 @@
},
"source": [
"tipo_amostragem = 'cross' # repetition ou cross\n",
"percentual_aumento_dados = .1 # de .1 a 1\n",
"percentual_aumento_dados = 0 # de .1 a 1\n",
"# se tipo_amostragem = 'cross', então deve ser 5 ou 10.\n",
"# se tipo_amostragem = 'repetition', normalmente usa-se 30, 25, .., 10, 5 images para treinamento. O conjunto de teste é fixado em 70 imagens\n",
"number_fold_or_image_train = 5 \n",
"tem_validacao = True \n",
"tem_oversampling = True\n",
"\n",
"dataset_name = 'annotated_pests_v3'\n",
"dataset_name = 'annotated_pests_v3' #.zip\n",
"path_dataset='/content/gdrive/MyDrive/datasets' # pasta existente no Drive\n"
],
"execution_count": null,
......@@ -122,7 +122,7 @@
},
"source": [
"%cd /content\n",
"!git clone http://git.inovisao.ucdb.br/inovisao/crossvalidation-repetition-object-detection.git"
"!git clone http://git.inovisao.ucdb.br/inovisao/crossvalidation-repetition-object-detection.git\n"
],
"execution_count": null,
"outputs": []
......@@ -170,7 +170,7 @@
"parametros = '/content/' + dataset_name + ' /content/' + tipo_amostragem + ' ' + tipo_amostragem + ' ' + str(number_fold_or_image_train) + ' ' + str(tem_validacao) + ' ' + str(percentual_aumento_dados) + ' ' + str(tem_oversampling)\n",
"comando = script + ' ' + parametros\n",
"\n",
"%cd /content/crossvalidation-repetition\n",
"%cd /content/crossvalidation-repetition-object-detection\n",
"!python3 $comando\n"
],
"execution_count": null,
......@@ -197,12 +197,9 @@
"\n",
"%cd /content/models/research\n",
"!protoc object_detection/protos/*.proto --python_out=.\n",
"!cp object_detection/packages/tf1/setup.py .\n",
"#!cp object_detection/packages/tf2/setup.py .\n",
"!python -m pip install .\n",
"\n",
"#!python setup.py build\n",
"#!python setup.py install"
"#!cp object_detection/packages/tf1/setup.py .\n",
"!cp object_detection/packages/tf2/setup.py .\n",
"!python -m pip install .\n"
],
"execution_count": null,
"outputs": []
......@@ -251,8 +248,7 @@
"path_tfrecords = '/content/tfrecord'\n",
"parametros = '/content/' + tipo_amostragem + ' ' + path_tfrecords + ' ' + '/content/detection_util_scripts'\n",
"comando = script + ' ' + parametros\n",
"\n",
"%cd /content/crossvalidation-repetition\n",
"%cd /content/crossvalidation-repetition-object-detection\n",
"!python3 $comando\n"
],
"execution_count": null,
......@@ -266,7 +262,7 @@
"source": [
"## Enviando as amostras para o Google Drive.\n",
"\n",
"As amostras são enviadas para a pasta informada na variável **dataset_name** do diretório informado na variável **path_dataset** no Google Drive. Neste exemplo: /content/gdrive/MyDrive/datasets/annotated_pests_v3"
"As amostras são enviadas para a pasta informada na variável **dataset_name** do diretório informado na variável **path_dataset** no Google Drive. "
]
},
{
......@@ -275,37 +271,27 @@
"id": "lK1a1DazP1FV"
},
"source": [
"import os\n",
"from shutil import copyfile, make_archive\n",
" \n",
"def transfere_files(fold_src_set, fold_dst_set):\n",
" for f in os.listdir(fold_src_set):\n",
" name, extension = os.path.splitext(f)\n",
" if extension.lower() == '.pbtxt'.lower():\n",
" file_src = fold_src_set + '/' + f\n",
" file_dst = fold_dst_set + '/' + f\n",
" copyfile(file_src, file_dst)\n",
" if extension.lower() == '.tfrecord'.lower():\n",
" file_src = fold_src_set + '/' + f\n",
" file_dst = fold_dst_set + '/' + f\n",
" copyfile(file_src, file_dst)\n",
"from files_utils import FileUtils\n",
"from yolo_utils import YoloUtils\n",
"\n",
"file_util = FileUtils()\n",
"\n",
"#tranfere os arquivos .tfrecord e .pbtxt para a pasta do repositório\n",
"repositorio = '/content/' + tipo_amostragem\n",
"file_util.transfereFilesTfrecord(path_tfrecords, repositorio)\n",
"\n",
"yo_utils = YoloUtils()\n",
"#quando rodar a yolo, os pesos serão salvos nesta pasta no drive. Configura o arquivo obj.data da yolo.\n",
"backup_weight_yolo = path_dataset+'/'+dataset_name\n",
"yo_utils.createFilesYolo(repositorio, backup_weight_yolo)\n",
"\n",
"path_douglasrizzo = '/content/detection_util_scripts'\n",
"\n",
"#path_tfrecords = '/content/tfrecord'\n",
"for fold in os.listdir(path_tfrecords):\n",
" fold_src = path_tfrecords + '/' + fold #origem\n",
" fold_dst = repositorio + '/' + fold #destino\n",
" for set_ in os.listdir(fold_src):\n",
" fold_src_set = fold_src + '/' + set_ #origem\n",
" fold_dst_set = fold_dst + '/' + set_ #destino\n",
" if set_ != 'test':\n",
" transfere_files(fold_src_set, fold_dst_set)\n",
"yo_utils.createAnnotationYolo(path_douglasrizzo, repositorio, path_tfrecords)\n",
"\n",
"#eviando as amostras para o Drive\n",
"sample_name_zip = path_dataset + '/' + dataset_name + '/' + tipo_amostragem\n",
"origem = '/content/' + tipo_amostragem\n",
"make_archive(sample_name_zip, 'zip', origem)"
"#tranfere as amostras para a pasta do Drive\n",
"path_dst = path_dataset + '/' + dataset_name\n",
"file_util.transfereFilesDrive(repositorio, path_dst, tipo_amostragem)\n"
],
"execution_count": null,
"outputs": []
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment