remove old fun

This commit is contained in:
hendrik 2025-06-03 21:24:19 +02:00
parent cb3cffe044
commit 6d21949cd6
2 changed files with 10 additions and 13 deletions

View File

@ -6,4 +6,5 @@ Use two AI models to generate tags for images. The tags will be saved in a `json
* Actually make interchangeable objects that gives tags per file
* handle videos: (idea: split using ffmpeg - tag those and somehow combine into taglist)
* ui
* ui
* progress (collect files and print progress)

View File

@ -16,6 +16,14 @@ CUTOFF = 0.035
model_clip = CLIPModel.from_pretrained("openai/clip-vit-base-patch32").to(DEVICE)
processor_clip = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")
def print_cuda_ava():
print(f"CUDA available: {torch.cuda.is_available()}")
print(f"Current device: {torch.cuda.current_device()}")
print(f"Device name: {torch.cuda.get_device_name(torch.cuda.current_device())}")
print(f"Allocated memory: {torch.cuda.memory_allocated()} bytes")
print(f"Reserved memory: {torch.cuda.memory_reserved()} bytes")
processor_blib = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
model_blib = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base").to(DEVICE)
@ -68,18 +76,6 @@ def add_tags_to_path(tags, json_path):
with open(json_path, "w") as json_file:
json.dump(new_json_data, json_file, indent=4)
def process_folder_clip(directory):
for root, _, files in os.walk(directory):
for fname in files:
if fname.lower().endswith((".jpg", ".png", ".jpeg", ".webp", ".bmp")):
full_path = os.path.join(root, fname)
json_path = os.path.join(root, f"{fname}.json")
tags = get_clip_tags(full_path, candidate_tags)
filtered_tags = [ tag for tag, score in tags if score > CUTOFF ]
add_tags_to_path(filtered_tags, json_path)
def process_image_folder(directory, clip, blib):
for root, _, files in os.walk(directory):
for fname in files: