Skip to content

Commit

Permalink
Use image limit value for "Classify/Test Many"
Browse files Browse the repository at this point in the history
Previously, it was only used for "Top N Predictions"
  • Loading branch information
lukeyeager committed Feb 25, 2016
1 parent 982bcae commit 347754d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
17 changes: 15 additions & 2 deletions digits/model/images/classification/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,11 @@ def classify_many():
else:
image_folder = None

if 'num_test_images' in flask.request.form and flask.request.form['num_test_images'].strip():
num_test_images = int(flask.request.form['num_test_images'])
else:
num_test_images = None

epoch = None
if 'snapshot_epoch' in flask.request.form:
epoch = float(flask.request.form['snapshot_epoch'])
Expand Down Expand Up @@ -380,6 +385,9 @@ def classify_many():
paths.append(path)
ground_truths.append(ground_truth)

if num_test_images is not None and len(paths) >= num_test_images:
break

# create inference job
inference_job = ImageInferenceJob(
username = utils.auth.get_username(),
Expand Down Expand Up @@ -457,10 +465,11 @@ def top_n():
top_n = int(flask.request.form['top_n'])
else:
top_n = 9

if 'num_test_images' in flask.request.form and flask.request.form['num_test_images'].strip():
num_images = int(flask.request.form['num_test_images'])
num_test_images = int(flask.request.form['num_test_images'])
else:
num_images = None
num_test_images = None

paths = []
for line in image_list.readlines():
Expand All @@ -476,6 +485,10 @@ def top_n():
else:
path = line
paths.append(path)

if num_test_images is not None and len(paths) >= num_test_images:
break

random.shuffle(paths)

# create inference job
Expand Down
8 changes: 8 additions & 0 deletions digits/model/images/generic/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@ def infer_many():
else:
image_folder = None

if 'num_test_images' in flask.request.form and flask.request.form['num_test_images'].strip():
num_test_images = int(flask.request.form['num_test_images'])
else:
num_test_images = None

epoch = None
if 'snapshot_epoch' in flask.request.form:
epoch = float(flask.request.form['snapshot_epoch'])
Expand All @@ -343,6 +348,9 @@ def infer_many():
path = os.path.join(image_folder, path)
paths.append(path)

if num_test_images is not None and len(paths) >= num_test_images:
break

# create inference job
inference_job = ImageInferenceJob(
username = utils.auth.get_username(),
Expand Down
10 changes: 5 additions & 5 deletions digits/templates/models/images/classification/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ <h3>Test a list of images</h3>
<input type="text" id="image_folder" name="image_folder" class="form-control autocomplete_path">
<small>Relative paths in the text file will be prepended with this value before reading</small>
</div>
<div class="form-group">
<label for="num_test_images" class="control-label">Number of images use from the file</label>
<input type="text" id="num_test_images" name="num_test_images" class="form-control" placeholder="All">
<small>Leave blank to use all</small>
</div>
<button name="classify-many-btn"
formaction="{{url_for('digits.model.images.classification.views.classify_many', job_id=job.id())}}"
formmethod="post"
Expand All @@ -200,11 +205,6 @@ <h3>Test a list of images</h3>
data-container="body"
title="Classify a list of images and show the top 5 category predictions for each."
></span>
<div class="form-group">
<label for="num_test_images" class="control-label">Number of images use from the file</label>
<input type="text" id="num_test_images" name="num_test_images" class="form-control" value="100" placeholder="All">
<small>Leave blank to use all</small>
</div>
<div class="form-group">
<label for="top_n" class="control-label">Number of images to show per category</label>
<input type="text" id="top_n" name="top_n" class="form-control" placeholder="9">
Expand Down
5 changes: 5 additions & 0 deletions digits/templates/models/images/generic/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ <h3>Test a list of images</h3>
<input type="text" id="image_folder" name="image_folder" class="form-control autocomplete_path">
<small>Relative paths in the text file will be prepended with this value before reading</small>
</div>
<div class="form-group">
<label for="num_test_images" class="control-label">Number of images use from the file</label>
<input type="text" id="num_test_images" name="num_test_images" class="form-control" placeholder="All">
<small>Leave blank to use all</small>
</div>
<button name="infer-many-btn"
formaction="{{url_for('digits.model.images.generic.views.infer_many', job_id=job.id())}}"
formmethod="post"
Expand Down

0 comments on commit 347754d

Please sign in to comment.