Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -31,7 +31,7 @@ def image_preprocess(image):
|
|
31 |
return image
|
32 |
|
33 |
def generate_caption(image_processor, model, tokenizer,device, image):
|
34 |
-
inputs = image_processor(image,
|
35 |
model.eval()
|
36 |
# Generate caption
|
37 |
with torch.no_grad():
|
@@ -40,6 +40,7 @@ def generate_caption(image_processor, model, tokenizer,device, image):
|
|
40 |
max_length=1000,# Adjust the maximum length of the generated caption as needed
|
41 |
num_beams=4, # Adjust the number of beams for beam search decoding
|
42 |
early_stopping=True # Enable early stopping to stop generation when all beams finished
|
|
|
43 |
)
|
44 |
|
45 |
# Decode the generated caption
|
|
|
31 |
return image
|
32 |
|
33 |
def generate_caption(image_processor, model, tokenizer,device, image):
|
34 |
+
inputs = image_processor(image, return_tensors='pt').to(device)
|
35 |
model.eval()
|
36 |
# Generate caption
|
37 |
with torch.no_grad():
|
|
|
40 |
max_length=1000,# Adjust the maximum length of the generated caption as needed
|
41 |
num_beams=4, # Adjust the number of beams for beam search decoding
|
42 |
early_stopping=True # Enable early stopping to stop generation when all beams finished
|
43 |
+
,batch_size=1
|
44 |
)
|
45 |
|
46 |
# Decode the generated caption
|