Spaces:
Sleeping
Sleeping
fixing tokenizer errors
Browse files
app.py
CHANGED
|
@@ -2,11 +2,16 @@ from fastapi import FastAPI, HTTPException
|
|
| 2 |
import chess
|
| 3 |
from contextlib import asynccontextmanager
|
| 4 |
import sys
|
| 5 |
-
from src.model import ChessPolicyModel, PolicyModelInference
|
| 6 |
-
from src.tokenizer import tokenizer
|
| 7 |
import torch
|
| 8 |
from pydantic import BaseModel
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
ml = {}
|
| 11 |
@asynccontextmanager
|
| 12 |
async def lifespan(app: FastAPI):
|
|
|
|
| 2 |
import chess
|
| 3 |
from contextlib import asynccontextmanager
|
| 4 |
import sys
|
|
|
|
|
|
|
| 5 |
import torch
|
| 6 |
from pydantic import BaseModel
|
| 7 |
|
| 8 |
+
# Pickle stored the model/tokenizer classes under their original (top-level)
|
| 9 |
+
# module paths. Alias src.* as top-level names so torch.load can resolve them.
|
| 10 |
+
from src import tokenizer as _tokenizer_module
|
| 11 |
+
sys.modules["tokenizer"] = _tokenizer_module
|
| 12 |
+
|
| 13 |
+
from src.model import ChessPolicyModel, PolicyModelInference
|
| 14 |
+
|
| 15 |
ml = {}
|
| 16 |
@asynccontextmanager
|
| 17 |
async def lifespan(app: FastAPI):
|