Update app.py
Browse files
app.py
CHANGED
@@ -1,28 +1,38 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import tensorflow as tf
|
3 |
-
from SpaceGen_preprocessing import *
|
4 |
-
from utils import *
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
#
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import tensorflow as tf
|
3 |
+
from SpaceGen_preprocessing import *
|
4 |
+
from utils import *
|
5 |
+
|
6 |
+
# טוען את המודל
|
7 |
+
model_path = "SpaceGen_Large.keras"
|
8 |
+
model = tf.keras.models.load_model(model_path)
|
9 |
+
|
10 |
+
# פונקציית תיקון רווחים
|
11 |
+
def fix_space(text):
|
12 |
+
text = clean_sentence(text)
|
13 |
+
X = text_to_X(text)
|
14 |
+
predictions = model.predict(X, verbose=0)
|
15 |
+
predicted_labels = []
|
16 |
+
for pred in predictions[0]:
|
17 |
+
predicted_labels.append(1 if pred[1] > .5 else 0)
|
18 |
+
fixed_text = insert_spaces(text.replace(' ',''), find_indices(predicted_labels))
|
19 |
+
return fixed_text
|
20 |
+
|
21 |
+
default_text = "T hel ittlegi rlra nthro ughth epa rkc has ing abut terfly."
|
22 |
+
|
23 |
+
description = (
|
24 |
+
"פרויקט לימודי במדעי הנתונים ומדעי המוח.\n"
|
25 |
+
"המערכת מדגימה שימוש ברשת LSTM לזיהוי מיקום רווחים חסרים בטקסט.\n"
|
26 |
+
"נכון לעכשיו, המודל תומך באנגלית בלבד.\n"
|
27 |
+
"לשאלות וביקורות: [email protected]"
|
28 |
+
)
|
29 |
+
|
30 |
+
demo = gr.Interface(
|
31 |
+
fn=fix_space,
|
32 |
+
inputs=gr.Textbox(label="Input Text", value=default_text),
|
33 |
+
outputs="text",
|
34 |
+
title="SpaceGen – Text Space Correction with LSTM",
|
35 |
+
description=description
|
36 |
+
)
|
37 |
+
|
38 |
+
demo.launch()
|