Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,10 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import fitz # PyMuPDF
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
# Function to extract text from PDF
|
| 6 |
def extract_text_from_pdf(pdf_file):
|
|
@@ -16,9 +20,6 @@ def generate_mcqs(text, num_questions=5):
|
|
| 16 |
if not text.strip():
|
| 17 |
return ["No text extracted from the PDF. Unable to generate MCQs."]
|
| 18 |
|
| 19 |
-
# Load HuggingFace model
|
| 20 |
-
tokenizer = AutoTokenizer.from_pretrained("openai-community/gpt2-large")
|
| 21 |
-
model = AutoModelForCausalLM.from_pretrained("openai-community/gpt2-large")
|
| 22 |
|
| 23 |
# Tokenize the input text
|
| 24 |
inputs = tokenizer(text, return_tensors="pt", max_length=512, truncation=True)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import fitz # PyMuPDF
|
| 3 |
+
# Load model directly
|
| 4 |
+
from transformers import AutoTokenizer, AutoModelForQuestionAnswering
|
| 5 |
+
|
| 6 |
+
tokenizer = AutoTokenizer.from_pretrained("google-bert/bert-large-cased-whole-word-masking-finetuned-squad")
|
| 7 |
+
model = AutoModelForQuestionAnswering.from_pretrained("google-bert/bert-large-cased-whole-word-masking-finetuned-squad")
|
| 8 |
|
| 9 |
# Function to extract text from PDF
|
| 10 |
def extract_text_from_pdf(pdf_file):
|
|
|
|
| 20 |
if not text.strip():
|
| 21 |
return ["No text extracted from the PDF. Unable to generate MCQs."]
|
| 22 |
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
# Tokenize the input text
|
| 25 |
inputs = tokenizer(text, return_tensors="pt", max_length=512, truncation=True)
|