gpucce commited on
Commit
d95697d
1 Parent(s): 2e13d7d

context for generate

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -13,7 +13,8 @@ model.to(device)
13
 
14
  def output_generate(image):
15
  im = transform(image).unsqueeze(0).to(device)
16
- generated = model.generate(im, seq_len=20)
 
17
  return open_clip.decode(generated[0].detach()).split("<end_of_text>")[0].replace("<start_of_text>", "")
18
 
19
  iface = gr.Interface(fn=output_generate, inputs=gr.Image(type="pil"), outputs="text")
 
13
 
14
  def output_generate(image):
15
  im = transform(image).unsqueeze(0).to(device)
16
+ with torch.no_grad(), torch.cuda.amp.autocast():
17
+ generated = model.generate(im, seq_len=20)
18
  return open_clip.decode(generated[0].detach()).split("<end_of_text>")[0].replace("<start_of_text>", "")
19
 
20
  iface = gr.Interface(fn=output_generate, inputs=gr.Image(type="pil"), outputs="text")