Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvain-morin committed Feb 15, 2024
1 parent 46f8cc7 commit e5ecc71
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/inat_inferrer.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ def prepare_image_for_inference(self, file_path):
image = tf.image.resize(image, [299, 299], tf.image.ResizeMethod.NEAREST_NEIGHBOR)
result = tf.expand_dims(image, 0)
END_TIME_RESIZE = time.time()
TIME_RESIZE = TIME_RESIZE + (END_TIME_RESIZE - START_TIME_RESIZE)
print("TIME-EXP: TIME_RESIZE "+str(TIME_RESIZE))
self.TIME_RESIZE = self.TIME_RESIZE + (END_TIME_RESIZE - START_TIME_RESIZE)
print("TIME-EXP: TIME_RESIZE "+str(self.TIME_RESIZE))
return result;

def vision_predict(self, image, debug=False):
Expand Down
12 changes: 8 additions & 4 deletions lib/inat_vision_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,19 @@ def bench_route(self):

for i in range(start, start + count):
observation_id = str( i )
form = ImageForm()
form.score_without_geo.data = "true"
form.aggregated.data = "true"

print("TIME-EXP: score " + observation_id)
START_TIME_TOTAL = time.time()
image_uuid = "downloaded-obs-" + observation_id
START_TIME_DOWNLOAD = time.time()
file_path, lat, lng, iconic_taxon_id = self.download_observation(
observation_id, image_uuid)
END_TIME_DOWNLOAD = time.time()
if file_path is None:
print("TIME-EXP: obs not found")
else:
TOTAL_OBS = TOTAL_OBS + 1
self.inferrer.TIME_DOWNLOAD = self.inferrer.TIME_DOWNLOAD + (END_TIME_DOWNLOAD - START_TIME_DOWNLOAD)
print("TIME-EXP: TIME_DOWNLOAD "+str(self.inferrer.TIME_DOWNLOAD))
scores = self.score_image(form, file_path, lat, lng, iconic_taxon_id, geomodel)
END_TIME_TOTAL = time.time()
self.inferrer.TIME_TOTAL = self.inferrer.TIME_TOTAL + (END_TIME_TOTAL - START_TIME_TOTAL)
Expand Down Expand Up @@ -246,8 +246,12 @@ def download_observation(self, observation_id, image_uuid):
return None, None, None
# download the first image if it isn't already cached
if not os.path.exists(cache_path):
START_TIME_DOWNLOAD = time.time()
urllib.request.urlretrieve(
data["results"][0]["photos"][0]["url"].replace("square", "medium"), cache_path)
END_TIME_DOWNLOAD = time.time()
self.inferrer.TIME_DOWNLOAD = self.inferrer.TIME_DOWNLOAD + (END_TIME_DOWNLOAD - START_TIME_DOWNLOAD)
print("TIME-EXP: TIME_DOWNLOAD "+str(self.inferrer.TIME_DOWNLOAD))
latlng = data["results"][0]["location"].split(",")
# return the path to the cached image, coordinates, and iconic taxon
return cache_path, latlng[0], latlng[1], data["results"][0]["taxon"]["iconic_taxon_id"]
Expand Down

0 comments on commit e5ecc71

Please sign in to comment.