Package: sheatless
sheatless - A python library for extracting parts from sheetmusic pdfsSheatless, a tool for The Beatless to become sheetless. Written and managed by the web-committee in the student orchestra The Beatless. Soon to be integrated intaktlaus.no.APIPdfPredictorclassPdfPredictor():def__init__(self,pdf:BytesIO|bytes,instruments=None,instruments_file=None,instruments_file_format="yaml",use_lstm=False,tessdata_dir=None,tesseract_languages=["eng"],log_stream=sys.stdout,crop_to_top=False,crop_to_left=True,full_score_threshold=3,full_score_label="Full score",):...defparts(self):for...:yield{"name":"<part name>","partNumber":"<part number>","instruments":["<instrument name",...],"fromPage":"<from page>","toPage":"<to page>",}Arguments for__init__:pdf- PDF file objectinstruments(optional) - Dictionary of instruments. Will override any provided instruments file.instruments_file(optional) - Full path to instruments file or instruments file object. Accepted extensions: .yaml, .yml, .jsoninstruments_file_format(optional) - Format of instruments_file if it is a file object. Accepted formats: yaml, jsonIf neither instruments_file nor instruments is provided a default instruments file will be used.use_lstm(optional) - Use LSTM instead of legacy engine mode.tessdata_dir(optional) - Full path to tessdata directory. If not provided, whatever the environment variable TESSDATA_DIR will be used.tesseract_languages(optional) - List of which languages tesseract should use.log_stream(optional) - File stream log output will be sent to. Can be set toNoneto disable logging.crop_to_top(optional) - If set toTrue(not default), PDF pages will be cropped to top half.crop_to_left(optional) - If set toTrue(default), PDF pages will be cropped to left half.full_score_threshold(optional) - If the number of parts predicted in one pages is greater than this number,full_score_labelwill be considered as the predicted part instead.full_score_label(optional) - The label to use for identifying a full score.processUploadedPdfdefprocessUploadedPdf(pdfPath,imagesDirPath,instruments_file=None,instruments=None,use_lstm=False,tessdata_dir=None):...returnparts,instrumentsDefaultPartswhich will be available withfromsheatlessimportprocessUploadedPdfArguments description here:ArgumentOptionalDescriptionpdfPathFull path to PDF file.imagesDirPathFull path to output images.instruments_file(optional)Full path to instruments file. Accepted formats: YAML (.yaml, .yml), JSON (.json).instruments(optional)Dictionary of instruments. Will override any provided instruments file.If neither instruments_file nor instruments is provided a default instruments file will be used.use_lstm(optional)Use LSTM instead of legacy engine mode.tessdata_dir(optional)Full path to tessdata directory. If not provided, whatever the environment variableTESSDATA_DIRwill be used.Returns description here:ReturnDescriptionpartsA list of dictionaries{ "name": "name", "instruments": ["instrument 1", "instrument 2"...] "fromPage": i, "toPage": j }describing each partinstrumentsDefaultPartsA dictionary{ ..., "instrument_i": j, ... }, wherejis the index in the parts list for the default part forinstrument_i.predict_parts_in_pdfdefpredict_parts_in_pdf(pdf:BytesIO|bytes,instruments=None,instruments_file=None,instruments_file_format="yaml",use_lstm=False,tessdata_dir=None,):...returnparts,instrumentsDefaultPartsArguments:pdf                                - PDF file objectinstruments             (optional) - Dictionary of instruments. Will override any provided instruments file.instruments_file        (optional) - Full path to instruments file or instruments file object. Accepted extensions: .yaml, .yml, .jsoninstruments_file_format (optional) - Format of instruments_file if it is a file object. Accepted formats: yaml, jsonIf neither instruments_file nor instruments is provided a default instruments file will be used.use_lstm                (optional) - Use LSTM instead of legacy engine mode.tessdata_dir            (optional) - Full path to tessdata directory. If not provided, whatever the environment variable TESSDATA_DIR will be used.Returns:parts                              - A list of dictionaries{ "name": "name", "instruments": ["instrument 1", "instrument 2"...] "fromPage": i, "toPage": j }describing each partinstrumentsDefaultParts            - A dictionary{ ..., "instrument_i": j, ... }, where j is the index in the parts list for the default part for instrument_i.predict_parts_in_imgdefpredict_parts_in_img(img:io.BytesIO|bytes|PIL.Image.Image,instruments,use_lstm=False,tessdata_dir=None)->typing.Tuple[list,list]:...returnpartNames,instrumentsesArguments:img                     - image objectinstruments             - dictionary of instrumentsuse_lstm     (optional) - Use LSTM instead of legacy engine mode.tessdata_dir (optional) - Full path to tessdata directory. If not provided, whatever the environment variable TESSDATA_DIR will be used.Returns:partNames               - a list of part namesinstrumentses           - a list of lists of instruments for each partExample docker setupSheatless requires tesseract and poppler installed on the system to work. An example docker setup as well as integration of the library can be found insheatless-splitter.