Update the lifecycle to load the model only from local files.

This commit is contained in:
2025-11-16 15:42:24 +02:00
parent fc286b34ed
commit dfab9d3df0
+4 -1
View File
@@ -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...")