Package: fast-form
fast-formProject from UniHack hackathon, helps to extract data from forms.InstallationTo use fast-form first installAnacondaon your computer from:https://www.anaconda.com/products/individual#Downloadsyou can keep default options for all the configurations of Installation wizard.then openAnaconda Promptand run these commands one by one:conda create -n fast-form python=3.7.10
conda activate fast-form
pip install fast-formInstalling dependencies will take couple of minuts.If the installation was successful, you can test if the CLI works correctly, by running:fast-form--versionNow you can start using the tool.Test RunTo run fast-form, first, initialize data folder:fast-forminitThis will create a folderfast-form-datacontaining test data and all the config files in your current working path.You will want to customize these files later on, for the test run, leave them as they are and run:fast-formextractThis will createvalidation_excel.xlsx, which you can open in office suite and manually fix all the results that were not recognized correctly.-1 is used for answers that were recognized as having multiple fields crossed-2 in case no crossed field was recognizedYou can replace those, in case picture recognition did a poor job.Once you are happy with the result, save the validation excel and runfast-formfinalizeThis will compile validated data in to format "one questionnaire per line" and append it in to excel configured infinal_excel_pathinpath_config.json.Using fast-formfast-form initcreated following directory structurefast-form-data
│   path_config.json
│   config.json    
│   template.pdf
└───documents
    │   document.jpg
    │   ...To configure fast-form for your custom questionnaire, you will have to replace/reconfigure these filespath_config.jsonProvides paths to all files and folders necessary for the script to run.
You can either let it as is and change the filenames, or change this configuration using any plain text processor (e.g. Notepad).{"template_path":"/pathtotemplate/template.jpg","form_structure_path":"/pathtoconfig/config.json","folder_with_documents_path":"/pathtodocumentfolder/documents","final_excel_path":"/pathtofinalexcel/final_excel.xlsx"}config.jsonContains description of all the fields in the questionnaire and their exact position on the page.
Those configs have to be created manually using the template and there is no visual tool to do it. We have ajupyter notebookfor this task, but workflow is far from smooth at this point.template.pdfIs clear, empty questionnaire, used as a template to correctly scale and rotate scanned files.
You can use pdf version of the file, that is used to print the questionnaires.documentsSimply a folder where you put all the scanned questionnaires to be processed.
Once files have been processed, it might be good idea to archive them.final_excel.xlsxIf you want the results to be appended to your existing excel document, provide path to this file, otherwise fast-form will create new excel document.Once you provided all the configuration files, you can process the files using following loopFill batch of scans in to documents folder.runfast-formextractvalidate results in table processor (such as Microsoft Excel)Finalize validated results with command:fast-formfinalizeDevelopmentBefore development please runmake setupInstalling new dependencies added on remotepip-syncAdding dependencies:add line torequirements.inand then runpip-compileRetrain modelWe are using preparsed emnist dataset.https://www.kaggle.com/crawford/emnistTo retrain the model, you need to download it to training_data folderfast-form
 - training_data
    - emnist-balanced-mapping.txt
    - emnist-balanced-train.csv
    - emnist-balanced-test.csv
    ...
 ...and then first runfield_recognizer/enrich_dataset.ipynbin jupyter notebook and after that usefield_recognizer/emnist-neural-network.ipynbtwice, once for type numbers, once for type letters
(see inside of notebook )Example form configuration - JSONtests/form_for_test/config.jsonRoad mappriorities till 15.11.2020Character Recognitionretrain model on capital letters onlyenrich emnist dataset by different letter positioninguse this notebook to improve the modelhttps://www.kaggle.com/tarunkr/digit-recognition-tutorial-cnn-99-67-accuracyAdd model for numbersSolve czech characters, eitherfind different dataset with czech diacriticsenrich emnist dataset by letters with diacriticsAdd second clasifier, that would recognize diacritics  / accute(') / carron(ˇ) / none  /Create our own, small dataset (maybe adding the diacritics to current dataset)
and use methods here:https://arxiv.org/pdf/1904.08095.pdf(depends on something in section Model results processing) Create a model distinguishing X or filled circle or nothing or anomaly.
Improve true/false computation for boxesRefactoringRestructure repository to separate code from dataRefactor to original emnist dataset structure instead of preparsed csv data from kagglePreprocessingsmarter thresholdingsmarter corner classificationcompletely drop corners, orient page based on the original file provided (fitting text on text)Improve just config so it centers boxes better and reponse 159 in PID1 is correctly parsedChange code to handle multiple pages somehowBetter noise cancellation on the whole fileBetter noise cancellation on the level of the cropped boxes (important to do before cropping to the symbol area as it is broken by noise at the moment sometimes)
many options how to approach, choose anyPossibly (but maybe hard to do): remove bounding lines from figures.Speedup: the current matching teplate logic is simly tooo slow. Think what to douse other feature extraction method than SIFT (I have tried ORB which did not work well enough, but maybe after some tuning it would. it is way faster)do whathever elseSaving of templates -> pickle is not working, but can be made working byhttps://stackoverflow.com/questions/10045363/pickling-cv2-keypoint-causes-picklingerrorModel results processingImplement logic around single choice forms return only single choice if there is only 1 true choice found, otherwise -1 (if no question answered) or -2 (if more than one question answered).Add to single choice logic also logic for filled in and anomaly circles.Specific Questionnaire processingPrepare empty template that will have only header and some repeating thigs for PID, test how it works, potentially alter
PID a bit, so it works for such empty templatePrepare at the top of the first page space where one can fill in the patient code and add this to config as only number fieldConfigurationlocation of text via top left corner, bottom right corner plus number of lettersCreate a tool for config file creationPackaging, proper outputprepare for pdf with multiple questionnairescreate config for the current questionnaire we are working onFor the name of the patient use the name from questionnaire of question called patient_id. In case such question is not present, use the name of the pdf (as it is done now)Prepare python script that will process the scanned pdfs:The program should get the following parameters from config file that will have to be existing in the folder:- folder with scanned files (how should be new questionnaire recongized? new file for each?
- path to template document as pdf or jpg or something
- config file with location of answers in the template document via coordinates in pixels (see configuration above)And it should output:- excel file with the answers and their accuracies and also the parts of the original scan that were used for the recognition.Prepare python script that will process the excel document with all the answers into an excel sheet. One questionnaire per line.params:path to the excel with answerspath to the excel to put it in (if none, create new)name of the sheet (if none create new)
if the sheet is non empty put the data below the data already thereWrite readmeWrite nicer readmeCreate from this a package on pypiTest and especially let someone test on mac