yannESGI commited on
Commit
39beaa6
·
1 Parent(s): 636ebd4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -10
app.py CHANGED
@@ -4,6 +4,7 @@ import shutil
4
  import tempfile
5
  import base64
6
  from pptx import Presentation
 
7
  import streamlit as st
8
  import fitz
9
  from transformers import pipeline
@@ -85,14 +86,22 @@ if uploaded_file is not None:
85
  title = slide.shapes.title
86
  title.text = f"Résumé du Paragraphe {i + 1}"
87
 
88
- left = prs.slide_width * 0.1
89
- top = prs.slide_height * 0.6
90
- width = prs.slide_width * 0.8
91
- height = prs.slide_height * 0.3
92
- txBox = slide.shapes.add_textbox(left, top, width, height)
93
- tf = txBox.text_frame
94
- p = tf.add_paragraph()
95
- p.text = summary[0]['summary_text']
 
 
 
 
 
 
 
 
96
 
97
  #st.text(f"Paragraphe {i}: {summary[0]['summary_text']}") # Affiche le résumé du paragraphe
98
 
@@ -100,8 +109,33 @@ if uploaded_file is not None:
100
  "inputs": 'A picture about :' + summary[0]['summary_text'] # Utilisez le texte du résumé
101
  })
102
  image = Image.open(io.BytesIO(image_bytes))
103
- left = top = prs.slide_width * 0.1
104
- pic = slide.shapes.add_picture(io.BytesIO(image_bytes), left, top, width=prs.slide_width * 0.8)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
 
106
  # st.image(image)
107
 
 
4
  import tempfile
5
  import base64
6
  from pptx import Presentation
7
+ from pptx.util import Inches
8
  import streamlit as st
9
  import fitz
10
  from transformers import pipeline
 
86
  title = slide.shapes.title
87
  title.text = f"Résumé du Paragraphe {i + 1}"
88
 
89
+ slide_width = prs.slide_width
90
+ slide_height = prs.slide_height
91
+
92
+ image_width = slide_width * 0.7 # L'image occupe 70% de la largeur de la slide
93
+ image_height = slide_height * 0.7 # L'image occupe 70% de la hauteur de la slide
94
+ left_img = (slide_width - image_width) / 2 # Centrez horizontalement
95
+ top_img = (slide_height - image_height) * 0.15 # Occupe 15% de la hauteur en haut de la slide
96
+
97
+ #left = prs.slide_width * 0.1
98
+ #top = prs.slide_height * 0.6
99
+ #width = prs.slide_width * 0.8
100
+ #height = prs.slide_height * 0.3
101
+ #txBox = slide.shapes.add_textbox(left, top, width, height)
102
+ #tf = txBox.text_frame
103
+ #p = tf.add_paragraph()
104
+ #p.text = summary[0]['summary_text']
105
 
106
  #st.text(f"Paragraphe {i}: {summary[0]['summary_text']}") # Affiche le résumé du paragraphe
107
 
 
109
  "inputs": 'A picture about :' + summary[0]['summary_text'] # Utilisez le texte du résumé
110
  })
111
  image = Image.open(io.BytesIO(image_bytes))
112
+ #left = top = prs.slide_width * 0.1
113
+ pic = slide.shapes.add_picture(io.BytesIO(image_bytes), left_img, top_img, image_width, image_height)
114
+
115
+ title_width = slide_width * 0.7 # Le titre occupe 70% de la largeur de la slide
116
+ title_height = slide_height * 0.15 # Le titre occupe 15% de la hauteur de la slide
117
+ left_title = (slide_width - title_width) / 2 # Centrez horizontalement
118
+ top_title = (slide_height - title_height) * 0.05 # Occupe 5% de la hauteur en haut de la slide
119
+ title = slide.shapes.add_textbox(left_title, top_title, title_width, title_height)
120
+ title_frame = title.text_frame
121
+
122
+ title_p = title_frame.add_paragraph()
123
+ title_p.text = "Paragraphe {i}: "
124
+ title_p.alignment = PP_ALIGN.CENTER # Centrez le texte horizontalement
125
+
126
+ text_width = slide_width * 0.7 # Le texte occupe 70% de la largeur de la slide
127
+ text_height = slide_height * 0.15 # Le texte occupe 15% de la hauteur de la slide
128
+ left_text = (slide_width - text_width) / 2 # Centrez horizontalement
129
+ top_text = slide_height * 0.85 # Occupe 85% de la hauteur en bas de la slide
130
+ txBox = slide.shapes.add_textbox(left_text, top_text, text_width, text_height)
131
+ tf = txBox.text_frame
132
+
133
+ p = tf.add_paragraph()
134
+ p.text = summary
135
+
136
+ p.space_before = Pt(12) # Espace avant le paragraphe (12 points)
137
+ p.space_after = Pt(12) # Espace après le paragraphe (12 points)
138
+ p.alignment = PP_ALIGN.CENTER # Centrez le texte horizontalement
139
 
140
  # st.image(image)
141