williamfzc / stagesepx

detect stages in video automatically
MIT License
434 stars 125 forks source link

分类的类型超过6个遇到assert异常 #170

Closed mayan90 closed 2 years ago

mayan90 commented 2 years ago

2022-03-09 14:46:07.978 | DEBUG | stagesepx.classifier.base:init:346 - no compress rate or target size received. set compress rate to 0.2 2022-03-09 14:46:07.978 | DEBUG | stagesepx.classifier.base:init:353 - compress rate: 0.2 2022-03-09 14:46:07.978 | DEBUG | stagesepx.classifier.base:init:354 - target size: None 2022-03-09 14:46:07.979 | DEBUG | stagesepx.hook:init:13 - start initialing: CompressHook ... 2022-03-09 14:46:07.979 | DEBUG | stagesepx.hook:init:80 - compress rate: 0.2 2022-03-09 14:46:07.979 | DEBUG | stagesepx.hook:init:81 - target size: None 2022-03-09 14:46:07.979 | DEBUG | stagesepx.hook:init:13 - start initialing: GreyHook ... 2022-03-09 14:46:07.979 | DEBUG | stagesepx.classifier.base:add_hook:375 - add hook: CompressHook 2022-03-09 14:46:07.979 | DEBUG | stagesepx.classifier.base:add_hook:375 - add hook: GreyHook 2022-03-09 14:46:07.979 | DEBUG | stagesepx.classifier.keras:init:50 - score threshold: 0.0 2022-03-09 14:46:07.979 | DEBUG | stagesepx.classifier.keras:init:51 - data size: (200, 200) 2022-03-09 14:46:07.979 | DEBUG | stagesepx.classifier.keras:init:52 - nb train samples: 64 2022-03-09 14:46:07.979 | DEBUG | stagesepx.classifier.keras:init:53 - nb validation samples: 64 2022-03-09 14:46:07.979 | DEBUG | stagesepx.classifier.keras:init:54 - epochs: 10 2022-03-09 14:46:07.979 | DEBUG | stagesepx.classifier.keras:init:55 - batch size: 4 Traceback (most recent call last): File "工作记录/KbPerformanceTest/testa.py", line 10, in cl.train('Desktop/monkey/table_frame') File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/stagesepx/classifier/keras.py", line 157, in train _data_verify(data_path) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/stagesepx/classifier/keras.py", line 152, in _data_verify assert number_of_dir <= 6, ( AssertionError: dataset has 12 classes (more than 6), please see https://github.com/williamfzc/stagesepx/issues/112

Process finished with exit code 1

williamfzc commented 2 years ago

强烈建议还是不要超出6个类型,我觉得场景过度复杂化了,几乎所有场景都可以在6个类内完成,大部分的类都可以合并。

如果一定要用那么多类型:

mayan90 commented 2 years ago

嗨改为12了 还是报错的。还有哪里需要修改

williamfzc commented 2 years ago

嗨改为12了 还是报错的。还有哪里需要修改

mayan90 commented 2 years ago

/usr/local/bin/python3.9 //Desktop/工作记录/KbPerformanceTest/testa.py 2022-03-09 15:25:00.140 | DEBUG | stagesepx.classifier.base:init:346 - no compress rate or target size received. set compress rate to 0.2 2022-03-09 15:25:00.140 | DEBUG | stagesepx.classifier.base:init:353 - compress rate: 0.2 2022-03-09 15:25:00.141 | DEBUG | stagesepx.classifier.base:init:354 - target size: None 2022-03-09 15:25:00.141 | DEBUG | stagesepx.hook:init:13 - start initialing: CompressHook ... 2022-03-09 15:25:00.141 | DEBUG | stagesepx.hook:init:80 - compress rate: 0.2 2022-03-09 15:25:00.141 | DEBUG | stagesepx.hook:init:81 - target size: None 2022-03-09 15:25:00.141 | DEBUG | stagesepx.hook:init:13 - start initialing: GreyHook ... 2022-03-09 15:25:00.141 | DEBUG | stagesepx.classifier.base:add_hook:375 - add hook: CompressHook 2022-03-09 15:25:00.141 | DEBUG | stagesepx.classifier.base:add_hook:375 - add hook: GreyHook 2022-03-09 15:25:00.141 | DEBUG | stagesepx.classifier.keras:init:50 - score threshold: 0.0 2022-03-09 15:25:00.141 | DEBUG | stagesepx.classifier.keras:init:51 - data size: (200, 200) 2022-03-09 15:25:00.142 | DEBUG | stagesepx.classifier.keras:init:52 - nb train samples: 64 2022-03-09 15:25:00.142 | DEBUG | stagesepx.classifier.keras:init:53 - nb validation samples: 64 2022-03-09 15:25:00.142 | DEBUG | stagesepx.classifier.keras:init:54 - epochs: 10 2022-03-09 15:25:00.142 | DEBUG | stagesepx.classifier.keras:init:55 - batch size: 4 Traceback (most recent call last): File "Desktop/工作记录/KbPerformanceTest/testa.py", line 10, in cl.train('Desktop/monkey/table_frame') File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/stagesepx/classifier/keras.py", line 157, in train _data_verify(data_path) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/stagesepx/classifier/keras.py", line 152, in _data_verify assert number_of_dir <= 6, ( AssertionError: dataset has 12 classes (more than 6), please see https://github.com/williamfzc/stagesepx/issues/112

mayan90 commented 2 years ago

生成的就是12个切割区间,不是6 也没有报错。

williamfzc commented 2 years ago

如果不是持久性的模型可以不用Keras,用默认的svm就可以了 可以贴下脚本

mayan90 commented 2 years ago

训练模型文件

cl = KerasClassifier(

训练轮数

epochs=10 ) cl.train('/Users/xm210407/Desktop/monkey/table_frame') cl.save_model('/Users/xm210407/Desktop/monkey/table_model/model.h5', overwrite=True) 就是参考模型直接使用的

williamfzc commented 2 years ago

https://blog.csdn.net/wsc106/article/details/107351675 参考下能不能压缩类型,12个肯定是过多的也不必要的,看你的场景只需要5个。