Ahmed235 commited on
Commit
2bb61b8
·
verified ·
1 Parent(s): d4d72ff

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # inference.py
2
+
3
+ from pptx import Presentation
4
+ import re
5
+ from transformers import pipeline
6
+
7
+ def extract_text_from_pptx(file_path):
8
+ presentation = Presentation(file_path)
9
+
10
+ text = []
11
+ for slide_number, slide in enumerate(presentation.slides, start=1):
12
+ for shape in slide.shapes:
13
+ if hasattr(shape, "text"):
14
+ text.append(shape.text)
15
+
16
+ return "\n".join(text)
17
+
18
+ def main():
19
+ file_path = "path/to/your/powerpoint.pptx" # Specify the path to your PowerPoint file
20
+
21
+ extracted_text = extract_text_from_pptx(file_path)
22
+ cleaned_text = re.sub(r'\s+', ' ', extracted_text)
23
+
24
+ print(cleaned_text)
25
+
26
+ classifier = pipeline("text-classification", model="Ahmed235/roberta_classification")
27
+ summarizer = pipeline("summarization", model="Falconsai/text_summarization")
28
+
29
+ result = classifier(cleaned_text)[0]
30
+ predicted_label = result['label']
31
+ predicted_probability = result['score']
32
+
33
+ print("Predicted Label:", predicted_label)
34
+ print(f"Evaluate the topic according to {predicted_label} is: {predicted_probability}")
35
+ print(summarizer(cleaned_text, max_length=80, min_length=30, do_sample=False))
36
+
37
+ if __name__ == "__main__":
38
+ main()