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