Check for vision model

This commit is contained in:
Jeffrey Serio 2024-12-21 16:37:19 -06:00
parent b601b2c381
commit 5e6a01ce16
2 changed files with 41 additions and 4 deletions

View File

@ -11,6 +11,18 @@ Options:
-m MODEL Use MODEL as the model. If MODEL is not provided, it defaults -m MODEL Use MODEL as the model. If MODEL is not provided, it defaults
to llama3.2-vision:11b. to llama3.2-vision:11b.
Supported vision models:
- llama3.2-vision:11b
- llama3.2-vision:90b
- llava:7b
- llava:13b
- llava:34b
- llava-llama3:8b
- bakllava:7b
- moondream:1.8b
- llava-phi3:3.8b
- minicpm-v:8b
Examples: Examples:
gen-alt-text -m llama3.2-vision:90b ~/pictures/rubber_duck.jpg gen-alt-text -m llama3.2-vision:90b ~/pictures/rubber_duck.jpg
gen-alt-text ~/pictures/coffee.jpg gen-alt-text ~/pictures/coffee.jpg
@ -26,7 +38,34 @@ from rich.markdown import Markdown
def main(): def main():
args = docopt(__doc__) args = docopt(__doc__)
vision_models = [
"llama3.2-vision:11b",
"llama3.2-vision:90b",
"llava:7b",
"llava:13b",
"llava:34b",
"llava-llama3:8b",
"bakllava:7b",
"moondream:1.8b",
"llava-phi3:3.8b",
"minicpm-v:8b",
]
print()
console = Console()
if args["-m"]: if args["-m"]:
if args["-m"] not in vision_models:
console.print(
"You must use a vision model to generate alt-text from images."
)
print()
console.print("[bold magenta]Available vision models:[/bold magenta]")
for model in vision_models:
print(f"- {model}")
print()
exit("Select a model above and run the command again.")
else:
model = args["-m"] model = args["-m"]
else: else:
model = "llama3.2-vision:11b" model = "llama3.2-vision:11b"
@ -36,8 +75,6 @@ def main():
else: else:
client = Client(host="http://localhost:11434") client = Client(host="http://localhost:11434")
print()
console = Console()
try: try:
with console.status( with console.status(
f"[bold magenta] {model}[/bold magenta] is generating alt-text for " f"[bold magenta] {model}[/bold magenta] is generating alt-text for "

View File

@ -1,6 +1,6 @@
[project] [project]
name = "gen-alt-text" name = "gen-alt-text"
version = "0.1" version = "0.2"
authors = [ authors = [
{ name="Jeffrey Serio", email="hyperreal@fedoraproject.org" }, { name="Jeffrey Serio", email="hyperreal@fedoraproject.org" },
] ]