Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import fitz # PyMuPDF
|
| 3 |
-
from transformers import AutoTokenizer,
|
| 4 |
|
| 5 |
# Load model directly
|
| 6 |
model_name = "openai-community/gpt2"
|
| 7 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 8 |
-
model =
|
| 9 |
|
| 10 |
# Function to extract text from PDF
|
| 11 |
def extract_text_from_pdf(pdf_file):
|
|
@@ -42,7 +42,7 @@ def generate_mcqs(text_chunks, num_questions=5):
|
|
| 42 |
question = question_part.split("Options:")[0].strip()
|
| 43 |
options_part = question_part.split("Options:")[1].strip()
|
| 44 |
options = options_part.split("\n")
|
| 45 |
-
|
| 46 |
# Ensure four options
|
| 47 |
if len(options) < 4:
|
| 48 |
continue
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import fitz # PyMuPDF
|
| 3 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
|
| 4 |
|
| 5 |
# Load model directly
|
| 6 |
model_name = "openai-community/gpt2"
|
| 7 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 8 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
| 9 |
|
| 10 |
# Function to extract text from PDF
|
| 11 |
def extract_text_from_pdf(pdf_file):
|
|
|
|
| 42 |
question = question_part.split("Options:")[0].strip()
|
| 43 |
options_part = question_part.split("Options:")[1].strip()
|
| 44 |
options = options_part.split("\n")
|
| 45 |
+
|
| 46 |
# Ensure four options
|
| 47 |
if len(options) < 4:
|
| 48 |
continue
|