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

main
KKlochko 1 month ago
parent fc286b34ed
commit dfab9d3df0
Signed by: KKlochko
GPG Key ID: 572ECCD219BBA91B

@ -24,7 +24,10 @@ async def lifespan(app: FastAPI):
print("Loading GLiNER model...")
model_name = os.getenv("MODEL_NAME", "knowledgator/gliner-multitask-large-v0.5")
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}")
yield
print("Shutting down...")

Loading…
Cancel
Save