sitammeur commited on
Commit
2a548c9
Β·
verified Β·
1 Parent(s): 313939e

Update src/florence/model.py

Browse files
Files changed (1) hide show
  1. src/florence/model.py +7 -7
src/florence/model.py CHANGED
@@ -1,6 +1,6 @@
1
  # Importing necessary libraries
2
  import sys
3
- import subprocess
4
  from typing import Optional
5
  from PIL import Image
6
  import torch
@@ -14,17 +14,17 @@ from src.exception import CustomExceptionHandling
14
 
15
 
16
  # Install the required dependencies
17
- subprocess.run(
18
- "pip install flash-attn --no-build-isolation",
19
- env={"FLASH_ATTENTION_SKIP_CUDA_BUILD": "TRUE"},
20
- shell=True,
21
- )
22
 
23
  # Load model and processor from Hugging Face
24
  model_id = "microsoft/Florence-2-large-ft"
25
  try:
26
  model = (
27
- AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, trust_remote_code=True)
28
  .to("cuda")
29
  .eval()
30
  )
 
1
  # Importing necessary libraries
2
  import sys
3
+ # import subprocess
4
  from typing import Optional
5
  from PIL import Image
6
  import torch
 
14
 
15
 
16
  # Install the required dependencies
17
+ # subprocess.run(
18
+ # "pip install flash-attn --no-build-isolation",
19
+ # env={"FLASH_ATTENTION_SKIP_CUDA_BUILD": "TRUE"},
20
+ # shell=True,
21
+ # )
22
 
23
  # Load model and processor from Hugging Face
24
  model_id = "microsoft/Florence-2-large-ft"
25
  try:
26
  model = (
27
+ AutoModelForCausalLM.from_pretrained(model_id, attn_implementation="sdpa", torch_dtype=torch.float16, trust_remote_code=True)
28
  .to("cuda")
29
  .eval()
30
  )