Fred808 commited on
Commit
3e5baf9
·
verified ·
1 Parent(s): 133b29b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -10,6 +10,9 @@ from fastapi import FastAPI, File, UploadFile
10
  from fastapi.responses import JSONResponse
11
  import uvicorn
12
 
 
 
 
13
  # Configure PyTorch settings
14
  torch.backends.cuda.enable_flash_sdp(False)
15
  torch.backends.cuda.enable_math_sdp(True)
@@ -40,14 +43,18 @@ def load_florence_model():
40
  log_message("[*] Loading Florence-2 model and processor...")
41
 
42
  # Load model and processor
 
43
  processor = AutoProcessor.from_pretrained(
44
  MODEL_ID,
45
- trust_remote_code=True
 
46
  )
47
 
 
48
  model = AutoModelForVision2Seq.from_pretrained(
49
  MODEL_ID,
50
  trust_remote_code=True,
 
51
  torch_dtype=torch.float32
52
  ).to(DEVICE)
53
 
 
10
  from fastapi.responses import JSONResponse
11
  import uvicorn
12
 
13
+ # Set environment variable to handle remote code trust
14
+ os.environ["TRANSFORMERS_OFFLINE"] = "1"
15
+
16
  # Configure PyTorch settings
17
  torch.backends.cuda.enable_flash_sdp(False)
18
  torch.backends.cuda.enable_math_sdp(True)
 
43
  log_message("[*] Loading Florence-2 model and processor...")
44
 
45
  # Load model and processor
46
+ # Load processor with explicit trust and local files
47
  processor = AutoProcessor.from_pretrained(
48
  MODEL_ID,
49
+ trust_remote_code=True,
50
+ local_files_only=True
51
  )
52
 
53
+ # Load model with explicit trust and local files
54
  model = AutoModelForVision2Seq.from_pretrained(
55
  MODEL_ID,
56
  trust_remote_code=True,
57
+ local_files_only=True,
58
  torch_dtype=torch.float32
59
  ).to(DEVICE)
60