Spaces:
Runtime error
Runtime error
Update demo.py
Browse files
demo.py
CHANGED
|
@@ -6,12 +6,12 @@ import torch
|
|
| 6 |
model_id = "MargiPandya/blip2-bdd100k"
|
| 7 |
processor = AutoProcessor.from_pretrained(model_id)
|
| 8 |
config = PeftConfig.from_pretrained(model_id)
|
| 9 |
-
model = Blip2ForConditionalGeneration.from_pretrained(config.base_model_name_or_path, load_in_8bit=True, device_map="
|
| 10 |
model = PeftModel.from_pretrained(model, model_id)
|
| 11 |
|
| 12 |
|
| 13 |
def caption_image(image):
|
| 14 |
-
inputs = processor(images=image, return_tensors="pt").to("
|
| 15 |
generated_ids = model.generate(
|
| 16 |
**inputs,
|
| 17 |
max_new_tokens=64,
|
|
|
|
| 6 |
model_id = "MargiPandya/blip2-bdd100k"
|
| 7 |
processor = AutoProcessor.from_pretrained(model_id)
|
| 8 |
config = PeftConfig.from_pretrained(model_id)
|
| 9 |
+
model = Blip2ForConditionalGeneration.from_pretrained(config.base_model_name_or_path, load_in_8bit=True, device_map="cpu")
|
| 10 |
model = PeftModel.from_pretrained(model, model_id)
|
| 11 |
|
| 12 |
|
| 13 |
def caption_image(image):
|
| 14 |
+
inputs = processor(images=image, return_tensors="pt").to("cpu", torch.float16)
|
| 15 |
generated_ids = model.generate(
|
| 16 |
**inputs,
|
| 17 |
max_new_tokens=64,
|