Skip to content

Commit

Permalink
minor bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
QuickLearner171998 committed Apr 11, 2020
1 parent 273c7f2 commit 20759ce
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@

# make sure the file is inside semi-auto-image-annotation-tool-master
import pathlib
cur_path = pathlib.Path(__file__).parent.absolute()
# cur_path = pathlib.Path(__file__).parent.absolute()
cur_path = pathlib.Path(__file__).parent.absolute().as_posix()
print(cur_path)
# cur_path = r"semi-auto-image-annotation-tool-master"
sys.path.append(cur_path)
os.chdir(cur_path)
Expand All @@ -34,8 +36,8 @@ class MainGUI:
def __init__(self, master):

# to choose between keras or tensorflow models
self.kera = 1 # default
self.tensorf = 0
self.keras_ = 1 # default
self.tensorflow_ = 0
self.models_dir = '' # gets updated as per user choice
self.model_path = ''
self.parent = master
Expand Down Expand Up @@ -175,7 +177,7 @@ def __init__(self, master):

self.labelListBox = Listbox(self.listPanel)
self.labelListBox.pack(fill=X, side=TOP)
if self.kera:
if self.keras_:
self.cocoLabels = config.labels_to_names.values()
else:
self.cocoLabels = tf_config.labels_to_names.values()
Expand Down Expand Up @@ -207,7 +209,7 @@ def get_session(self):
def available_models(self):
self.models_dir = os.path.join(cur_path, 'snapshots')
# only for keras and tf
model_categ = os.listdir(self.models_dir)
model_categ = [dir_ for dir_ in os.listdir(self.models_dir) if os.path.isdir(os.path.join(self.models_dir, dir_))]
# creating all model options list
model_names = []
for categ in model_categ:
Expand Down Expand Up @@ -499,12 +501,12 @@ def add_model(self):
self.model_path = os.path.join(self.models_dir,list_model_name)
# if its Tensorflow model then modify path
if('keras' in list_model_name):
self.kera = 1
self.tensorf = 0
self.keras_ = 1
self.tensorflow_ = 0
elif('tensorflow' in list_model_name):
self.model_path = os.path.join(self.model_path,'frozen_inference_graph.pb')
self.kera = 0
self.tensorf = 1
self.keras_ = 0
self.tensorflow_ = 1
# change cocoLabels corresponding to tensorflow
self.cocoLabels = tf_config.labels_to_names.values()
break
Expand Down Expand Up @@ -533,7 +535,7 @@ def automate(self):
# Convert RGB to BGR
opencvImage = open_cv_image[:, :, ::-1].copy()
# if tensorflow
if self.tensorf :
if self.tensorflow_ :
detection_graph = tf.Graph()
with detection_graph.as_default():
od_graph_def = tf.GraphDef()
Expand Down Expand Up @@ -576,7 +578,7 @@ def automate(self):

b = box
# only if using tf models as keras and tensorflow have different coordinate order
if(self.tensorf):
if(self.tensorflow_):
w, h = self.img.size
(b[0],b[1],b[2],b[3]) = (b[1]*w, b[0]*h, b[3]*w, b[2]*h)
b = b.astype(int)
Expand Down

0 comments on commit 20759ce

Please sign in to comment.