From 25ce7fd39f88a93ddfdc9316ef4dea8a79e5d1bc Mon Sep 17 00:00:00 2001 From: tkinaba Date: Tue, 4 Aug 2026 10:59:58 -0300 Subject: [PATCH] fix: UnboundLocalError em shutil durante o treino MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _executar_treino_sync tinha um `import random, shutil` local depois de já usar shutil.rmtree() mais cedo na mesma função — o import local faz o Python tratar 'shutil' como variável local pra toda a função, então o uso anterior lançava "local variable 'shutil' referenced before assignment" antes mesmo de chegar no split de treino/validação. shutil já vem importado no escopo do módulo; só falta random no import local. --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index cf45999..66613f8 100644 --- a/main.py +++ b/main.py @@ -166,7 +166,7 @@ def _executar_treino_sync(ambiente: str, pular_triagem: bool, forcar_do_zero: bo imagens = [f for f in os.listdir(img_dir) if not f.endswith('.txt')] if len(imagens) > 0: - import random, shutil + import random random.shuffle(imagens) corte = max(1, int(len(imagens) * 0.8)) val_imgs = imagens[corte:]