diff --git a/backend/compare_accuracy.py b/backend/compare_accuracy.py index 95a34f8..3762222 100644 --- a/backend/compare_accuracy.py +++ b/backend/compare_accuracy.py @@ -27,7 +27,7 @@ def main(): # Load automated results auto_results = {} - with open(jsonl_file, "r") as f: + with open(jsonl_file, "r", encoding="utf-8") as f: for line in f: if not line.strip(): continue @@ -44,7 +44,7 @@ def main(): manual_labels = {} for mf in manual_files: try: - with open(mf, "r") as f: + with open(mf, "r", encoding="utf-8") as f: data = json.load(f) filename = data.get("filename") if filename: diff --git a/backend/compile_json.py b/backend/compile_json.py index 33aab02..4fc56f8 100644 --- a/backend/compile_json.py +++ b/backend/compile_json.py @@ -23,7 +23,7 @@ def main(): for mf in sorted(manual_files): try: - with open(mf, "r") as f: + with open(mf, "r", encoding="utf-8") as f: data = json.load(f) manual_list.append(data) except Exception as e: diff --git a/backend/fix_encoding_chars.py b/backend/fix_encoding_chars.py new file mode 100644 index 0000000..118f987 --- /dev/null +++ b/backend/fix_encoding_chars.py @@ -0,0 +1,33 @@ +import os +import glob + +def main(): + uploads_dir = "backend/uploads" + if not os.path.exists(uploads_dir): + uploads_dir = "uploads" + + manual_pattern = os.path.join(uploads_dir, "manual_label_*.json") + manual_files = glob.glob(manual_pattern) + fixed_count = 0 + + for mf in manual_files: + try: + with open(mf, "r", encoding="utf-8") as f: + content = f.read() + + if "✓" in content: + # Replace with the correct checkmark character + content = content.replace("✓", "✓") + + with open(mf, "w", encoding="utf-8") as f: + f.write(content) + + print(f"Fixed encoding corruption in: {mf}") + fixed_count += 1 + except Exception as e: + print(f"Error fixing {mf}: {e}") + + print(f"Encoding fix completed. Files fixed: {fixed_count}") + +if __name__ == "__main__": + main() diff --git a/backend/fix_store_labels.py b/backend/fix_store_labels.py index 923d72e..9ee9803 100644 --- a/backend/fix_store_labels.py +++ b/backend/fix_store_labels.py @@ -17,7 +17,7 @@ def main(): for mf in manual_files: try: - with open(mf, "r") as f: + with open(mf, "r", encoding="utf-8") as f: data = json.load(f) is_modified = False diff --git a/backend/pfm-web-app/public/comparison_report.xlsx b/backend/pfm-web-app/public/comparison_report.xlsx index 0e6cd0b..84fd945 100644 Binary files a/backend/pfm-web-app/public/comparison_report.xlsx and b/backend/pfm-web-app/public/comparison_report.xlsx differ diff --git a/backend/pfm-web-app/src/app/api/manual-images/route.ts b/backend/pfm-web-app/src/app/api/manual-images/route.ts index fd74b47..e44deca 100644 --- a/backend/pfm-web-app/src/app/api/manual-images/route.ts +++ b/backend/pfm-web-app/src/app/api/manual-images/route.ts @@ -1,38 +1,22 @@ import { NextResponse } from "next/server"; - -const testFiles = [ - "1782870899198-sample_do.jpeg", - "1782872141829-rotated_1782872118246_rotated_1782872112296_rotated_1782872107513_CAP3481952560331460805.jpg", - "1782875271815-rotated_1782875258464_rotated_1782875254091_rotated_1782875250123_CAP1599226410575173446.jpg", - "1782884664859-rotated_1782884661516_rotated_1782884658097_rotated_1782884654697_CAP5956452738616729026.jpg", - "1782888127716-CAP6161747431193129837.jpg", - "1782888211457-rotated_1782888204591_rotated_1782888199962_rotated_1782888195402_CAP7202641176939787142.jpg", - "1782888609885-rotated_1782888593813_1000000454.jpg", - "1782890303600-1000000465.jpg", - "1782892728794-1000000466.jpg", - "1782909791970-sample_do.jpeg", - "IMG_20260630_145445.jpg", - "IMG_20260701_134446.jpg", - "IMG_20260701_134504.jpg", - "IMG_20260701_134533.jpg", - "IMG_20260701_134555.jpg", - "IMG_20260701_134555~2.jpg", - "IMG_20260701_134635.jpg", - "IMG_20260701_134636.jpg", - "IMG_20260701_134646.jpg", - "IMG_20260701_134646~2.jpg", - "IMG_20260701_134704.jpg", - "IMG_20260701_134704~2.jpg", - "IMG_20260701_134810.jpg", - "IMG_20260701_134817.jpg", - "IMG_20260701_135900.jpg", - "IMG_20260701_135910.jpg", - "IMG_20260701_135923.jpg", - "IMG_20260701_135938.jpg", - "IMG_20260701_135950.jpg", - "IMG_20260701_140005.jpg" -]; +import fs from "fs"; +import path from "path"; export async function GET() { - return NextResponse.json({ files: testFiles }); + try { + const dirPath = path.join(process.cwd(), "public/test-images"); + if (!fs.existsSync(dirPath)) { + return NextResponse.json({ files: [] }); + } + const files = fs.readdirSync(dirPath).filter(file => { + const ext = path.extname(file).toLowerCase(); + return ext === ".jpg" || ext === ".jpeg" || ext === ".png"; + }); + // Sort files to keep consistent ordering in UI + files.sort(); + return NextResponse.json({ files }); + } catch (error: any) { + console.error("Error reading test-images directory:", error); + return NextResponse.json({ error: error.message }, { status: 500 }); + } } diff --git a/backend/sources/manual_labels.json b/backend/sources/manual_labels.json index 07f970e..d7f2447 100644 --- a/backend/sources/manual_labels.json +++ b/backend/sources/manual_labels.json @@ -114,7 +114,7 @@ "kodeBarang": "21002601", "namaBarang": "Prima Nasi Spicy Chick Sambal Geprek COPY", "banyak": "1 80X", - "jumlah": "6 PAC✓" + "jumlah": "6 PAC✓" } ] }, @@ -338,7 +338,7 @@ "kodeBarang": "11048000", "namaBarang": "BEBEK PARTING-NEW(*)", "banyak": "2 BOX", - "jumlah": "30 PAC ✓" + "jumlah": "30 PAC ✓" } ] },