syedfaisalabrar commited on
Commit
383aa7e
·
verified ·
1 Parent(s): 964b114

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -13,16 +13,25 @@ from frontPrompt import main as main_f
13
 
14
  model_path = "best.pt"
15
  modelY = YOLO(model_path)
 
 
16
 
17
- path = "OpenGVLab/InternVL2_5-4B"
18
  model = AutoModel.from_pretrained(
19
  path,
 
20
  torch_dtype=torch.bfloat16 if torch.cuda.is_available() else torch.float32,
21
- # load_in_8bit=True,
22
  low_cpu_mem_usage=True,
23
  use_flash_attn=True,
24
- trust_remote_code=True).eval().to("cpu")
25
- tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True, use_fast=False)
 
 
 
 
 
 
 
26
 
27
  def preprocessing(image):
28
  """Apply three enhancement filters, including brightness reduction, and resize."""
 
13
 
14
  model_path = "best.pt"
15
  modelY = YOLO(model_path)
16
+ os.environ["TRANSFORMERS_CACHE"] = "./.cache"
17
+ cache_folder = "./.cache"
18
 
19
+ # Load the Hugging Face model and tokenizer globally (downloaded only once)
20
  model = AutoModel.from_pretrained(
21
  path,
22
+ cache_dir=cache_folder,
23
  torch_dtype=torch.bfloat16 if torch.cuda.is_available() else torch.float32,
 
24
  low_cpu_mem_usage=True,
25
  use_flash_attn=True,
26
+ trust_remote_code=True
27
+ ).eval().to("cpu")
28
+
29
+ tokenizer = AutoTokenizer.from_pretrained(
30
+ path,
31
+ cache_dir=cache_folder,
32
+ trust_remote_code=True,
33
+ use_fast=False
34
+ )
35
 
36
  def preprocessing(image):
37
  """Apply three enhancement filters, including brightness reduction, and resize."""