Ahmed235 commited on
Commit
09ca2da
·
verified ·
1 Parent(s): bbeaa3a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -2,9 +2,11 @@ import gradio as gr
2
  from transformers import pipeline
3
  from pptx import Presentation # Import the Presentation class
4
  import re
 
5
  # Create a text classification pipeline
6
  classifier = pipeline("text-classification", model="Ahmed235/roberta_classification", tokenizer="Ahmed235/roberta_classification")
7
  summarizer = pipeline("summarization", model="Falconsai/text_summarization")
 
8
  def extract_text_from_pptx(file_path):
9
  presentation = Presentation(file_path)
10
  text = []
@@ -25,8 +27,9 @@ def predict_pptx_content(file_path):
25
  predicted_probability = result[0]['score']
26
  summary = summarizer(extracted_text, max_length=80, min_length=30, do_sample=False)[0]['summary_text']
27
  prediction = {
 
28
  "Evaluation": f"Evaluate the topic according to {predicted_label} is: {predicted_probability}",
29
- "Summary": summary
30
  }
31
 
32
  return prediction
@@ -40,7 +43,7 @@ def predict_pptx_content(file_path):
40
  iface = gr.Interface(
41
  fn=predict_pptx_content,
42
  inputs=gr.File(type="filepath", label="Upload PowerPoint (.pptx) file"),
43
- outputs=["text"], # Predicted Label, Evaluation
44
  live=False, # Change to True for one-time analysis
45
  title="<h1 style='color: lightgreen; text-align: center;'>HackTalk Analyzer</h1>",
46
  )
 
2
  from transformers import pipeline
3
  from pptx import Presentation # Import the Presentation class
4
  import re
5
+
6
  # Create a text classification pipeline
7
  classifier = pipeline("text-classification", model="Ahmed235/roberta_classification", tokenizer="Ahmed235/roberta_classification")
8
  summarizer = pipeline("summarization", model="Falconsai/text_summarization")
9
+
10
  def extract_text_from_pptx(file_path):
11
  presentation = Presentation(file_path)
12
  text = []
 
27
  predicted_probability = result[0]['score']
28
  summary = summarizer(extracted_text, max_length=80, min_length=30, do_sample=False)[0]['summary_text']
29
  prediction = {
30
+ "Summary": summary,
31
  "Evaluation": f"Evaluate the topic according to {predicted_label} is: {predicted_probability}",
32
+ "Predicted Label": predicted_label,
33
  }
34
 
35
  return prediction
 
43
  iface = gr.Interface(
44
  fn=predict_pptx_content,
45
  inputs=gr.File(type="filepath", label="Upload PowerPoint (.pptx) file"),
46
+ outputs=[gr.Textbox("Summary"), gr.Textbox("Evaluation"), gr.Textbox("Predicted Label")],
47
  live=False, # Change to True for one-time analysis
48
  title="<h1 style='color: lightgreen; text-align: center;'>HackTalk Analyzer</h1>",
49
  )