SuriRaja commited on
Commit
df7cb44
·
verified ·
1 Parent(s): 123be7b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import pdfplumber
2
  from transformers import LayoutLMv2Processor, LayoutLMv2ForTokenClassification
3
  import torch
@@ -49,11 +50,14 @@ def process_pdfs(pdf1, pdf2):
49
  except Exception as e:
50
  return f"Error processing PDFs: {e}"
51
 
52
- if __name__ == "__main__":
53
- # Replace this block with code to upload and pass files if running in a web app environment
54
- pdf1_path = "path/to/source.pdf" # Placeholder path
55
- pdf2_path = "path/to/target.pdf" # Placeholder path
56
 
57
- # Process and print differences
58
- result = process_pdfs(pdf1_path, pdf2_path)
59
- print(result)
 
 
 
 
 
1
+ import streamlit as st
2
  import pdfplumber
3
  from transformers import LayoutLMv2Processor, LayoutLMv2ForTokenClassification
4
  import torch
 
50
  except Exception as e:
51
  return f"Error processing PDFs: {e}"
52
 
53
+ # Streamlit UI
54
+ st.title("PDF Comparison Tool")
55
+ st.write("Upload two PDFs to compare their content. The first PDF is treated as the source of truth.")
 
56
 
57
+ pdf1 = st.file_uploader("Upload Source PDF (A)", type=["pdf"])
58
+ pdf2 = st.file_uploader("Upload Target PDF (B)", type=["pdf"])
59
+
60
+ if pdf1 and pdf2:
61
+ with st.spinner("Processing..."):
62
+ result = process_pdfs(pdf1, pdf2)
63
+ st.text_area("Comparison Result", result, height=400)