Spaces:
Sleeping
Sleeping
File size: 601 Bytes
0619931 42ac98b 0619931 42ac98b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
from transformers import pipeline
# Step 1: Load the pre-trained model
image_to_text_pipeline = pipeline("image-to-text", model="Salesforce/blip-image-captioning-large")
# Step 2: Get the uploaded image file path
uploaded_files = get_uploaded_files()
if not uploaded_files:
print("Please upload an image file.")
else:
image_path = uploaded_files[0] # Assuming only one image is uploaded
# Step 3: Test the model by providing the uploaded image
generated_text = image_to_text_pipeline(image_path)
# Step 4: Print the generated text
print("Generated Text:", generated_text)
|