fix: UnboundLocalError em shutil durante o treino
_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.
This commit is contained in:
@@ -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')]
|
imagens = [f for f in os.listdir(img_dir) if not f.endswith('.txt')]
|
||||||
if len(imagens) > 0:
|
if len(imagens) > 0:
|
||||||
import random, shutil
|
import random
|
||||||
random.shuffle(imagens)
|
random.shuffle(imagens)
|
||||||
corte = max(1, int(len(imagens) * 0.8))
|
corte = max(1, int(len(imagens) * 0.8))
|
||||||
val_imgs = imagens[corte:]
|
val_imgs = imagens[corte:]
|
||||||
|
|||||||
Reference in New Issue
Block a user