Update the lifecycle to load the model only from local files.
This commit is contained in:
@@ -24,7 +24,10 @@ async def lifespan(app: FastAPI):
|
|||||||
print("Loading GLiNER model...")
|
print("Loading GLiNER model...")
|
||||||
model_name = os.getenv("MODEL_NAME", "knowledgator/gliner-multitask-large-v0.5")
|
model_name = os.getenv("MODEL_NAME", "knowledgator/gliner-multitask-large-v0.5")
|
||||||
device = "cuda" if torch.cuda.is_available() else "cpu"
|
device = "cuda" if torch.cuda.is_available() else "cpu"
|
||||||
model = GLiNER.from_pretrained(model_name).to(device)
|
model = GLiNER.from_pretrained(
|
||||||
|
model_name,
|
||||||
|
local_files_only = True
|
||||||
|
).to(device)
|
||||||
print(f"Model loaded on {device}")
|
print(f"Model loaded on {device}")
|
||||||
yield
|
yield
|
||||||
print("Shutting down...")
|
print("Shutting down...")
|
||||||
|
|||||||
Reference in New Issue
Block a user