This commit is contained in:
mike
2026-06-18 23:26:30 +02:00
parent 1dead1c666
commit 045b9b6458
21 changed files with 1477 additions and 979 deletions

View File

@@ -10,6 +10,13 @@ import sys
import fcntl
import re
try:
from . import database
from . import embeddings
except ImportError:
import database
import embeddings
# Load configuration
CONFIG_PATH = os.path.join(os.path.dirname(__file__), "config.json")
@@ -142,6 +149,7 @@ def process_image(filename):
output_filename = f"{timestamp}_{filename}"
output_path = os.path.join(CONF["output_dir"], output_filename)
temp_path = input_path + ".tmp.png"
try:
logging.info(f"Starting processing for {filename}...")
cropped_img = crop_to_bbox(
@@ -152,7 +160,6 @@ def process_image(filename):
)
# Save temporary cropped image for upload
temp_path = input_path + ".tmp.png"
cropped_img.save(temp_path, format="PNG")
with open(temp_path, 'rb') as f:
@@ -169,6 +176,22 @@ def process_image(filename):
with open(output_path, 'wb') as f:
f.write(response.content)
logging.info(f"Successfully processed {filename} -> {output_path}")
# Register in DB
try:
embedding = embeddings.generate_embedding(output_path)
gid = filename
database.upsert_person(output_filename, filepath=output_path, embedding=embedding, group_id=gid)
# Also trigger tagging to get auto-name and clip description
tag_url = CONF["api_url"].replace("/edit", "/tag")
try:
requests.post(tag_url, json={"filename": output_filename, "group_id": gid}, timeout=30)
except Exception as tag_err:
logging.error(f"Error triggering tagging for {output_filename}: {tag_err}")
except Exception as db_err:
logging.error(f"Database error registering {output_filename}: {db_err}")
if os.path.exists(temp_path):
os.remove(temp_path)
return True