update binarization threshold

This commit is contained in:
Inga Kirschnick 2022-11-10 16:19:58 +01:00
parent f4f0628b60
commit 79d76f158f
4 changed files with 7 additions and 5 deletions

View File

@ -59,6 +59,8 @@ def _create_job_service(job):
command += f' -m {job.service_args["model"]}' command += f' -m {job.service_args["model"]}'
if 'binarization' in job.service_args and job.service_args['binarization']: if 'binarization' in job.service_args and job.service_args['binarization']:
command += ' --binarize' command += ' --binarize'
value = job.service_args['ocropus_nlbin_threshold']
command += f' --ocropus-nlbin-threshold {value}'
elif job.service == 'transkribus-htr-pipeline': elif job.service == 'transkribus-htr-pipeline':
transkribus_htr_pipeline_model_id = job.service_args['model'] transkribus_htr_pipeline_model_id = job.service_args['model']
command += f' -m {transkribus_htr_pipeline_model_id}' command += f' -m {transkribus_htr_pipeline_model_id}'

View File

@ -3,7 +3,7 @@ from flask_wtf import FlaskForm
from flask_wtf.file import FileField, FileRequired from flask_wtf.file import FileField, FileRequired
from wtforms import ( from wtforms import (
BooleanField, BooleanField,
IntegerRangeField, DecimalRangeField,
MultipleFileField, MultipleFileField,
SelectField, SelectField,
StringField, StringField,
@ -50,8 +50,8 @@ class CreateTesseractOCRPipelineJobForm(CreateJobBaseForm):
binarization = BooleanField('Binarization') binarization = BooleanField('Binarization')
pdf = FileField('File', validators=[FileRequired()]) pdf = FileField('File', validators=[FileRequired()])
model = SelectField('Model', validators=[InputRequired()]) model = SelectField('Model', validators=[InputRequired()])
ocropus_nlbin_threshold = IntegerRangeField( ocropus_nlbin_threshold = DecimalRangeField(
render_kw={'tooltips':'false', 'min': 0, 'max': 1, 'step': 0.1, 'start': [0.5]} render_kw={'min': 0, 'max': 1, 'step': 0.1, 'start': [0.5]}
) )
def validate_binarization(self, field): def validate_binarization(self, field):

View File

@ -79,7 +79,7 @@ def tesseract_ocr_pipeline():
service_args={ service_args={
'binarization': form.binarization.data, 'binarization': form.binarization.data,
'model': hashids.decode(form.model.data), 'model': hashids.decode(form.model.data),
'ocropus_nlbin_threshold': form.ocropus_nlbin_threshold.data 'ocropus_nlbin_threshold': float(form.ocropus_nlbin_threshold.data)
}, },
service_version=form.version.data, service_version=form.version.data,
user=current_user user=current_user

View File

@ -85,7 +85,7 @@
</div> </div>
<div class="col s12"><p>&nbsp;</p></div> <div class="col s12"><p>&nbsp;</p></div>
<div class="col s9"> <div class="col s9">
<p>Intensity</p> <p>Intensity (between 0 and 1)</p>
<p class="range-field">{{ form.ocropus_nlbin_threshold() }}</p> <p class="range-field">{{ form.ocropus_nlbin_threshold() }}</p>
</div> </div>
<div class="col s12"><p>&nbsp;</p></div> <div class="col s12"><p>&nbsp;</p></div>