Spaces:
Runtime error
Runtime error
Adapt code to use gr.Interface
Browse files- app.py +19 -6
- flagged/log.csv +2 -0
- flagged/output/tmp753_rhoo.json +1 -0
- requirements.txt +1 -0
app.py
CHANGED
@@ -1,11 +1,24 @@
|
|
1 |
import gradio as gr
|
2 |
from AinaTheme import AinaGradioTheme
|
|
|
3 |
|
4 |
-
gr.load("projecte-aina/multiner_ceil",src="models",aggregation_strategy="first", **AinaGradioTheme().get_kwargs()).launch()
|
5 |
-
#from transformers import pipeline
|
6 |
-
#import gradio as gr
|
7 |
|
8 |
-
#pipe = pipeline("token-classification", model="projecte-aina/multiner_ceil",aggregation_strategy="first")
|
9 |
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from AinaTheme import AinaGradioTheme
|
3 |
+
from transformers import pipeline
|
4 |
|
5 |
+
# gr.load("projecte-aina/multiner_ceil",src="models",aggregation_strategy="first", **AinaGradioTheme().get_kwargs()).launch()
|
|
|
|
|
6 |
|
|
|
7 |
|
8 |
+
import gradio as gr
|
9 |
+
|
10 |
+
ner_pipeline = pipeline("token-classification", model="projecte-aina/multiner_ceil")
|
11 |
+
|
12 |
+
# examples = [
|
13 |
+
# "Does Chicago have any stores and does Joe live here?",
|
14 |
+
# ]
|
15 |
+
|
16 |
+
def ner(text):
|
17 |
+
output = ner_pipeline(text)
|
18 |
+
return {"text": text, "entities": output}
|
19 |
+
|
20 |
+
demo = gr.Interface(ner,
|
21 |
+
gr.Textbox(placeholder="Enter sentence here..."),
|
22 |
+
gr.HighlightedText(), **AinaGradioTheme().get_kwargs())
|
23 |
+
|
24 |
+
demo.launch()
|
flagged/log.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
text,output,flag,username,timestamp
|
2 |
+
"El Centre de Coordinació de Rescat Marí de la ciutat de Novorossisk, a Crimea, ha confirmat que el petrolier ha patit danys, i ha explicat que el Servei de Salvament Marítim rus ha remolcat el vaixell. El vice-president del Consell de Seguretat de Rússia, Dmitri Medvédev, ha acusat Ucraïna de voler provocar una catàstrofe mediambiental al mar Negre",/home/andrei/workspace/projects/aina/multiner_demo/flagged/output/tmp753_rhoo.json,,,2023-10-18 14:09:10.264007
|
flagged/output/tmp753_rhoo.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
[["El ", null], ["Centre", "B-organization-other"], [" ", null], ["de", "I-organization-other"], [" ", null], ["Coordinaci\u00f3", "I-organization-other"], [" ", null], ["de", "I-organization-other"], [" ", null], ["R", "I-organization-other"], ["", null], ["escat", "I-organization-other"], [" ", null], ["Mar\u00ed", "I-organization-other"], [" de la ciutat de ", null], ["No", "B-GPE"], ["", null], ["vor", "I-GPE"], ["", null], ["oss", "I-GPE"], ["", null], ["is", "I-GPE"], ["", null], ["k", "I-GPE"], [", a ", null], ["Crimea", "B-GPE"], [", ha confirmat que el petrolier ha patit danys, i ha explicat que el ", null], ["Servei", "B-organization-other"], [" ", null], ["de", "I-organization-other"], [" ", null], ["Salvament", "I-organization-other"], [" ", null], ["Mar\u00edtim", "I-organization-other"], [" ", null], ["rus", "I-organization-other"], [" ha remolcat el vaixell. El vice-president del ", null], ["Consell", "B-organization-other"], [" ", null], ["de", "I-organization-other"], [" ", null], ["Seguretat", "I-organization-other"], [" ", null], ["de", "I-organization-other"], [" ", null], ["R\u00fassia", "I-organization-other"], [", ", null], ["D", "B-person-politician"], ["", null], ["mit", "I-person-politician"], ["", null], ["ri", "I-person-politician"], [" ", null], ["Med", "I-person-politician"], ["", null], ["v\u00e9", "I-person-politician"], ["", null], ["dev", "I-person-politician"], [", ha acusat ", null], ["Ucra\u00efna", "B-GPE"], [" de voler provocar una cat\u00e0strofe mediambiental al ", null], ["mar", "B-location-bodiesofwater"], [" ", null], ["Negre", "I-location-bodiesofwater"], ["", null]]
|
requirements.txt
CHANGED
@@ -1,3 +1,4 @@
|
|
1 |
transformers==4.34.0
|
2 |
gradio==3.49.0
|
3 |
git+https://gitlab.bsc.es/projecte-aina/[email protected]
|
|
|
|
1 |
transformers==4.34.0
|
2 |
gradio==3.49.0
|
3 |
git+https://gitlab.bsc.es/projecte-aina/[email protected]
|
4 |
+
torch==2.1.0
|