Added some logging code

This commit is contained in:
2025-09-03 11:36:38 -07:00
parent 2fcdc24699
commit d330f47462

View File

@@ -1,6 +1,7 @@
import os
import sys
import csv
import logging
from sentence_transformers import SentenceTransformer
import tqdm
@@ -13,12 +14,23 @@ from .util import ffmpeg_description, parse_ucs
@click.group(epilog="For more information see "
"<https://git.squad51.us/jamie/ucsinfer>")
# @click.option('--verbose', flag_value='verbose', help='Verbose output')
def ucsinfer():
@click.option('--verbose', '-v', flag_value='verbose', help='Verbose output')
def ucsinfer(verbose):
"""
Tools for applying UCS categories to sounds using large-language Models
"""
pass
if verbose:
logging.basicConfig(format="%(levelname)s: %(message)s",
level=logging.DEBUG)
else:
import warnings
warnings.filterwarnings(
action='ignore', module='torch', category=FutureWarning,
message=r"`encoder_attention_mask` is deprecated.*")
logging.basicConfig(format="%(levelname)s: %(message)s",
level=logging.WARN)
@ucsinfer.command('recommend')
@@ -44,7 +56,7 @@ def recommend(text, paths, model, interactive, skip_ucs):
"Description" text metadata is extracted from audio files given as PATHS,
or text can be provided directly using the "--text" option. The selected
model is then used to attempt to classify the given text according to
the synonyms and explanations definied for each UCS subcategory. A list
the synonyms an explanations definied for each UCS subcategory. A list
of ranked subcategories is printed to the terminal for each PATH.
"""
m = SentenceTransformer(model)
@@ -246,10 +258,4 @@ def evaluate(dataset, offset, limit, model, no_foley):
if __name__ == '__main__':
os.environ['TOKENIZERS_PARALLELISM'] = 'false'
# sentence_transformers generates an error in PyTorch upon loading
import warnings
warnings.filterwarnings(action='ignore', module='torch',
category=FutureWarning,
message=r"`encoder_attention_mask` is deprecated.*")
ucsinfer()