Update app.py
Browse files
app.py
CHANGED
@@ -12,13 +12,13 @@ def generate_caption(image):
|
|
12 |
|
13 |
# Preprocess the image and generate a detailed caption
|
14 |
inputs = processor(images=image, return_tensors="pt")
|
15 |
-
out = model.generate(**inputs, num_beams=
|
16 |
caption = processor.decode(out[0], skip_special_tokens=True)
|
17 |
|
18 |
end_time = time.time() # End time
|
19 |
processing_time = end_time - start_time # Calculate processing time
|
20 |
|
21 |
-
return caption, f"Time taken: {processing_time:.
|
22 |
|
23 |
# Function to handle cancellation (clear image and output)
|
24 |
def cancel_action():
|
|
|
12 |
|
13 |
# Preprocess the image and generate a detailed caption
|
14 |
inputs = processor(images=image, return_tensors="pt")
|
15 |
+
out = model.generate(**inputs, num_beams=3, max_length=500, early_stopping=True)
|
16 |
caption = processor.decode(out[0], skip_special_tokens=True)
|
17 |
|
18 |
end_time = time.time() # End time
|
19 |
processing_time = end_time - start_time # Calculate processing time
|
20 |
|
21 |
+
return caption, f"Time taken: {processing_time:.1f} seconds"
|
22 |
|
23 |
# Function to handle cancellation (clear image and output)
|
24 |
def cancel_action():
|