Spaces:
Runtime error
Runtime error
Delete app.py
Browse files
app.py
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import pytesseract
|
3 |
-
from PIL import Image
|
4 |
-
from transformers import pipeline
|
5 |
-
|
6 |
-
# Load the pre-trained model for question generation
|
7 |
-
generator = pipeline("text2text-generation", model="t5-small")
|
8 |
-
|
9 |
-
# Function to process image and generate questions
|
10 |
-
def generate_questions(image):
|
11 |
-
# Step 1: Extract text from the image using pytesseract
|
12 |
-
text = pytesseract.image_to_string(image)
|
13 |
-
|
14 |
-
# Step 2: Use the T5 model to generate questions from the text
|
15 |
-
prompt = f"Generate multiple-choice questions based on the following text:\n{text}"
|
16 |
-
questions = generator(prompt, max_length=150, num_return_sequences=1)
|
17 |
-
|
18 |
-
# Return the generated questions
|
19 |
-
return questions[0]['generated_text']
|
20 |
-
|
21 |
-
# Create the Gradio interface
|
22 |
-
iface = gr.Interface(
|
23 |
-
fn=generate_questions,
|
24 |
-
inputs=gr.Image(type="pil", label="Upload Image"),
|
25 |
-
outputs=gr.Textbox(label="Generated Question Paper"),
|
26 |
-
title="Image to Question Paper Generator",
|
27 |
-
description="Upload images containing text, and this tool will generate a question paper based on the text found in the images."
|
28 |
-
)
|
29 |
-
|
30 |
-
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|