Closed LCorleone closed 5 years ago
I solved it. It can load two models at the same time. However, here the global CLASS_INDEX will overwrite two different class names and should be modified.
def decode_predictions(preds, top=5, model_json=""):
global CLASS_INDEX
if CLASS_INDEX is None:
CLASS_INDEX = json.load(open(model_json))
results = []
for pred in preds:
top_indices = pred.argsort()[-top:][::-1]
for i in top_indices:
each_result = []
each_result.append(CLASS_INDEX[str(i)])
each_result.append(pred[i])
results.append(each_result)
return results
@LCorleone Thank you for working on this. It is very useful to have 2 or more custom models active. I will adopt your modifications in the next version of ImageAI.
@LCorleone Can you share what you did to make it work as a workaround?
Hello, has it been changed in the code yet?
I think a quick workaround would be: (however the model would be loaded each time)
`def decode_predictions(preds, top=5, model_json=""):
shittyVariable = json.load(open(model_json))
results = []
for pred in preds:
top_indices = pred.argsort()[-top:][::-1]
for i in top_indices:
each_result = []
each_result.append(shittyVariable [str(i)])
each_result.append(pred[i])
results.append(each_result)
return results`
But the main question is why is this method not directly in the CustomImagePrediction class???
hi, first excellent job you did. I trained two different prediction model, and i want to load them at the same time.
But i found that it seems to fail as it can only load one?