|
import gradio as gr
|
|
|
|
with open('materials/introduction.html', 'r', encoding='utf-8') as file:
|
|
html_description = file.read()
|
|
|
|
with gr.Blocks() as landing_interface:
|
|
gr.HTML(html_description)
|
|
|
|
with gr.Accordion("How to run this model locally", open=False):
|
|
gr.Markdown(
|
|
"""
|
|
## Installation
|
|
To use this model, you must install the GLiNER Python library:
|
|
```
|
|
pip install gliner
|
|
```
|
|
## Usage
|
|
Once you've downloaded the GLiNER library, you can import the GLiNER class. You can then load this model using `GLiNER.from_pretrained` and predict entities with `predict_entities`.
|
|
"""
|
|
)
|
|
gr.Code(
|
|
'''
|
|
from gliner import GLiNER
|
|
model = GLiNER.from_pretrained("knowledgator/gliner-multitask-large-v0.5")
|
|
text = "Your text here"
|
|
labels = ["person", "award", "date", "competitions", "teams"]
|
|
entities = model.predict_entities(text, labels)
|
|
for entity in entities:
|
|
print(entity["text"], "=>", entity["label"])
|
|
''',
|
|
language="python",
|
|
) |