Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -13,7 +13,7 @@ import tempfile
|
|
13 |
from inference import split_image_from_dataframe
|
14 |
from datetime import datetime
|
15 |
from predict_vit import extract_features, predict_similarity, compare_features, extract_features_cp
|
16 |
-
|
17 |
from predict_copy import extract_features_with_augmentation, extract_features_with_augmentation_cp
|
18 |
|
19 |
|
@@ -79,7 +79,7 @@ def perform_inference(cropped_images, species_feature_list, img_df):
|
|
79 |
st.success("Setting up OPENAI Client:")
|
80 |
client = setup_client()
|
81 |
st.success("Setting up knowledge database & BM25 retriever:")
|
82 |
-
retriever = setup_retriever()
|
83 |
st.success("Setting up BM25 Retriever:")
|
84 |
for img_idx, item in enumerate(cropped_images):
|
85 |
image = item["image"]
|
@@ -113,22 +113,22 @@ def perform_inference(cropped_images, species_feature_list, img_df):
|
|
113 |
# Extract and print the tree species name if found
|
114 |
if match:
|
115 |
tree_species = match.group(1)
|
116 |
-
species_info = retriever.invoke(f"Scientific name:{tree_species}")
|
117 |
|
118 |
-
ans = generate_image(species_info, client)
|
119 |
-
emoji.append(ans)
|
120 |
-
text_context = [doc.page_content for doc in species_info]
|
121 |
-
text_context = ", ".join(text_context)
|
122 |
-
species_context.append(text_context)
|
123 |
# print(ans)
|
124 |
-
species_result.append(tree_species)
|
125 |
|
126 |
else:
|
127 |
print("Tree species name not found.")
|
128 |
img_df.at[img_idx, "species_identified"] = ", ".join(species_result) if species_result else "No similar species found"
|
129 |
img_df.at[img_idx, "result_file_path"] = ", ".join(row_results) if row_results else ""
|
130 |
-
img_df.at[img_idx, "emoji"] = ", ".join(emoji) if emoji else ""
|
131 |
-
img_df.at[img_idx, "retreived context"] = ", ".join(species_context) if species_context else ""
|
132 |
|
133 |
|
134 |
return cropped_images
|
|
|
13 |
from inference import split_image_from_dataframe
|
14 |
from datetime import datetime
|
15 |
from predict_vit import extract_features, predict_similarity, compare_features, extract_features_cp
|
16 |
+
|
17 |
from predict_copy import extract_features_with_augmentation, extract_features_with_augmentation_cp
|
18 |
|
19 |
|
|
|
79 |
st.success("Setting up OPENAI Client:")
|
80 |
client = setup_client()
|
81 |
st.success("Setting up knowledge database & BM25 retriever:")
|
82 |
+
# retriever = setup_retriever()
|
83 |
st.success("Setting up BM25 Retriever:")
|
84 |
for img_idx, item in enumerate(cropped_images):
|
85 |
image = item["image"]
|
|
|
113 |
# Extract and print the tree species name if found
|
114 |
if match:
|
115 |
tree_species = match.group(1)
|
116 |
+
# species_info = retriever.invoke(f"Scientific name:{tree_species}")
|
117 |
|
118 |
+
# ans = generate_image(species_info, client)
|
119 |
+
# emoji.append(ans)
|
120 |
+
# text_context = [doc.page_content for doc in species_info]
|
121 |
+
# text_context = ", ".join(text_context)
|
122 |
+
# species_context.append(text_context)
|
123 |
# print(ans)
|
124 |
+
# species_result.append(tree_species)
|
125 |
|
126 |
else:
|
127 |
print("Tree species name not found.")
|
128 |
img_df.at[img_idx, "species_identified"] = ", ".join(species_result) if species_result else "No similar species found"
|
129 |
img_df.at[img_idx, "result_file_path"] = ", ".join(row_results) if row_results else ""
|
130 |
+
# img_df.at[img_idx, "emoji"] = ", ".join(emoji) if emoji else ""
|
131 |
+
# img_df.at[img_idx, "retreived context"] = ", ".join(species_context) if species_context else ""
|
132 |
|
133 |
|
134 |
return cropped_images
|