mkoot007 commited on
Commit
5779ac4
·
1 Parent(s): b9cf8e5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -9
app.py CHANGED
@@ -13,20 +13,12 @@ def extract_text_from_pdf(pdf_content):
13
 
14
 
15
  def generate_summary(file_content):
16
- # Load pre-trained Flan-T5 model
17
  text_generator = pipeline("text2text-generation", model="google/flan-t5-base")
18
-
19
- # Handle PDF files separately
20
  if file_content.type == "application/pdf":
21
  input_text = extract_text_from_pdf(file_content.read())
22
  else:
23
- # Assume text file, directly use the content
24
  input_text = file_content.read().decode("utf-8")
25
-
26
- # Generate summary
27
  summary = text_generator(input_text, max_length=1024, num_beams=4)
28
-
29
- # Return results
30
  return {
31
  "Extracted Information": input_text,
32
  "Book Summary": summary[0]["generated_text"],
@@ -36,7 +28,7 @@ def generate_summary(file_content):
36
 
37
  iface = gr.Interface(
38
  fn=generate_summary,
39
- inputs=gr.File(), # No need to specify max_upload_size
40
  outputs=[
41
  gr.Textbox(),
42
  gr.Textbox(),
 
13
 
14
 
15
  def generate_summary(file_content):
 
16
  text_generator = pipeline("text2text-generation", model="google/flan-t5-base")
 
 
17
  if file_content.type == "application/pdf":
18
  input_text = extract_text_from_pdf(file_content.read())
19
  else:
 
20
  input_text = file_content.read().decode("utf-8")
 
 
21
  summary = text_generator(input_text, max_length=1024, num_beams=4)
 
 
22
  return {
23
  "Extracted Information": input_text,
24
  "Book Summary": summary[0]["generated_text"],
 
28
 
29
  iface = gr.Interface(
30
  fn=generate_summary,
31
+ inputs=gr.File(),
32
  outputs=[
33
  gr.Textbox(),
34
  gr.Textbox(),