Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -53,19 +53,19 @@ def infer_fin_pali(image, question):
|
|
| 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 |
-
|
| 57 |
-
|
| 58 |
###
|
| 59 |
|
| 60 |
-
model = AutoModelForCausalLM.from_pretrained("microsoft/Florence-2-large", torch_dtype=torch_dtype, trust_remote_code=True).to(device)
|
| 61 |
-
processor = AutoProcessor.from_pretrained("microsoft/Florence-2-large", trust_remote_code=True)
|
| 62 |
|
| 63 |
-
prompt = "<OD>"
|
| 64 |
|
| 65 |
-
url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg?download=true"
|
| 66 |
-
image = Image.open(requests.get(url, stream=True).raw)
|
| 67 |
|
| 68 |
-
inputs = processor(text=
|
| 69 |
|
| 70 |
######
|
| 71 |
# inputs = processor(images=image, text=question, return_tensors="pt").to(device)
|
|
|
|
| 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 |
+
# model = AutoModelForCausalLM.from_pretrained("microsoft/Florence-2-large", torch_dtype=torch_dtype, trust_remote_code=True).to(device)
|
| 61 |
+
# processor = AutoProcessor.from_pretrained("microsoft/Florence-2-large", trust_remote_code=True)
|
| 62 |
|
| 63 |
+
# prompt = "<OD>"
|
| 64 |
|
| 65 |
+
# url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg?download=true"
|
| 66 |
+
# image = Image.open(requests.get(url, stream=True).raw)
|
| 67 |
|
| 68 |
+
inputs = processor(text=question, images=image, return_tensors="pt").to(device, torch_dtype)
|
| 69 |
|
| 70 |
######
|
| 71 |
# inputs = processor(images=image, text=question, return_tensors="pt").to(device)
|