Spaces:
Running on Zero
Running on Zero
File size: 1,680 Bytes
9ef70e8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | #!/usr/bin/env python3
import argparse
import sys
sys.path.insert(0, '.')
from lib.multimodal_search import verify_image_embedding, image_search_command
def main():
parser = argparse.ArgumentParser(description="Multimodal Search CLI")
subparsers = parser.add_subparsers(dest="command", help="Available commands")
# Verify image embedding command
verify_parser = subparsers.add_parser(
"verify_image_embedding",
help="Verify image embedding generation"
)
verify_parser.add_argument(
"image_path",
type=str,
help="Path to the image file"
)
# Image search command
search_parser = subparsers.add_parser(
"image_search",
help="Search movies using an image"
)
search_parser.add_argument(
"image_path",
type=str,
help="Path to the image file"
)
args = parser.parse_args()
match args.command:
case "verify_image_embedding":
verify_image_embedding(args.image_path)
case "image_search":
results = image_search_command(args.image_path)
# Print results
for i, result in enumerate(results, 1):
# Truncate description to first 100 characters
description = result['description'][:100]
if len(result['description']) > 100:
description += "..."
print(f"{i}. {result['title']} (similarity: {result['similarity']:.3f})")
print(f" {description}")
print()
case _:
parser.print_help()
if __name__ == "__main__":
main()
|