Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,12 +2,11 @@ from fastapi import FastAPI
|
|
| 2 |
from pydantic import BaseModel
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
-
# Load AI Model for Question Extraction
|
| 6 |
-
question_extractor = pipeline("text-classification", model="
|
| 7 |
|
| 8 |
app = FastAPI()
|
| 9 |
|
| 10 |
-
# Define API Input Format
|
| 11 |
class OCRText(BaseModel):
|
| 12 |
text: str
|
| 13 |
|
|
@@ -16,7 +15,6 @@ def extract_question(data: OCRText):
|
|
| 16 |
text = data.text
|
| 17 |
lines = text.split("\n")
|
| 18 |
|
| 19 |
-
# Use AI Model to Identify Question Parts
|
| 20 |
ranked_lines = sorted(lines, key=lambda line: question_extractor(line)[0]['score'], reverse=True)
|
| 21 |
top_sentences = [line for line in ranked_lines[:3] if len(line) > 10] # Keep Top 3 Sentences
|
| 22 |
|
|
|
|
| 2 |
from pydantic import BaseModel
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
+
# Load AI Model for Question Extraction from Local Model Folder
|
| 6 |
+
question_extractor = pipeline("text-classification", model="./model")
|
| 7 |
|
| 8 |
app = FastAPI()
|
| 9 |
|
|
|
|
| 10 |
class OCRText(BaseModel):
|
| 11 |
text: str
|
| 12 |
|
|
|
|
| 15 |
text = data.text
|
| 16 |
lines = text.split("\n")
|
| 17 |
|
|
|
|
| 18 |
ranked_lines = sorted(lines, key=lambda line: question_extractor(line)[0]['score'], reverse=True)
|
| 19 |
top_sentences = [line for line in ranked_lines[:3] if len(line) > 10] # Keep Top 3 Sentences
|
| 20 |
|