Layan22 commited on
Commit
8d555e4
Β·
verified Β·
1 Parent(s): edf7492

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -13
app.py CHANGED
@@ -9,7 +9,7 @@ import warnings
9
  warnings.filterwarnings("ignore")
10
 
11
  class PDFSummarizer:
12
- def init(self):
13
  # Use a much faster, lighter model for summarization
14
  self.model_name = "sshleifer/distilbart-cnn-12-6" # Much faster than BART-large
15
  self.device = "cuda" if torch.cuda.is_available() else "cpu"
@@ -156,7 +156,7 @@ class PDFSummarizer:
156
 
157
  # Create statistics
158
  summary_stats = f"""
159
- πŸ“Š Document Statistics:
160
  - Original word count: {word_count:,}
161
  - Original character count: {char_count:,}
162
  - Pages processed: {len(chunks)}
@@ -189,7 +189,8 @@ def summarize_pdf_interface(pdf_file, summary_type):
189
 
190
  except Exception as e:
191
  return f"❌ Error: {str(e)}", "", ""
192
- # Create Gradio interface
 
193
  def create_interface():
194
  with gr.Blocks(
195
  title="πŸ“„ AI PDF Summarizer",
@@ -212,8 +213,8 @@ def create_interface():
212
  Upload any PDF document and get an intelligent summary in seconds!
213
  Perfect for research papers, reports, articles, and books.
214
 
215
- Features:
216
- - ⚑️ Fast processing with BART model
217
  - πŸ“Š Document statistics
218
  - 🎯 Multiple summary lengths
219
  - πŸ” Smart text chunking
@@ -264,15 +265,15 @@ def create_interface():
264
  gr.Markdown("""
265
  ## πŸ’‘ Tips for Best Results:
266
 
267
- - File Quality: Ensure your PDF has selectable text (not just images)
268
- - Length: Works best with documents between 500-10,000 words
269
- - Language: Optimized for English content
270
- - Format: Clean, well-formatted PDFs produce better summaries
271
 
272
  ## πŸ”§ Technical Details:
273
- - Model: Facebook BART-Large-CNN (state-of-the-art summarization)
274
- - Processing: Smart text chunking with overlap prevention
275
- - Speed: GPU-accelerated when available
276
  """)
277
 
278
  # Connect the button to the function
@@ -292,6 +293,6 @@ def create_interface():
292
  return interface
293
 
294
  # Launch the application
295
- if name == "main":
296
  interface = create_interface()
297
  interface.launch()
 
9
  warnings.filterwarnings("ignore")
10
 
11
  class PDFSummarizer:
12
+ def __init__(self):
13
  # Use a much faster, lighter model for summarization
14
  self.model_name = "sshleifer/distilbart-cnn-12-6" # Much faster than BART-large
15
  self.device = "cuda" if torch.cuda.is_available() else "cpu"
 
156
 
157
  # Create statistics
158
  summary_stats = f"""
159
+ πŸ“Š **Document Statistics:**
160
  - Original word count: {word_count:,}
161
  - Original character count: {char_count:,}
162
  - Pages processed: {len(chunks)}
 
189
 
190
  except Exception as e:
191
  return f"❌ Error: {str(e)}", "", ""
192
+
193
+ # Create Gradio interface
194
  def create_interface():
195
  with gr.Blocks(
196
  title="πŸ“„ AI PDF Summarizer",
 
213
  Upload any PDF document and get an intelligent summary in seconds!
214
  Perfect for research papers, reports, articles, and books.
215
 
216
+ **Features:**
217
+ - ⚑ Fast processing with BART model
218
  - πŸ“Š Document statistics
219
  - 🎯 Multiple summary lengths
220
  - πŸ” Smart text chunking
 
265
  gr.Markdown("""
266
  ## πŸ’‘ Tips for Best Results:
267
 
268
+ - **File Quality**: Ensure your PDF has selectable text (not just images)
269
+ - **Length**: Works best with documents between 500-10,000 words
270
+ - **Language**: Optimized for English content
271
+ - **Format**: Clean, well-formatted PDFs produce better summaries
272
 
273
  ## πŸ”§ Technical Details:
274
+ - **Model**: Facebook BART-Large-CNN (state-of-the-art summarization)
275
+ - **Processing**: Smart text chunking with overlap prevention
276
+ - **Speed**: GPU-accelerated when available
277
  """)
278
 
279
  # Connect the button to the function
 
293
  return interface
294
 
295
  # Launch the application
296
+ if __name__ == "__main__":
297
  interface = create_interface()
298
  interface.launch()