Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,9 @@ from io import BytesIO
|
|
6 |
from PIL import Image
|
7 |
from transformers import pipeline
|
8 |
|
|
|
|
|
|
|
9 |
# Define maximum dimensions for the fortune image (in pixels)
|
10 |
MAX_SIZE = (400, 400)
|
11 |
|
@@ -34,16 +37,16 @@ if "stick_clicked" not in st.session_state:
|
|
34 |
|
35 |
# Update the check functions to use the "question" parameter properly.
|
36 |
def check_sentence_is_english_model(question):
|
37 |
-
|
38 |
# If the model predicts the label "en", we consider it English.
|
39 |
-
if
|
40 |
return True
|
41 |
return False
|
42 |
|
43 |
def check_sentence_is_question_model(question):
|
44 |
-
|
45 |
# If the model predicts "LABEL_1", we consider it a question.
|
46 |
-
if
|
47 |
return True
|
48 |
return False
|
49 |
|
|
|
6 |
from PIL import Image
|
7 |
from transformers import pipeline
|
8 |
|
9 |
+
pipe1 = pipeline("text-classification", model="papluca/xlm-roberta-base-language-detection")
|
10 |
+
pipe2 = pipeline("text-classification", model="shahrukhx01/question-vs-statement-classifier")
|
11 |
+
|
12 |
# Define maximum dimensions for the fortune image (in pixels)
|
13 |
MAX_SIZE = (400, 400)
|
14 |
|
|
|
37 |
|
38 |
# Update the check functions to use the "question" parameter properly.
|
39 |
def check_sentence_is_english_model(question):
|
40 |
+
globals pipe1
|
41 |
# If the model predicts the label "en", we consider it English.
|
42 |
+
if pipe1(question)[0]['label'] == 'en':
|
43 |
return True
|
44 |
return False
|
45 |
|
46 |
def check_sentence_is_question_model(question):
|
47 |
+
globals pipe1
|
48 |
# If the model predicts "LABEL_1", we consider it a question.
|
49 |
+
if pipe2(question)[0]['label'] == 'LABEL_1':
|
50 |
return True
|
51 |
return False
|
52 |
|