ShreyMehra commited on
Commit
bdb81d2
·
unverified ·
1 Parent(s): 46d5540

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
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.float32) #, 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
 
 
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