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

Kludge to fix tf.shape for shadow model #128 #129

Merged
merged 1 commit into from
Dec 4, 2024
Merged
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
4 changes: 2 additions & 2 deletions src/class_portstarObj.py
Original file line number Diff line number Diff line change
Expand Up @@ -1824,8 +1824,8 @@ def _detectShadow(self, remShadow, i, USE_GPU, doPlot=True, tileFile='.jpg'):
###############
# Do prediction

port_label, port_prob = doPredict(model, MODEL, self.port.sonDat, N_DATA_BANDS, NCLASSES, TARGET_SIZE, OTSU_THRESHOLD)
star_label, star_prob = doPredict(model, MODEL, self.star.sonDat, N_DATA_BANDS, NCLASSES, TARGET_SIZE, OTSU_THRESHOLD)
port_label, port_prob = doPredict(model, MODEL, self.port.sonDat, N_DATA_BANDS, NCLASSES, TARGET_SIZE, OTSU_THRESHOLD, shadow=True)
star_label, star_prob = doPredict(model, MODEL, self.star.sonDat, N_DATA_BANDS, NCLASSES, TARGET_SIZE, OTSU_THRESHOLD, shadow=True)

# Set shadow to 0, else 1
port_label = np.where(port_label==0,1,0)
Expand Down
7 changes: 6 additions & 1 deletion src/funcs_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def initModel(weights, configfile, USE_GPU=False):
################################################

#=======================================================================
def doPredict(model, MODEL, arr, N_DATA_BANDS, NCLASSES, TARGET_SIZE, OTSU_THRESHOLD):
def doPredict(model, MODEL, arr, N_DATA_BANDS, NCLASSES, TARGET_SIZE, OTSU_THRESHOLD, shadow=False):

'''
'''
Expand All @@ -152,6 +152,11 @@ def doPredict(model, MODEL, arr, N_DATA_BANDS, NCLASSES, TARGET_SIZE, OTSU_THRES

image = standardize(image.numpy()).squeeze()

# Kludge to fix error noted in Issue #128
if shadow:
image = image[:,:,0]
image = tf.expand_dims(image, 2)

if NCLASSES == 2:

E0, E1 = est_label_binary(image, model, MODEL, False, NCLASSES, TARGET_SIZE, w, h)
Expand Down
Loading