Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,12 +5,9 @@ import spaces
|
|
| 5 |
import torch
|
| 6 |
import os
|
| 7 |
|
| 8 |
-
from transformers import AutoProcessor, AutoModelForCausalLM
|
| 9 |
-
|
| 10 |
-
|
| 11 |
|
| 12 |
access_token = os.getenv('HF_token')
|
| 13 |
-
model_id = "selamw/
|
| 14 |
bnb_config = BitsAndBytesConfig(load_in_8bit=True)
|
| 15 |
|
| 16 |
|
|
@@ -44,18 +41,11 @@ def convert_to_markdown(input_text):
|
|
| 44 |
|
| 45 |
@spaces.GPU
|
| 46 |
def infer_fin_pali(image, question):
|
| 47 |
-
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
| 51 |
|
| 52 |
-
|
| 53 |
-
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
| 54 |
-
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
| 55 |
-
|
| 56 |
-
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch_dtype, trust_remote_code=True, quantization_config=bnb_config,token=access_token).to(device)
|
| 57 |
-
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True, token=access_token)
|
| 58 |
-
###
|
| 59 |
|
| 60 |
inputs = processor(images=image, text=question, return_tensors="pt").to(device)
|
| 61 |
|
|
|
|
| 5 |
import torch
|
| 6 |
import os
|
| 7 |
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
access_token = os.getenv('HF_token')
|
| 10 |
+
model_id = "selamw/BirdWatcher"
|
| 11 |
bnb_config = BitsAndBytesConfig(load_in_8bit=True)
|
| 12 |
|
| 13 |
|
|
|
|
| 41 |
|
| 42 |
@spaces.GPU
|
| 43 |
def infer_fin_pali(image, question):
|
| 44 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 45 |
|
| 46 |
+
model = PaliGemmaForConditionalGeneration.from_pretrained(model_id, quantization_config=bnb_config, token=access_token)
|
| 47 |
+
processor = PaliGemmaProcessor.from_pretrained(model_id, token=access_token)
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
inputs = processor(images=image, text=question, return_tensors="pt").to(device)
|
| 51 |
|