Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
8 |
def img2text(url):
|
9 |
"""
|
10 |
-
Converts an image to text using the
|
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="
|
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"
|