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

Fix broken image scoring #328

Open
wants to merge 1 commit 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
4 changes: 2 additions & 2 deletions cpa/classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -1671,12 +1671,12 @@ def ClassifyImage(self, imKey):
for className, obKeys in classHits.items():
training_keys = [key for key in obKeys if key in training_obKeys]
if training_keys:
trainingCoords['training ' + className] = db.GetObjectsCoords(training_keys)[0:2]
trainingCoords['training ' + className] = db.GetObjectsCoords(training_keys)
else:
trainingCoords['training ' + className] = []
object_keys = [key for key in obKeys if key not in training_obKeys]
if object_keys:
classCoords[className] = db.GetObjectsCoords(object_keys)[0:2]
classCoords[className] = db.GetObjectsCoords(object_keys)
else:
classCoords[className] = []
classCoords.update(trainingCoords)
Expand Down
18 changes: 4 additions & 14 deletions cpa/dbconnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,20 +707,10 @@ def GetObjectCoords(self, obKey, none_ok=False, silent=False):
return res[0]

def GetObjectsCoords(self, obKeys, none_ok=False, silent=False):
'''Returns the specified objects' x, y, (and sometimes) z coordinates in an image.
'''
if p.process_3D:
res = self.execute('SELECT %s, %s, %s, %s, %s FROM %s WHERE %s'%(
p.image_id, p.object_id, p.cell_x_loc, p.cell_y_loc, p.cell_z_loc, p.object_table,
GetWhereClauseForObjects(obKeys)), silent=silent)
reslist = [list(coord) for coord in res] #tuples are immutable so first make tuple of tuples a list of lists
reslist[0][2]=round(reslist[0][2]) #round to get z slice
restup = [tuple(coord) for coord in reslist] #then convert back to list of tuples
res = tuple(restup) #convert to tuple of tuples
else:
res = self.execute('SELECT %s, %s, %s, %s FROM %s WHERE %s'%(
p.image_id, p.object_id, p.cell_x_loc, p.cell_y_loc, p.object_table,
GetWhereClauseForObjects(obKeys)), silent=silent)
# Returns the specified objects' x and y coordinates in an image.
res = self.execute('SELECT %s, %s, %s, %s FROM %s WHERE %s'%(
p.image_id, p.object_id, p.cell_x_loc, p.cell_y_loc, p.object_table,
GetWhereClauseForObjects(obKeys)), silent=silent)
if len(res) == 0 or res[0][0] is None or res[0][1] is None:
message = ('Failed to load coordinates for object key %s. This may '
'indicate a problem with your per-object table.\n'
Expand Down