Spaces:
Sleeping
Sleeping
| from fastapi import FastAPI | |
| from core.init_nlp import initialize_nlp | |
| from contextlib import asynccontextmanager | |
| import logging | |
| from api.endpoints import location | |
| app = FastAPI(lifespan=lifespan) | |
| async def lifespan(app: FastAPI): | |
| # initialize_nlp() | |
| print("Initializing NER model and tokenizer") | |
| logging.info("Initializing NER model and tokenizer") | |
| app.tokenizer = AutoTokenizer.from_pretrained("ml6team/bert-base-uncased-city-country-ner") | |
| app.model = AutoModelForTokenClassification.from_pretrained("ml6team/bert-base-uncased-city-country-ner") | |
| app.nlp = pipeline('ner', model=app.model, tokenizer=app.tokenizer, aggregation_strategy="simple") | |
| yield | |
| app.include_router(location.router, prefix="/location/api/v1") | |