Spaces:
Runtime error
Runtime error
context for generate
Browse files
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 |
-
|
|
|
|
| 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")
|