Update app.py
Browse files
app.py
CHANGED
|
@@ -3,13 +3,28 @@ import gradio as gr
|
|
| 3 |
from transformers import pipeline
|
| 4 |
from pptx import Presentation
|
| 5 |
from pptx.util import Inches
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
# Chargement du modèle IA depuis Hugging Face
|
| 8 |
text_to_presentation = pipeline("text-generation", model="your-model-on-huggingface")
|
| 9 |
|
| 10 |
def generate_presentation(text):
|
|
|
|
|
|
|
|
|
|
| 11 |
# Analyse du texte avec le modèle IA
|
| 12 |
-
presentation_content = text_to_presentation(
|
| 13 |
|
| 14 |
# Génération de la présentation PowerPoint
|
| 15 |
prs = Presentation()
|
|
|
|
| 3 |
from transformers import pipeline
|
| 4 |
from pptx import Presentation
|
| 5 |
from pptx.util import Inches
|
| 6 |
+
python
|
| 7 |
+
|
| 8 |
+
# Préprompt pour donner des instructions au modèle
|
| 9 |
+
PREPROMPT = """Vous êtes un assistant IA chargé de générer une présentation PowerPoint à partir d'un texte fourni par un utilisateur. Voici les instructions à suivre :
|
| 10 |
+
|
| 11 |
+
- Analysez attentivement le texte pour en comprendre les idées principales et la structure.
|
| 12 |
+
- Générez des titres et sous-titres pertinents pour chaque diapositive.
|
| 13 |
+
- Résumez les points clés sous forme de listes à puces.
|
| 14 |
+
- Ajoutez du texte explicatif pour chaque diapositive afin de compléter le contenu.
|
| 15 |
+
- Assurez-vous que la présentation soit cohérente, logique et visuellement attractive.
|
| 16 |
+
|
| 17 |
+
Voici le texte à transformer en présentation :"""
|
| 18 |
|
| 19 |
# Chargement du modèle IA depuis Hugging Face
|
| 20 |
text_to_presentation = pipeline("text-generation", model="your-model-on-huggingface")
|
| 21 |
|
| 22 |
def generate_presentation(text):
|
| 23 |
+
# Ajout du préprompt au texte de l'utilisateur
|
| 24 |
+
full_prompt = PREPROMPT + "\n\n" + text
|
| 25 |
+
|
| 26 |
# Analyse du texte avec le modèle IA
|
| 27 |
+
presentation_content = text_to_presentation(full_prompt, max_length=1500, num_return_sequences=1)[0]["generated_text"]
|
| 28 |
|
| 29 |
# Génération de la présentation PowerPoint
|
| 30 |
prs = Presentation()
|