nielsr HF staff commited on
Commit
7e4d7af
·
1 Parent(s): c6a9f66

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -54,7 +54,8 @@ def generate_caption(processor, model, image, tokenizer=None):
54
 
55
  def generate_caption_coca(model, transform, image):
56
  im = transform(image).unsqueeze(0).to(device)
57
- generated = model.generate(im, seq_len=20)
 
58
  return open_clip.decode(generated[0].detach()).split("<end_of_text>")[0].replace("<start_of_text>", "")
59
 
60
 
 
54
 
55
  def generate_caption_coca(model, transform, image):
56
  im = transform(image).unsqueeze(0).to(device)
57
+ with torch.no_grad(), torch.cuda.amp.autocast():
58
+ generated = model.generate(im, seq_len=20)
59
  return open_clip.decode(generated[0].detach()).split("<end_of_text>")[0].replace("<start_of_text>", "")
60
 
61