Update app.py
Browse files
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 |
-
|
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
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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."""
|