Using folders "Copies" and "Par label", hopefully
This commit is contained in:
+16
-15
@@ -101,7 +101,7 @@ def worker_thread(base_dir, files_to_process, all_labels):
|
||||
previous_copie = None
|
||||
last_label_index = None
|
||||
for img_path in files_to_process:
|
||||
json_path = base_dir / f"{img_path.stem}.json"
|
||||
json_path = base_dir / "Copies" / f"{img_path.stem}.json"
|
||||
copie_part = int(img_path.stem[-2:])
|
||||
copie = img_path.stem[:-3]
|
||||
if copie != previous_copie:
|
||||
@@ -222,7 +222,7 @@ class ImageViewer:
|
||||
def save_current_batch(self):
|
||||
"""Writes the accumulated data to the main JSON file."""
|
||||
if self.active_copie_name and self.accumulated_results:
|
||||
main_json_path = self.base_dir / f"{self.active_copie_name}.json"
|
||||
main_json_path = self.base_dir / "Copies" / f"{self.active_copie_name}.json"
|
||||
print(f"Writing aggregated result to {main_json_path}")
|
||||
with open(main_json_path, 'w') as f:
|
||||
json.dump(self.accumulated_results, f)
|
||||
@@ -327,7 +327,7 @@ class ImageViewer:
|
||||
def on_open_ori_pdf(self, event):
|
||||
if self.is_viewing and self.current_json_path:
|
||||
new_filename = self.current_json_path.stem.split('_')[0] + ".pdf"
|
||||
pdf_path = self.current_json_path.parent / "Copies Originales" / new_filename
|
||||
pdf_path = self.base_dir / "Copies Originales" / new_filename
|
||||
print(f"Opening {pdf_path}")
|
||||
subprocess.Popen(['xdg-open', str(pdf_path.absolute())])
|
||||
|
||||
@@ -363,20 +363,21 @@ if __name__ == "__main__":
|
||||
files_to_process = []
|
||||
|
||||
if input_path.is_file():
|
||||
# Correctly identify base_dir if we are in 'Copies' or 'Cutleft'
|
||||
if input_path.parent.name in ["Copies", "Cutleft"]:
|
||||
base_dir = input_path.parent.parent
|
||||
else:
|
||||
base_dir = input_path.parent
|
||||
|
||||
base_dir = input_path.parent
|
||||
stem = input_path.stem
|
||||
img_path = base_dir / "Cutleft" / f"{stem}.jpg"
|
||||
files_to_process = [img_path]
|
||||
if not img_path.exists() and input_path.parent.name == "Cutleft":
|
||||
base_dir = input_path.parent.parent
|
||||
img_path = input_path
|
||||
files_to_process = [img_path]
|
||||
if not img_path.exists():
|
||||
# We're given Copie01.pdf, look for parts
|
||||
cutleft_dir = base_dir / "Cutleft"
|
||||
files_to_process = sorted(list(cutleft_dir.glob(f"{img_path.stem}_*.jpg")),
|
||||
key=natural_key)
|
||||
cutleft_dir = base_dir / "Cutleft"
|
||||
img_path = cutleft_dir / f"{stem}.jpg"
|
||||
|
||||
if img_path.exists():
|
||||
files_to_process = [img_path]
|
||||
else:
|
||||
# We're given something like Copie01.pdf, look for its split image parts
|
||||
files_to_process = sorted(list(cutleft_dir.glob(f"{stem}_*.jpg")), key=natural_key)
|
||||
else:
|
||||
base_dir = input_path
|
||||
cutleft_dir = base_dir / "Cutleft"
|
||||
|
||||
Reference in New Issue
Block a user