Update app.py
Browse files
app.py
CHANGED
@@ -27,16 +27,25 @@ def generate_image_caption(image):
|
|
27 |
|
28 |
def generate_keywords(caption):
|
29 |
"""
|
30 |
-
Generate a list of keywords from the caption.
|
31 |
|
32 |
Args:
|
33 |
caption (str): The image caption.
|
34 |
|
35 |
Returns:
|
36 |
-
list: A list of single-word keywords.
|
37 |
"""
|
38 |
words = caption.split()
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
return keywords
|
41 |
|
42 |
def process_images(image_files):
|
|
|
27 |
|
28 |
def generate_keywords(caption):
|
29 |
"""
|
30 |
+
Generate a list of keywords from the caption, focusing on SEO relevance.
|
31 |
|
32 |
Args:
|
33 |
caption (str): The image caption.
|
34 |
|
35 |
Returns:
|
36 |
+
list: A list of 50 single-word keywords.
|
37 |
"""
|
38 |
words = caption.split()
|
39 |
+
# Remove common stopwords and keep unique words for SEO relevance
|
40 |
+
stopwords = {"a", "the", "and", "of", "in", "on", "with", "at", "for", "to", "is"}
|
41 |
+
keywords = list(set(word.lower() for word in words if word.lower() not in stopwords))
|
42 |
+
|
43 |
+
# Ensure the list contains exactly 50 keywords (add repetitions if needed)
|
44 |
+
if len(keywords) > 50:
|
45 |
+
keywords = keywords[:50]
|
46 |
+
elif len(keywords) < 50:
|
47 |
+
keywords.extend(keywords[:50-len(keywords)])
|
48 |
+
|
49 |
return keywords
|
50 |
|
51 |
def process_images(image_files):
|