Omkar008 commited on
Commit
bbfbf5e
·
verified ·
1 Parent(s): 94a3c4b

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +13 -13
main.py CHANGED
@@ -6,21 +6,21 @@ from api.endpoints import location
6
  from transformers import AutoTokenizer, AutoModelForTokenClassification
7
  from transformers import pipeline
8
  from models.fastapi_globals import g ,GlobalsMiddleware
9
- @asynccontextmanager
10
- async def lifespan(app: FastAPI):
11
- # initialize_nlp()
12
- print("Initializing NER model and tokenizer")
13
- logging.info("Initializing NER model and tokenizer")
14
 
15
- app.tokenizer = AutoTokenizer.from_pretrained("ml6team/bert-base-uncased-city-country-ner")
16
- app.model = AutoModelForTokenClassification.from_pretrained("ml6team/bert-base-uncased-city-country-ner")
17
- app.nlp = pipeline('ner', model=app.model, tokenizer=app.tokenizer, aggregation_strategy="simple")
18
- g.set_default("ner_model", ner_model)
19
- yield
20
- del sentiment_model
21
- g.cleanup()
22
 
23
- app = FastAPI(lifespan=lifespan)
24
 
25
  app.include_router(location.router, prefix="/location/api/v1")
26
 
 
6
  from transformers import AutoTokenizer, AutoModelForTokenClassification
7
  from transformers import pipeline
8
  from models.fastapi_globals import g ,GlobalsMiddleware
9
+ # @asynccontextmanager
10
+ # async def lifespan(app: FastAPI):
11
+ # # initialize_nlp()
12
+ # print("Initializing NER model and tokenizer")
13
+ # logging.info("Initializing NER model and tokenizer")
14
 
15
+ # app.tokenizer = AutoTokenizer.from_pretrained("ml6team/bert-base-uncased-city-country-ner")
16
+ # app.model = AutoModelForTokenClassification.from_pretrained("ml6team/bert-base-uncased-city-country-ner")
17
+ # app.nlp = pipeline('ner', model=app.model, tokenizer=app.tokenizer, aggregation_strategy="simple")
18
+ # g.set_default("ner_model", ner_model)
19
+ # yield
20
+ # del sentiment_model
21
+ # g.cleanup()
22
 
23
+ app = FastAPI()
24
 
25
  app.include_router(location.router, prefix="/location/api/v1")
26