Skip to content

Commit

Permalink
Merge pull request #2 from lukeyeager/pr137-fixes
Browse files Browse the repository at this point in the history
Pr137 fixes
  • Loading branch information
groar committed Jun 15, 2015
2 parents a465d6c + 48ff78c commit 823dea6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
24 changes: 14 additions & 10 deletions digits/evaluation/images/classification/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
# -*- coding: utf-8 -*-

import flask
import werkzeug.exceptions

from digits.evaluation import tasks
from digits.webapp import app, scheduler
from flask import render_template, request, redirect, url_for
from job import ImageClassificationEvaluationJob


Expand All @@ -11,24 +14,24 @@

@app.route(NAMESPACE + '/new', methods=['GET'])
def image_classification_evaluation_new():
return render_template('evaluations/images/classification/new.html')
return flask.render_template('evaluations/images/classification/new.html')


@app.route(NAMESPACE + '/accuracy', methods=['POST'])
def image_classification_evaluation_create():
"""Creates a classification performance evaluation task """

modelJob = scheduler.get_job(request.args['job_id'])
modelJob = scheduler.get_job(flask.request.args['job_id'])

if not modelJob:
return 'Unknown model job_id "%s"' % request.args['job_id'], 500
if modelJob is None:
raise werkzeug.exceptions.NotFound('Job not found')

job = None
try:
# We retrieve the selected snapshot from the epoch and the train task
epoch = None
if 'snapshot_epoch' in request.form:
epoch = int(request.form['snapshot_epoch'])
epoch = -1
if 'snapshot_epoch' in flask.request.form:
epoch = float(flask.request.form['snapshot_epoch'])

job = ImageClassificationEvaluationJob(
name=modelJob._name + "-accuracy-evaluation-epoch-" + str(epoch),
Expand Down Expand Up @@ -62,7 +65,7 @@ def image_classification_evaluation_create():

# The job is created
scheduler.add_job(job)
return redirect(url_for('evaluations_show', job_id=job.id()))
return flask.redirect(flask.url_for('evaluations_show', job_id=job.id()))

except:
if job:
Expand All @@ -74,4 +77,5 @@ def show(job):
"""
Called from digits.evaluation.views.evaluations_show()
"""
return render_template('evaluations/images/classification/show.html', job=job)
return flask.render_template('evaluations/images/classification/show.html', job=job)

2 changes: 0 additions & 2 deletions digits/evaluation/tasks/accuracy.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ def avg_accuracy_graph_data(self):
if self.probas_data is None:
return None

print self.probas_data

def f_threshold(threshold, probas):
N = len(probas)
max_probs = np.max(probas, axis=1)
Expand Down
19 changes: 19 additions & 0 deletions digits/test_webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,25 @@ def test_retrain(self):
method='previous', **options)
self.abort_model(job_id)

def test_evaluation(self):
"""created model - evaluate"""
url = '/evaluations/images/classification/accuracy?job_id=%s' % self.model_id
rv = self.app.post(url)

# expect a redirect
if not 300 <= rv.status_code <= 310:
s = BeautifulSoup(rv.data)
div = s.select('div.alert-danger')
if div:
raise RuntimeError(div[0])
else:
raise RuntimeError('Failed to create evaluation')

job_id = self.job_id_from_response(rv)

assert self.job_wait_completion(job_id) == 'Done', 'evaluation creation failed'


class TestDatasetModelInteractions(WebappBaseTest):
"""
Test the interactions between datasets and models
Expand Down

0 comments on commit 823dea6

Please sign in to comment.