BhuiyanMasum commited on
Commit
4d61771
·
1 Parent(s): 1a9e80b

Upload model files

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -5,12 +5,14 @@ from fastapi import FastAPI, UploadFile, File
5
  from fastapi.responses import JSONResponse
6
  from pydantic import BaseModel
7
 
8
- app = FastAPI()
 
9
 
10
- # Load the pre-trained model
11
- model_uri = "model.pth"
12
- model = torch.load(model_uri)
13
 
 
 
 
14
 
15
  # Define input schema for JSON requests
16
  class ImageInput(BaseModel):
 
5
  from fastapi.responses import JSONResponse
6
  from pydantic import BaseModel
7
 
8
+ # Allowlist the required global for PyTorch model loading
9
+ torch.serialization.add_safe_globals(['cloudpickle.cloudpickle._make_skeleton_class'])
10
 
11
+ app = FastAPI()
 
 
12
 
13
+ # Load the pre-trained model from within the container
14
+ model_uri = "/app/model.pth"
15
+ model = torch.load(model_uri, weights_only=True)
16
 
17
  # Define input schema for JSON requests
18
  class ImageInput(BaseModel):