Spaces:
Running
Running
Delete test_fix.py
Browse files- test_fix.py +0 -55
test_fix.py
DELETED
@@ -1,55 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python3
|
2 |
-
import streamlit as st
|
3 |
-
from ocr_processing import process_file
|
4 |
-
|
5 |
-
# Mock a file upload
|
6 |
-
class MockFile:
|
7 |
-
def __init__(self, name, content):
|
8 |
-
self.name = name
|
9 |
-
self._content = content
|
10 |
-
|
11 |
-
def getvalue(self):
|
12 |
-
return self._content
|
13 |
-
|
14 |
-
def main():
|
15 |
-
# Load the test image - using the problematic image from the original task
|
16 |
-
with open('input/magician-or-bottle-cungerer.jpg', 'rb') as f:
|
17 |
-
file_bytes = f.read()
|
18 |
-
|
19 |
-
# Create mock file
|
20 |
-
uploaded_file = MockFile('magician-or-bottle-cungerer.jpg', file_bytes)
|
21 |
-
|
22 |
-
# Process the file
|
23 |
-
result = process_file(uploaded_file)
|
24 |
-
|
25 |
-
# Display results
|
26 |
-
print("\nDocument Content")
|
27 |
-
print("Title")
|
28 |
-
if 'title' in result['ocr_contents']:
|
29 |
-
print(result['ocr_contents']['title'])
|
30 |
-
|
31 |
-
print("\nMain")
|
32 |
-
if 'main_text' in result['ocr_contents']:
|
33 |
-
print(result['ocr_contents']['main_text'])
|
34 |
-
|
35 |
-
print("\nRaw Text")
|
36 |
-
if 'raw_text' in result['ocr_contents']:
|
37 |
-
print(result['ocr_contents']['raw_text'][:300] + "...")
|
38 |
-
|
39 |
-
# Debug: Print all keys in ocr_contents
|
40 |
-
print("\nAll OCR Content Keys:")
|
41 |
-
for key in result['ocr_contents'].keys():
|
42 |
-
print(f"- {key}")
|
43 |
-
|
44 |
-
# Debug: Display content of all keys
|
45 |
-
print("\nContent of each key:")
|
46 |
-
for key in result['ocr_contents'].keys():
|
47 |
-
print(f"\n--- {key} ---")
|
48 |
-
content = result['ocr_contents'][key]
|
49 |
-
if isinstance(content, str):
|
50 |
-
print(content[:150] + "..." if len(content) > 150 else content)
|
51 |
-
else:
|
52 |
-
print(f"Type: {type(content)}")
|
53 |
-
|
54 |
-
if __name__ == "__main__":
|
55 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|