Commit ·
9807731
1
Parent(s): e02c264
captions added
Browse files
app.py
CHANGED
|
@@ -9,10 +9,16 @@ def image_captioning(image_path, candidate_captions):
|
|
| 9 |
best_captions, similarities = match_captions(image_features, candidate_captions, clip_model, processor)
|
| 10 |
return best_captions, similarities
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
st.title("AI Image Caption Recommender with CLIP")
|
| 13 |
uploaded_image = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
|
| 14 |
|
| 15 |
-
candidate_captions =
|
| 16 |
|
| 17 |
if uploaded_image is not None:
|
| 18 |
st.image(uploaded_image, caption="Uploaded Image", use_column_width=True)
|
|
|
|
| 9 |
best_captions, similarities = match_captions(image_features, candidate_captions, clip_model, processor)
|
| 10 |
return best_captions, similarities
|
| 11 |
|
| 12 |
+
|
| 13 |
+
def load_captions(file_path):
|
| 14 |
+
with open(file_path, 'r') as file:
|
| 15 |
+
captions = [line.strip() for line in file.readlines()]
|
| 16 |
+
return captions
|
| 17 |
+
|
| 18 |
st.title("AI Image Caption Recommender with CLIP")
|
| 19 |
uploaded_image = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
|
| 20 |
|
| 21 |
+
candidate_captions = load_captions('caption.txt')
|
| 22 |
|
| 23 |
if uploaded_image is not None:
|
| 24 |
st.image(uploaded_image, caption="Uploaded Image", use_column_width=True)
|