TianzhongSong / Person-Segmentation-Keras

Person segmentation with Keras (SegNet, Unet, etc.)
Apache License 2.0
160 stars 34 forks source link

Stop at epoch (1/50) #6

Open 03053020ITE opened 5 years ago

03053020ITE commented 5 years ago

@TianzhongSong 你好,请教一下一个问题 首先我已经照着list格式放置好了dataset和label,为何我下了指令python train_segmentation.py --model='unet' 停止在epoch(1/50) 再麻烦您回复了 万分感谢

jhfmat commented 5 years ago

有解决了吗

simon-rob commented 5 years ago

I seems to be related to this known issue:

https://stackoverflow.com/questions/48709839/stopiteration-generator-output-nextoutput-generator?noredirect=1&lq=1

I changed the generator function in the utils directory to:

def generator(root_path, path_file, batch_size, n_classes, input_height, input_width, train=True): f = open(path_file, 'r') items = f.readlines() f.close() while True: # <== Move forever loop if train: shuffled_items = [] index = [n for n in range(len(items))] random.shuffle(index) for i in range(len(items)): shuffled_items.append(items[index[i]]) for j in range(len(items) // batch_size): x, y = get_batch(shuffled_items[j batch_size:(j + 1) batch_size], root_path, n_classes, input_height, input_width) yield np.array(x), np.array(y) else: for j in range(len(items) // batch_size): x, y = get_batch(items[j batch_size:(j + 1) batch_size], root_path, n_classes, input_height, input_width) yield np.array(x), np.array(y)

And it allowed my to train ok.

Pythonlushun commented 5 years ago

您好,你现在运行好了吗,我想和您交流一下,我现在也出现了类似的问题