Instructions to use cimo001/urchade with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- GLiNER
How to use cimo001/urchade with GLiNER:
from gliner import GLiNER model = GLiNER.from_pretrained("cimo001/urchade") text = "Cristiano Ronaldo dos Santos Aveiro was born on 5 February 1985 in Funchal, Madeira, Portugal." labels = ["person", "date", "location"] entities = model.predict_entities(text, labels) for entity in entities: print(entity["text"], "=>", entity["label"]) - Notebooks
- Google Colab
- Kaggle
Download gliner_multi-v2.1/src/helper.py from cimo001/urchade: direct link, hf CLI and curl.
- Browser
- Download file 1.28 kB
-
https://huggingface.co/cimo001/urchade/resolve/main/gliner_multi-v2.1/src/helper.py
- Command line
-
hf download hf://cimo001/urchade/gliner_multi-v2.1/src/helper.py
-
curl -L -o helper.py https://huggingface.co/cimo001/urchade/resolve/main/gliner_multi-v2.1/src/helper.py
1.28 kB
| import os | |
| stderrFileDescriptor = os.dup(2) | |
| nullFileDescriptor = os.open(os.devnull, os.O_WRONLY) | |
| os.dup2(nullFileDescriptor, 2) | |
| import onnxruntime | |
| os.dup2(stderrFileDescriptor, 2) | |
| os.close(nullFileDescriptor) | |
| os.close(stderrFileDescriptor) | |
| def onnxSessionBuild(pathModel): | |
| option = onnxruntime.SessionOptions() | |
| option.log_severity_level = 3 | |
| option.graph_optimization_level = onnxruntime.GraphOptimizationLevel.ORT_ENABLE_ALL | |
| option.intra_op_num_threads = max(1, os.cpu_count()) | |
| option.inter_op_num_threads = 1 | |
| option.enable_cpu_mem_arena = True | |
| option.enable_mem_pattern = True | |
| option.enable_mem_reuse = True | |
| option.execution_mode = onnxruntime.ExecutionMode.ORT_SEQUENTIAL | |
| providerPreferredList = [ | |
| "CUDAExecutionProvider", | |
| "OpenVINOExecutionProvider", | |
| "CPUExecutionProvider" | |
| ] | |
| providerAvailableList = onnxruntime.get_available_providers() | |
| providerList = [provider for provider in providerPreferredList if provider in providerAvailableList] | |
| inference = onnxruntime.InferenceSession(pathModel, sess_options=option, providers=providerList) | |
| print(f"Provider available: {providerAvailableList}") | |
| print(f"Provider active: {inference.get_providers()}\n") | |
| return inference | |