Implementation
This commit is contained in:
@@ -2,6 +2,8 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import csv
|
import csv
|
||||||
|
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from sentence_transformers import SentenceTransformer
|
from sentence_transformers import SentenceTransformer
|
||||||
import tqdm
|
import tqdm
|
||||||
import click
|
import click
|
||||||
@@ -11,19 +13,60 @@ from .inference import InferenceContext, load_ucs
|
|||||||
from .util import ffmpeg_description, parse_ucs
|
from .util import ffmpeg_description, parse_ucs
|
||||||
|
|
||||||
|
|
||||||
@click.group()
|
def recommend_text(text: str, ctx: InferenceContext):
|
||||||
|
return None
|
||||||
|
|
||||||
|
@click.group(epilog="For more information see "
|
||||||
|
"<https://git.squad51.us/jamie/ucsinfer>")
|
||||||
# @click.option('--verbose', flag_value='verbose', help='Verbose output')
|
# @click.option('--verbose', flag_value='verbose', help='Verbose output')
|
||||||
def ucsinfer():
|
def ucsinfer():
|
||||||
|
"""
|
||||||
|
Tools for applying UCS categories to sounds using large-language Models
|
||||||
|
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@ucsinfer.command('recommend')
|
@ucsinfer.command('recommend')
|
||||||
def recommend():
|
@click.option('--text', type=Optional[str], default=None,
|
||||||
|
help="Recommend a category for given text instead of reading "
|
||||||
|
"from a file")
|
||||||
|
@click.argument('files', nargs=-1)
|
||||||
|
@click.option('--model', type=str, metavar="<model-name>",
|
||||||
|
default="paraphrase-multilingual-mpnet-base-v2",
|
||||||
|
show_default=True,
|
||||||
|
help="Select the sentence_transformer model to use")
|
||||||
|
def recommend(text, paths, model):
|
||||||
"""
|
"""
|
||||||
Infer a UCS category for a text description
|
Infer a UCS category for a text description
|
||||||
|
|
||||||
"""
|
"""
|
||||||
pass
|
m = SentenceTransformer(model)
|
||||||
|
ctx = InferenceContext(m, model)
|
||||||
|
|
||||||
|
recommendations = []
|
||||||
|
if text is not None:
|
||||||
|
recommendations.append({
|
||||||
|
"text": text,
|
||||||
|
"recommendations": recommend_text(text, ctx)
|
||||||
|
})
|
||||||
|
|
||||||
|
for path in paths:
|
||||||
|
text = ffmpeg_description(path)
|
||||||
|
if text:
|
||||||
|
recommendations.append({
|
||||||
|
"path":path,
|
||||||
|
"text":text,
|
||||||
|
"recommendations":recommend_text(text, ctx)
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
recommendations.append({
|
||||||
|
"path":path,
|
||||||
|
"text":None,
|
||||||
|
"recommendations":None
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ucsinfer.command('gather')
|
@ucsinfer.command('gather')
|
||||||
|
Reference in New Issue
Block a user