Flo161 commited on
Commit
f5cc285
·
1 Parent(s): e41304e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -82,15 +82,17 @@ if uploaded_file is not None:
82
  summary = summarizer(paragraph, max_length=(len(paragraph) / 2), min_length=10, do_sample=False)
83
  summary_text = add_line_breaks_to_summary(summary[0]['summary_text'], 70)
84
 
 
 
 
 
 
 
 
 
85
  # Create a slide
86
  slide = prs.slides.add_slide(prs.slide_layouts[5])
87
 
88
- # Add the image to the slide at the bottom
89
- left = Inches(1)
90
- top = Inches(2)
91
- width = height = Inches(5)
92
- pic = slide.shapes.add_picture(temp_img_path, left, top, width, height)
93
-
94
  # Add the paragraph to the slide at the top
95
  left = top = Inches(1)
96
  width = Inches(5)
@@ -103,6 +105,12 @@ if uploaded_file is not None:
103
  p = tf.add_paragraph()
104
  p.text = summary_text
105
 
 
 
 
 
 
 
106
  i += 1
107
 
108
  # Save the PowerPoint presentation
 
82
  summary = summarizer(paragraph, max_length=(len(paragraph) / 2), min_length=10, do_sample=False)
83
  summary_text = add_line_breaks_to_summary(summary[0]['summary_text'], 70)
84
 
85
+ # Generate and save the image to a temporary file
86
+ image_bytes = query({
87
+ "inputs": 'A picture without text about: ' + summary[0]['summary_text']
88
+ })
89
+ temp_img_path = tempfile.NamedTemporaryFile(delete=False, suffix=".png").name
90
+ with open(temp_img_path, "wb") as img_file:
91
+ img_file.write(image_bytes)
92
+
93
  # Create a slide
94
  slide = prs.slides.add_slide(prs.slide_layouts[5])
95
 
 
 
 
 
 
 
96
  # Add the paragraph to the slide at the top
97
  left = top = Inches(1)
98
  width = Inches(5)
 
105
  p = tf.add_paragraph()
106
  p.text = summary_text
107
 
108
+ # Add the image to the slide at the bottom
109
+ left = Inches(1)
110
+ top = Inches(2)
111
+ width = height = Inches(5)
112
+ pic = slide.shapes.add_picture(temp_img_path, left, top, width, height)
113
+
114
  i += 1
115
 
116
  # Save the PowerPoint presentation