Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
|
|
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 |
|