Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,20 @@
|
|
1 |
-
from pptx import Presentation
|
2 |
-
import re
|
3 |
import gradio as gr
|
4 |
-
from transformers import
|
5 |
import torch
|
6 |
import torch.nn.functional as F
|
7 |
|
8 |
-
# Load the pre-trained model and tokenizer
|
|
|
|
|
|
|
9 |
tokenizer = AutoTokenizer.from_pretrained("Ahmed235/roberta_classification")
|
10 |
-
|
11 |
device = torch.device("cpu")
|
12 |
model = model.to(device) # Move the model to the CPU
|
13 |
|
14 |
def extract_text_from_pptx(file_path):
|
15 |
-
|
16 |
-
|
17 |
-
for slide_number, slide in enumerate(presentation.slides, start=1):
|
18 |
-
for shape in slide.shapes:
|
19 |
-
if hasattr(shape, "text"):
|
20 |
-
text.append(shape.text)
|
21 |
-
return "\n".join(text)
|
22 |
|
23 |
def predict_pptx_content(file_path):
|
24 |
try:
|
@@ -62,4 +58,4 @@ iface = gr.Interface(
|
|
62 |
)
|
63 |
|
64 |
# Deploy the Gradio interface
|
65 |
-
iface.launch(share=True)
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
3 |
import torch
|
4 |
import torch.nn.functional as F
|
5 |
|
6 |
+
# Load the pre-trained model and tokenizer using gr.load
|
7 |
+
model = gr.load("models/Ahmed235/roberta_classification")
|
8 |
+
|
9 |
+
# Tokenizer can be loaded using transformers directly
|
10 |
tokenizer = AutoTokenizer.from_pretrained("Ahmed235/roberta_classification")
|
11 |
+
|
12 |
device = torch.device("cpu")
|
13 |
model = model.to(device) # Move the model to the CPU
|
14 |
|
15 |
def extract_text_from_pptx(file_path):
|
16 |
+
# Assume your implementation for text extraction remains the same
|
17 |
+
pass
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
def predict_pptx_content(file_path):
|
20 |
try:
|
|
|
58 |
)
|
59 |
|
60 |
# Deploy the Gradio interface
|
61 |
+
iface.launch(share=True)
|