feat: Integrate Ollama API for image comparison in sort_media.py
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
import shutil
|
||||
from datetime import datetime
|
||||
from ollama import Ollama
|
||||
import ollama
|
||||
|
||||
def get_earliest_time(file_path):
|
||||
"""Get the earliest of creation or last modified time."""
|
||||
@@ -29,15 +29,17 @@ def sort_media(directory):
|
||||
def compare_images_with_ollama(directory):
|
||||
"""Compare images using Ollama."""
|
||||
# Initialize the Ollama model
|
||||
ollama = Ollama(model='llama3.2')
|
||||
model = 'llama3.2'
|
||||
|
||||
for root, _, files in os.walk(directory):
|
||||
for file in files:
|
||||
if file.lower().endswith(('.png', '.jpg', '.jpeg')):
|
||||
file_path = os.path.join(root, file)
|
||||
# Use Ollama to compare images
|
||||
result = ollama.compare_images(file_path)
|
||||
print(f"Comparison result for {file}: {result}")
|
||||
response = ollama.chat(model=model, messages=[
|
||||
{'role': 'user', 'content': f'Compare image: {file_path}'},
|
||||
])
|
||||
print(f"Comparison result for {file}: {response['message']['content']}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
directory = input("Enter the directory path to sort and compare media: ")
|
||||
|
||||
Reference in New Issue
Block a user