Spaces:
Running
Running
Update main.py
Browse files
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 |
-
|
12 |
-
|
13 |
-
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
|
23 |
-
app = FastAPI(
|
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 |
|