Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove useless global variable in custom_utils #454

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions imageai/Prediction/Custom/custom_utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import json

CLASS_INDEX = None



def preprocess_input(x):
"""Preprocesses a tensor encoding a batch of images.
Expand All @@ -24,11 +21,8 @@ def preprocess_input(x):

def decode_predictions(preds, top=5, model_json=""):


global CLASS_INDEX

if CLASS_INDEX is None:
CLASS_INDEX = json.load(open(model_json))
with open(model_json) as f:
CLASS_INDEX = json.load(f)
results = []
for pred in preds:
top_indices = pred.argsort()[-top:][::-1]
Expand All @@ -38,4 +32,4 @@ def decode_predictions(preds, top=5, model_json=""):
each_result.append(pred[i])
results.append(each_result)

return results
return results
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
tensorflow
keras
numpy
pillow
pillow<7.0.0
scipy
h5py
matplotlib
Expand Down