Instructions to use kenisgod/en_ingredient_extract with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- spaCy
How to use kenisgod/en_ingredient_extract with spaCy:
!pip install https://huggingface.co/kenisgod/en_ingredient_extract/resolve/main/en_ingredient_extract-any-py3-none-any.whl # Using spacy.load(). import spacy nlp = spacy.load("en_ingredient_extract") # Importing as module. import en_ingredient_extract nlp = en_ingredient_extract.load() - Notebooks
- Google Colab
- Kaggle
Download handler.py from kenisgod/en_ingredient_extract: direct link, hf CLI and curl.
- Browser
- Download file 597 Bytes
-
https://huggingface.co/kenisgod/en_ingredient_extract/resolve/main/handler.py
- Command line
-
hf download hf://kenisgod/en_ingredient_extract/handler.py
-
curl -L -o handler.py https://huggingface.co/kenisgod/en_ingredient_extract/resolve/main/handler.py
597 Bytes
| from typing import Dict, List, Any | |
| import spacy | |
| class EndpointHandler: | |
| def __init__(self, path=""): | |
| self.nlp = spacy.load(path) | |
| def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]: | |
| """ | |
| Your mom. | |
| """ | |
| # Get inputs | |
| text_input = data.pop("inputs", "") | |
| # Perform regular model task | |
| result = self.nlp(text_input) | |
| # Return the result | |
| entities = [] | |
| for ent in result.ents: | |
| entities.append({"text": ent.text, "label": ent.label_, "id": ent.ent_id_}) | |
| return entities | |