I have a lot of files, which are a result of machine learning with YOLO model, generated by Tensorflow.
Each filename is named:
detection_model-ex-013--loss-0016.228.h5
With the only differences, being:
013 - epoch/generationNumber
0016 - loss (kind of accuracy, but from training PoV)
228 - additional precision of loss (I think, but I'm not sure yet, so I consider it as separate for now)
It would be pretty simple, but it's a combination of dashes, underscores and dots, given that I'm pretty new to python and what it's capable of, I couldn't find any solution that would fit this filename and I'm having difficulties writing a regexp for this.
For now my python "logic" selects the model solely based on which file was the last one saved, which is a start, but it's far from ideal.
def findBestModel(): # "best" model is currently just the last model in directory
last_model = max(glob.glob('data/models/*.h5'), key=os.path.getmtime)
print('Selected model: ' + last_model)
return last_model
What would be the right way to actually make findBestModel() return those 3 variables that I need, from each filename, without making it overcomplicated?