mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-14 16:55:42 +00:00
Update OCR-Models list + small fix for empty list
This commit is contained in:
parent
e93449ba73
commit
a54ff2e35a
@ -84,12 +84,18 @@ class CreateTesseractOCRPipelineJobForm(CreateJobBaseForm):
|
|||||||
del self.binarization.render_kw['disabled']
|
del self.binarization.render_kw['disabled']
|
||||||
if 'ocropus_nlbin_threshold' in service_info['methods']:
|
if 'ocropus_nlbin_threshold' in service_info['methods']:
|
||||||
del self.ocropus_nlbin_threshold.render_kw['disabled']
|
del self.ocropus_nlbin_threshold.render_kw['disabled']
|
||||||
|
user_models = [
|
||||||
|
x for x in current_user.tesseract_ocr_pipeline_models.order_by(TesseractOCRPipelineModel.title).all()
|
||||||
|
]
|
||||||
models = [
|
models = [
|
||||||
x for x in TesseractOCRPipelineModel.query.order_by(TesseractOCRPipelineModel.title).all()
|
x for x in TesseractOCRPipelineModel.query.order_by(TesseractOCRPipelineModel.title).all()
|
||||||
if version in x.compatible_service_versions and (x.is_public == True or x.user == current_user)
|
if version in x.compatible_service_versions and (x.is_public == True or x.user == current_user)
|
||||||
]
|
]
|
||||||
self.model.choices = [('', 'Choose your option')]
|
self.model.choices = {
|
||||||
self.model.choices += [(x.hashid, f'{x.title} [{x.version}]') for x in models]
|
'': [('', 'Choose your option')],
|
||||||
|
'Your models': [(x.hashid, f'{x.title} [{x.version}]') for x in user_models] if user_models else [(0, 'Nothing here yet...')],
|
||||||
|
'Public models': [(x.hashid, f'{x.title} [{x.version}]') for x in models]
|
||||||
|
}
|
||||||
self.model.default = ''
|
self.model.default = ''
|
||||||
self.version.choices = [(x, x) for x in service_manifest['versions']]
|
self.version.choices = [(x, x) for x in service_manifest['versions']]
|
||||||
self.version.data = version
|
self.version.data = version
|
||||||
@ -177,7 +183,7 @@ class CreateSpacyNLPPipelineJobForm(CreateJobBaseForm):
|
|||||||
]
|
]
|
||||||
self.model.choices = {
|
self.model.choices = {
|
||||||
'': [('', 'Choose your option')],
|
'': [('', 'Choose your option')],
|
||||||
'Your models': [(x.hashid, f'{x.title} [{x.version}]') for x in user_models],
|
'Your models': [(x.hashid, f'{x.title} [{x.version}]') for x in user_models] if user_models else [(0, 'Nothing here yet...')],
|
||||||
'Public models': [(x.hashid, f'{x.title} [{x.version}]') for x in models]
|
'Public models': [(x.hashid, f'{x.title} [{x.version}]') for x in models]
|
||||||
}
|
}
|
||||||
self.model.default = ''
|
self.model.default = ''
|
||||||
|
@ -107,11 +107,13 @@ def tesseract_ocr_pipeline():
|
|||||||
x for x in TesseractOCRPipelineModel.query.all()
|
x for x in TesseractOCRPipelineModel.query.all()
|
||||||
if version in x.compatible_service_versions and (x.is_public == True or x.user == current_user)
|
if version in x.compatible_service_versions and (x.is_public == True or x.user == current_user)
|
||||||
]
|
]
|
||||||
|
user_tesseract_ocr_pipeline_models_count = len(current_user.tesseract_ocr_pipeline_models.all())
|
||||||
return render_template(
|
return render_template(
|
||||||
'services/tesseract_ocr_pipeline.html.j2',
|
'services/tesseract_ocr_pipeline.html.j2',
|
||||||
title=service_manifest['name'],
|
title=service_manifest['name'],
|
||||||
form=form,
|
form=form,
|
||||||
tesseract_ocr_pipeline_models=tesseract_ocr_pipeline_models
|
tesseract_ocr_pipeline_models=tesseract_ocr_pipeline_models,
|
||||||
|
user_tesseract_ocr_pipeline_models_count=user_tesseract_ocr_pipeline_models_count
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -183,6 +185,7 @@ def spacy_nlp_pipeline():
|
|||||||
abort(404)
|
abort(404)
|
||||||
form = CreateSpacyNLPPipelineJobForm(prefix='create-job-form', version=version)
|
form = CreateSpacyNLPPipelineJobForm(prefix='create-job-form', version=version)
|
||||||
spacy_nlp_pipeline_models = SpaCyNLPPipelineModel.query.all()
|
spacy_nlp_pipeline_models = SpaCyNLPPipelineModel.query.all()
|
||||||
|
user_spacy_nlp_pipeline_models_count = len(current_user.spacy_nlp_pipeline_models.all())
|
||||||
if form.is_submitted():
|
if form.is_submitted():
|
||||||
if not form.validate():
|
if not form.validate():
|
||||||
response = {'errors': form.errors}
|
response = {'errors': form.errors}
|
||||||
@ -214,7 +217,8 @@ def spacy_nlp_pipeline():
|
|||||||
'services/spacy_nlp_pipeline.html.j2',
|
'services/spacy_nlp_pipeline.html.j2',
|
||||||
title=service_manifest['name'],
|
title=service_manifest['name'],
|
||||||
form=form,
|
form=form,
|
||||||
spacy_nlp_pipeline_models=spacy_nlp_pipeline_models
|
spacy_nlp_pipeline_models=spacy_nlp_pipeline_models,
|
||||||
|
user_spacy_nlp_pipeline_models_count=user_spacy_nlp_pipeline_models_count
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -163,3 +163,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock modals %}
|
{% endblock modals %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
{{ super() }}
|
||||||
|
<script>
|
||||||
|
// Disable user model selection if no models are available
|
||||||
|
{% if user_spacy_nlp_pipeline_models_count == 0 %}
|
||||||
|
optionGroupOptions = document.querySelectorAll(".optgroup-option");
|
||||||
|
optionGroupOptions[0].classList.add("disabled");
|
||||||
|
{% endif %}
|
||||||
|
</script>
|
||||||
|
{% endblock scripts %}
|
||||||
|
@ -147,6 +147,13 @@
|
|||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
// Disable user model selection if no models are available
|
||||||
|
{% if user_tesseract_ocr_pipeline_models_count == 0 %}
|
||||||
|
optionGroupOptions = document.querySelectorAll(".optgroup-option");
|
||||||
|
optionGroupOptions[0].classList.add("disabled");
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
document.querySelector('#create-job-form-binarization').addEventListener('change', (event) => {
|
document.querySelector('#create-job-form-binarization').addEventListener('change', (event) => {
|
||||||
document.querySelector('#create-job-form-ocropus_nlbin_threshold-container').classList.toggle('hide');
|
document.querySelector('#create-job-form-ocropus_nlbin_threshold-container').classList.toggle('hide');
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user