Spaces:
Sleeping
Sleeping
fix pdf not loading issue
Browse files- Base-RCNN-FPN.yaml +0 -18
- Final_Insurance_Report.pdf +0 -0
- Final_Service_Centre_Report.pdf +80 -0
- a.py +6 -9
- output.pdf +0 -0
- summary.pdf +0 -0
Base-RCNN-FPN.yaml
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
MODEL:
|
2 |
-
META_ARCHITECTURE: "GeneralizedRCNN"
|
3 |
-
RPN:
|
4 |
-
PRE_NMS_TOPK_TEST: 6000
|
5 |
-
POST_NMS_TOPK_TEST: 1000
|
6 |
-
ROI_HEADS:
|
7 |
-
NAME: "Res5ROIHeads"
|
8 |
-
DATASETS:
|
9 |
-
TRAIN: ("coco_2017_train",)
|
10 |
-
TEST: ("coco_2017_val",)
|
11 |
-
SOLVER:
|
12 |
-
IMS_PER_BATCH: 16
|
13 |
-
BASE_LR: 0.02
|
14 |
-
STEPS: (60000, 80000)
|
15 |
-
MAX_ITER: 90000
|
16 |
-
INPUT:
|
17 |
-
MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800)
|
18 |
-
VERSION: 2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Final_Insurance_Report.pdf
ADDED
Binary file (1.6 kB). View file
|
|
Final_Service_Centre_Report.pdf
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
%PDF-1.3
|
2 |
+
3 0 obj
|
3 |
+
<</Type /Page
|
4 |
+
/Parent 1 0 R
|
5 |
+
/Resources 2 0 R
|
6 |
+
/Contents 4 0 R>>
|
7 |
+
endobj
|
8 |
+
4 0 obj
|
9 |
+
<</Filter /FlateDecode /Length 604>>
|
10 |
+
stream
|
11 |
+
x��SMs�0��W쩓Lc ��c��fZO&xz�E���H�$�q}�N<ʴ7!�}��-�����^/nWp�e$�`����xŀ�gW�e$�!˓���D�"+�9*gq����կI�SB=GBIN�yg�n��R�X@)��½�*��;����#N+'*ˮ}FS�g:�OX�Lx�Mh�������j�f����Ʀ��Z�fU�M
|
12 |
+
uX��P([�0�r��c���!�<%ɘ����6�Q��8&�ﬓ���P�c}���6\��R�A��c�DK���{�����Ўy�s�`����cg��j#�xK��(ߋ�fBD����m��A%�H������Sx
|
13 |
+
endstream
|
14 |
+
endobj
|
15 |
+
1 0 obj
|
16 |
+
<</Type /Pages
|
17 |
+
/Kids [3 0 R ]
|
18 |
+
/Count 1
|
19 |
+
/MediaBox [0 0 595.28 841.89]
|
20 |
+
>>
|
21 |
+
endobj
|
22 |
+
5 0 obj
|
23 |
+
<</Type /Font
|
24 |
+
/BaseFont /Helvetica
|
25 |
+
/Subtype /Type1
|
26 |
+
/Encoding /WinAnsiEncoding
|
27 |
+
>>
|
28 |
+
endobj
|
29 |
+
6 0 obj
|
30 |
+
<</Type /Font
|
31 |
+
/BaseFont /Helvetica-Bold
|
32 |
+
/Subtype /Type1
|
33 |
+
/Encoding /WinAnsiEncoding
|
34 |
+
>>
|
35 |
+
endobj
|
36 |
+
2 0 obj
|
37 |
+
<<
|
38 |
+
/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
|
39 |
+
/Font <<
|
40 |
+
/F1 5 0 R
|
41 |
+
/F2 6 0 R
|
42 |
+
>>
|
43 |
+
/XObject <<
|
44 |
+
>>
|
45 |
+
>>
|
46 |
+
endobj
|
47 |
+
7 0 obj
|
48 |
+
<<
|
49 |
+
/Producer (PyFPDF 1.7.2 http://pyfpdf.googlecode.com/)
|
50 |
+
/CreationDate (D:20250301060254)
|
51 |
+
>>
|
52 |
+
endobj
|
53 |
+
8 0 obj
|
54 |
+
<<
|
55 |
+
/Type /Catalog
|
56 |
+
/Pages 1 0 R
|
57 |
+
/OpenAction [3 0 R /FitH null]
|
58 |
+
/PageLayout /OneColumn
|
59 |
+
>>
|
60 |
+
endobj
|
61 |
+
xref
|
62 |
+
0 9
|
63 |
+
0000000000 65535 f
|
64 |
+
0000000761 00000 n
|
65 |
+
0000001045 00000 n
|
66 |
+
0000000009 00000 n
|
67 |
+
0000000087 00000 n
|
68 |
+
0000000848 00000 n
|
69 |
+
0000000944 00000 n
|
70 |
+
0000001159 00000 n
|
71 |
+
0000001268 00000 n
|
72 |
+
trailer
|
73 |
+
<<
|
74 |
+
/Size 9
|
75 |
+
/Root 8 0 R
|
76 |
+
/Info 7 0 R
|
77 |
+
>>
|
78 |
+
startxref
|
79 |
+
1371
|
80 |
+
%%EOF
|
a.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
import fitz
|
2 |
import requests
|
3 |
from openai import OpenAI
|
4 |
from fpdf import FPDF
|
@@ -25,7 +25,6 @@ def generate_structured_summary(text):
|
|
25 |
base_url="https://openrouter.ai/api/v1",
|
26 |
api_key="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",
|
27 |
)
|
28 |
-
print(text)
|
29 |
prompt = (
|
30 |
"Generate a well-structured professional report from the following text. "
|
31 |
"Include appropriate headings, subheadings, and bullet points, but do NOT include any instructions on converting the output into a PDF or formatting recommendations.Dont add conclusion"
|
@@ -41,12 +40,11 @@ def generate_structured_summary(text):
|
|
41 |
]
|
42 |
)
|
43 |
if completion.choices[0].message.content:
|
44 |
-
return completion.choices[0].message.content
|
45 |
return completion.choices[0].message.content
|
46 |
|
47 |
|
48 |
def save_structured_pdf(structured_text, output_pdf):
|
49 |
-
print(structured_text)
|
50 |
"""Save the structured text into a well-formatted PDF file using FPDF."""
|
51 |
pdf = FPDF()
|
52 |
pdf.set_auto_page_break(auto=True, margin=15)
|
@@ -69,8 +67,8 @@ def upload_to_cloudinary(file_path):
|
|
69 |
)
|
70 |
|
71 |
upload_result = cloudinary.uploader.upload(
|
72 |
-
"output.pdf", resource_type="
|
73 |
-
type="upload",
|
74 |
access_mode="public")
|
75 |
print(upload_result)
|
76 |
return upload_result.get("secure_url")
|
@@ -78,8 +76,8 @@ def upload_to_cloudinary(file_path):
|
|
78 |
|
79 |
def main(pdf1_url, pdf2_url, output_pdf):
|
80 |
"""Download, extract, summarize, and save summaries in a structured format to a PDF, then upload it."""
|
81 |
-
pdf1_path = "
|
82 |
-
pdf2_path = "
|
83 |
|
84 |
download_pdf(pdf1_url, pdf1_path)
|
85 |
download_pdf(pdf2_url, pdf2_path)
|
@@ -94,7 +92,6 @@ def main(pdf1_url, pdf2_url, output_pdf):
|
|
94 |
save_structured_pdf(full_summary, output_pdf)
|
95 |
print(f"Structured summaries saved to {output_pdf}")
|
96 |
|
97 |
-
# Upload to Cloudinary
|
98 |
pdf_url = upload_to_cloudinary(output_pdf)
|
99 |
print(f"PDF uploaded to: {pdf_url}")
|
100 |
return pdf_url
|
|
|
1 |
+
import fitz
|
2 |
import requests
|
3 |
from openai import OpenAI
|
4 |
from fpdf import FPDF
|
|
|
25 |
base_url="https://openrouter.ai/api/v1",
|
26 |
api_key="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",
|
27 |
)
|
|
|
28 |
prompt = (
|
29 |
"Generate a well-structured professional report from the following text. "
|
30 |
"Include appropriate headings, subheadings, and bullet points, but do NOT include any instructions on converting the output into a PDF or formatting recommendations.Dont add conclusion"
|
|
|
40 |
]
|
41 |
)
|
42 |
if completion.choices[0].message.content:
|
43 |
+
return completion.choices[0].message.content
|
44 |
return completion.choices[0].message.content
|
45 |
|
46 |
|
47 |
def save_structured_pdf(structured_text, output_pdf):
|
|
|
48 |
"""Save the structured text into a well-formatted PDF file using FPDF."""
|
49 |
pdf = FPDF()
|
50 |
pdf.set_auto_page_break(auto=True, margin=15)
|
|
|
67 |
)
|
68 |
|
69 |
upload_result = cloudinary.uploader.upload(
|
70 |
+
"output.pdf", resource_type="image",
|
71 |
+
type="upload",
|
72 |
access_mode="public")
|
73 |
print(upload_result)
|
74 |
return upload_result.get("secure_url")
|
|
|
76 |
|
77 |
def main(pdf1_url, pdf2_url, output_pdf):
|
78 |
"""Download, extract, summarize, and save summaries in a structured format to a PDF, then upload it."""
|
79 |
+
pdf1_path = "Final_Insurance_Report.pdf"
|
80 |
+
pdf2_path = "Final_Service_Centre_Report.pdf"
|
81 |
|
82 |
download_pdf(pdf1_url, pdf1_path)
|
83 |
download_pdf(pdf2_url, pdf2_path)
|
|
|
92 |
save_structured_pdf(full_summary, output_pdf)
|
93 |
print(f"Structured summaries saved to {output_pdf}")
|
94 |
|
|
|
95 |
pdf_url = upload_to_cloudinary(output_pdf)
|
96 |
print(f"PDF uploaded to: {pdf_url}")
|
97 |
return pdf_url
|
output.pdf
ADDED
Binary file (1.89 kB). View file
|
|
summary.pdf
ADDED
Binary file (1.55 kB). View file
|
|