credent007 commited on
Commit
9e66763
·
verified ·
1 Parent(s): 6c30bf9

Delete json_handling.py

Browse files
Files changed (1) hide show
  1. json_handling.py +0 -75
json_handling.py DELETED
@@ -1,75 +0,0 @@
1
- # import torch
2
- # from model_loader import model, processor, device
3
- # from processor_utils import load_input
4
- # from prompt import get_prompt
5
- # from inference import process_document
6
- # import json
7
-
8
- # # def process_whole_doc(file_path):
9
- # # images = load_input(file_path)
10
- # # complete_json = {}
11
- # # for image in images:
12
- # # json = process_documents(image)
13
- # # def process_whole_doc(file_path):
14
- # # images = load_input(file_path)
15
- # # complete_json = {}
16
-
17
- # # for image in images:
18
- # # partial_json = process_document(image)
19
-
20
- # # for part_name, part_value in partial_json.items():
21
-
22
- # # # Ensure structure exists
23
- # # if part_name not in complete_json:
24
- # # complete_json[part_name] = [{}]
25
-
26
- # # if not complete_json[part_name]:
27
- # # complete_json[part_name].append({})
28
-
29
- # # # Merge data
30
- # # if isinstance(part_value, list) and part_value:
31
- # # complete_json[part_name][0].update(part_value[0])
32
-
33
- # # return complete_json
34
-
35
- # def process_whole_doc(file_path):
36
- # images = load_input(file_path)
37
-
38
- # complete_json = "["
39
- # first = True
40
-
41
- # for image in images:
42
- # partial_json = process_document(image) # returns string
43
-
44
- # if not first:
45
- # complete_json += ","
46
- # complete_json += partial_json
47
- # first = False
48
-
49
- # complete_json += "]"
50
-
51
- # return complete_json
52
- # # complete_json = ""
53
-
54
-
55
- # # # PART_NAME = "PART-1 - BILL OF ENTRY SUMMARY" # you can change per doc type
56
- # # for i, image in enumerate(images, start=1):
57
- # # partial_json = process_document(image)
58
- # # # print(partial_json)
59
- # # complete_json = complete_json+partial_json
60
- # # # # 🔹 Extract only "result"
61
- # # # result_data = partial_json.get("result", {})
62
- # # # page_key = f"Page {i}"
63
- # # # Ensure structure exists
64
- # # # # if PART_NAME not in complete_json:
65
- # # # complete_json[] = [{}]
66
-
67
- # # # if not complete_json[PART_NAME]:
68
- # # # complete_json[PART_NAME].append({})
69
-
70
- # # # ✅ Merge directly
71
- # # # complete_json[page_key]=result_data
72
-
73
- # # return complete_json
74
-
75
-