Spaces:
Runtime error
Runtime error
ShreyMehra
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -39,7 +39,7 @@ class UI:
|
|
39 |
# pixel_values = pixel_values.to(torch.float32)
|
40 |
|
41 |
print(4)
|
42 |
-
generated_ids = model.generate(pixel_values=pixel_values, max_length=25)
|
43 |
generated_caption = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
44 |
|
45 |
st.write(generated_caption)
|
@@ -58,7 +58,7 @@ class Model:
|
|
58 |
config = PeftConfig.from_pretrained(peft_model_id)
|
59 |
global model
|
60 |
global processor
|
61 |
-
model = Blip2ForConditionalGeneration.from_pretrained(config.base_model_name_or_path, low_cpu_mem_usage=True, torch_dtype=torch.
|
62 |
model = PeftModel.from_pretrained(model, peft_model_id)
|
63 |
processor = AutoProcessor.from_pretrained("Salesforce/blip2-opt-2.7b")
|
64 |
|
|
|
39 |
# pixel_values = pixel_values.to(torch.float32)
|
40 |
|
41 |
print(4)
|
42 |
+
generated_ids = model.to(device, torch.float32).generate(pixel_values=pixel_values, max_length=25)
|
43 |
generated_caption = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
44 |
|
45 |
st.write(generated_caption)
|
|
|
58 |
config = PeftConfig.from_pretrained(peft_model_id)
|
59 |
global model
|
60 |
global processor
|
61 |
+
model = Blip2ForConditionalGeneration.from_pretrained(config.base_model_name_or_path, low_cpu_mem_usage=True, torch_dtype=torch.float16) #, device_map="auto", load_in_8bit=True
|
62 |
model = PeftModel.from_pretrained(model, peft_model_id)
|
63 |
processor = AutoProcessor.from_pretrained("Salesforce/blip2-opt-2.7b")
|
64 |
|