Spaces:
Runtime error
Runtime error
update
Browse files- .gitignore +1 -0
- app.py +21 -6
- requirements.txt +1 -1
.gitignore
CHANGED
@@ -1,3 +1,4 @@
|
|
1 |
venv
|
|
|
2 |
.headline_detector_model
|
3 |
.word_vectors_cache
|
|
|
1 |
venv
|
2 |
+
flagged
|
3 |
.headline_detector_model
|
4 |
.word_vectors_cache
|
app.py
CHANGED
@@ -8,10 +8,21 @@ model_dict = {
|
|
8 |
"fastText": FasttextDetector
|
9 |
}
|
10 |
|
11 |
-
def process(
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
iface = gr.Interface(
|
17 |
fn=process,
|
@@ -25,8 +36,12 @@ iface = gr.Interface(
|
|
25 |
list(model_dict.keys()),
|
26 |
label="Model",
|
27 |
info="Model Used",
|
28 |
-
max_choices=1
|
29 |
),
|
30 |
-
gr.Radio(
|
|
|
|
|
|
|
|
|
|
|
31 |
], outputs="text")
|
32 |
iface.launch()
|
|
|
8 |
"fastText": FasttextDetector
|
9 |
}
|
10 |
|
11 |
+
def process(text_input, model_name, radio_idx):
|
12 |
+
model: typing.Union[FasttextDetector, IndoBERTweetDetector, CNNDetector] = model_dict[model_name]
|
13 |
+
model = model.load_from_scenario(radio_idx + 1)
|
14 |
+
print([text_input], model_name, radio_idx)
|
15 |
+
test = [
|
16 |
+
"nama kamu siapa?",
|
17 |
+
"Kapolda Jatim Teddy Minahasa Dikabarkan Ditangkap Terkait Narkoba https://t.co/LD9X6VFaUR",
|
18 |
+
"RSUD Abepura Papua Kebakaran, Tiga Orang Dilaporkan Tewas"
|
19 |
+
]
|
20 |
+
results = model.predict_text([text_input])
|
21 |
+
print(results)
|
22 |
+
final_text = "not a headline"
|
23 |
+
if results[0] == 1:
|
24 |
+
final_text = "a headline"
|
25 |
+
return final_text
|
26 |
|
27 |
iface = gr.Interface(
|
28 |
fn=process,
|
|
|
36 |
list(model_dict.keys()),
|
37 |
label="Model",
|
38 |
info="Model Used",
|
|
|
39 |
),
|
40 |
+
gr.Radio(
|
41 |
+
[1, 2, 3, 4, 5, 6],
|
42 |
+
label="Scenario Number",
|
43 |
+
type="index",
|
44 |
+
value=1,
|
45 |
+
)
|
46 |
], outputs="text")
|
47 |
iface.launch()
|
requirements.txt
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
headline-detector
|
2 |
gradio
|
3 |
fastapi>0.95
|
|
|
1 |
+
headline-detector>1.0.2
|
2 |
gradio
|
3 |
fastapi>0.95
|