Commit ·
d9c1e0e
1
Parent(s): 86a4cd6
Update app.py
Browse files1234567893 unmodified lines1314151617181920212221 unmodified lines4445464748import gradio as grfrom dataclasses import dataclassfrom pytorch_ie import AnnotationList, LabeledSpan, Pipeline, TextDocument, annotation_fieldfrom pytorch_ie.models import TransformerSpanClassificationModelfrom pytorch_ie.taskmodules import TransformerSpanClassificationTaskModulefrom spacy import displacy3 unmodified linesmodel_name_or_path = "pie/example-ner-spanclf-conll03"ner_taskmodule = TransformerSpanClassificationTaskModule.from_pretrained(model_name_or_path)ner_model = TransformerSpanClassificationModel.from_pretrained(model_name_or_path)ner_pipeline = Pipeline(model=ner_model, taskmodule=ner_taskmodule, device=-1, num_workers=0)def predict(text):21 unmodified linesreturn htmliface = gr.Interface(fn=predict, inputs="textbox", outputs="html")iface.launch()12345678910113 unmodified lines151617181920212221 unmodified lines444546474849505152535455import gradio as grfrom dataclasses import dataclassfrom pytorch_ie.annotations import LabeledSpanfrom pytorch_ie.auto import AutoPipelinefrom pytorch_ie.core import AnnotationList, annotation_fieldfrom pytorch_ie.documents import TextDocumentfrom spacy import displacy3 unmodified linesmodel_name_or_path = "pie/example-ner-spanclf-conll03"ner_pipeline = AutoPipeline.from_pretrained(model_name_or_path, device=-1, num_workers=0)def predict(text):21 unmodified linesreturn htmliface = gr.Interface(fn=predict,inputs=gr.inputs.Textbox(lines=5,default="There is still some uncertainty that Musk - also chief executive of electric car maker Tesla and rocket company SpaceX - will pull off his planned buyout.",),outputs="html",)iface.launch()
app.py+14-7