Ahmed235 commited on
Commit
1aa90a2
·
verified ·
1 Parent(s): 067fd4b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -2
app.py CHANGED
@@ -16,8 +16,29 @@ def extract_text_from_pptx(file_path):
16
  return "\n".join(text)
17
 
18
  def predict_pptx_content(file_path):
19
- extracted_text = extract_text_from_pptx(file_path)
20
- cleaned_text = re.sub(r'\s+', ' ', extracted_text)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  classifier = pipeline("text-classification", model="Ahmed235/roberta_classification")
23
  #summarizer = pipeline("summarization", model="Falconsai/text_summarization")
 
16
  return "\n".join(text)
17
 
18
  def predict_pptx_content(file_path):
19
+ print(f"File path received: {file_path}")
20
+ try:
21
+ extracted_text = extract_text_from_pptx(file_path)
22
+ cleaned_text = re.sub(r'\s+', ' ', extracted_text)
23
+
24
+ classifier = pipeline("text-classification", model="Ahmed235/roberta_classification")
25
+ #summarizer = pipeline("summarization", model="Falconsai/text_summarization")
26
+
27
+ result = classifier(cleaned_text)[0]
28
+ predicted_label = result['label']
29
+ predicted_probability = result['score']
30
+
31
+ prediction = {
32
+ "Predicted Label": predicted_label,
33
+ "Evaluation": f"Evaluate the topic according to {predicted_label} is: {predicted_probability}"
34
+ #"Summary": summarizer(cleaned_text, max_length=80, min_length=30, do_sample=False)
35
+ }
36
+
37
+ return prediction
38
+ except Exception as e:
39
+ print(f"Error processing file: {e}")
40
+ return {"error": str(e)}
41
+
42
 
43
  classifier = pipeline("text-classification", model="Ahmed235/roberta_classification")
44
  #summarizer = pipeline("summarization", model="Falconsai/text_summarization")