lcyyyy commited on
Commit
42ac98b
·
verified ·
1 Parent(s): 7af96ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
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: Test the model by providing an image
8
- image_path = "image.jpg"
9
- generated_text = image_to_text_pipeline(image_path)
 
 
 
10
 
11
- # Step 3: Print the generated text
12
- print("Generated Text:", generated_text)
 
 
 
 
 
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)