Add switch for binarization

This commit is contained in:
Patrick Jentsch 2019-09-12 16:00:48 +02:00
parent 6cf12fa799
commit c51a9492f3
3 changed files with 29 additions and 6 deletions

View File

@ -1,5 +1,6 @@
from flask_wtf import FlaskForm
from wtforms import MultipleFileField, SelectField, StringField, SubmitField, ValidationError
from wtforms import (BooleanField, MultipleFileField, SelectField, StringField,
SubmitField, ValidationError)
from wtforms.validators import DataRequired, Length
@ -34,6 +35,7 @@ class NewNLPJobForm(FlaskForm):
class NewOCRJobForm(FlaskForm):
binarization = BooleanField('Binarazation')
description = StringField('Description',
validators=[DataRequired(), Length(1, 255)])
files = MultipleFileField('Files', validators=[DataRequired()])
@ -49,6 +51,7 @@ class NewOCRJobForm(FlaskForm):
('por', 'Portuguese'),
('spa', 'Spanish; Castilian')],
validators=[DataRequired()])
split = BooleanField('Split')
submit = SubmitField('Submit')
title = StringField('Title', validators=[DataRequired(), Length(1, 32)])
version = SelectField('Version',

View File

@ -62,9 +62,13 @@ def ocr():
mem_mb=8192,
n_cores=4,
service='ocr',
service_args=json.dumps([
'-l {}'.format(new_ocr_job_form.language.data),
'--skip-binarisation']),
service_args=json.dumps(
[
'-l {}'.format(new_ocr_job_form.language.data),
'' if new_ocr_job_form.binarization.data
else '--skip-binarisation'
]
),
service_version=new_ocr_job_form.version.data,
status='preparing',
title=new_ocr_job_form.title.data)

View File

@ -88,8 +88,7 @@
{% endfor %}
</div>
</div>
</div>
<div class="row">
<div class="col s12"></div>
<div class="col s12 m6">
<div class="file-field input-field">
<div class="btn">
@ -114,6 +113,23 @@
{% endfor %}
</div>
</div>
<div class="col s12"></div>
<div class="col s12">
<div class="switch right-align">
<label>
Perform binarization
{{ new_ocr_job_form.binarization() }}
<span class="lever"></span>
</label>
</div>
<div class="switch right-align">
<label>
Split pages in half
<input type="checkbox" disabled>
<span class="lever"></span>
</label>
</div>
</div>
</div>
</div>
<div class="card-action right-align">