smtsead commited on
Commit
1510296
·
verified ·
1 Parent(s): 72f3264

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -4,10 +4,10 @@ from transformers import pipeline
4
  from gtts import gTTS
5
  import os
6
 
7
- # Function to convert image to text using Hugging Face's BLIP model
8
  def img2text(url):
9
  """
10
- Converts an image to text using the Salesforce/blip-image-captioning-base model.
11
 
12
  Args:
13
  url (str): Path to the image file.
@@ -15,7 +15,7 @@ def img2text(url):
15
  Returns:
16
  str: Generated text caption from the image, without words like "illustration".
17
  """
18
- image_to_text_model = pipeline("image-to-text", model="Salesforce/blip-image-captioning-base")
19
  text = image_to_text_model(url)[0]["generated_text"]
20
 
21
  # Remove unwanted words like "illustration"
 
4
  from gtts import gTTS
5
  import os
6
 
7
+ # Function to convert image to text using Hugging Face's vit-gpt2-image-captioning model
8
  def img2text(url):
9
  """
10
+ Converts an image to text using the nlpconnect/vit-gpt2-image-captioning model.
11
 
12
  Args:
13
  url (str): Path to the image file.
 
15
  Returns:
16
  str: Generated text caption from the image, without words like "illustration".
17
  """
18
+ image_to_text_model = pipeline("image-to-text", model="nlpconnect/vit-gpt2-image-captioning")
19
  text = image_to_text_model(url)[0]["generated_text"]
20
 
21
  # Remove unwanted words like "illustration"