Spaces:
Sleeping
Sleeping
Commit
·
1ec60dd
1
Parent(s):
8d55090
updates
Browse files
app.py
CHANGED
|
@@ -20,8 +20,6 @@ dataset_name = "GeorgeIbrahim/EGYCOCO" # Replace with your dataset name
|
|
| 20 |
with open('nearest_neighbors_with_captions.json', 'r') as f:
|
| 21 |
results = json.load(f)
|
| 22 |
|
| 23 |
-
print(results)
|
| 24 |
-
|
| 25 |
# Load or create the dataset
|
| 26 |
try:
|
| 27 |
dataset = load_dataset(dataset_name, split="train")
|
|
@@ -31,8 +29,6 @@ try:
|
|
| 31 |
# Check if the 'split' column exists; if not, add it
|
| 32 |
if 'split' not in dataset.column_names:
|
| 33 |
# Define the 'split' values based on `image_id`
|
| 34 |
-
print(results)
|
| 35 |
-
print(example["image_id"] in results)
|
| 36 |
split_values = [
|
| 37 |
"dev" if example["image_id"] in results else "train"
|
| 38 |
for example in dataset
|
|
@@ -133,7 +129,6 @@ def get_next_image(session_data):
|
|
| 133 |
|
| 134 |
# Iterate over each image file to apply the filtering logic
|
| 135 |
for img in image_files:
|
| 136 |
-
print(img) # Debugging line to print each image filename
|
| 137 |
|
| 138 |
# Match and extract the image_id from the filename
|
| 139 |
match = re.search(r'_(\d+)\.', img)
|
|
@@ -204,7 +199,7 @@ def save_annotation(caption, session_data):
|
|
| 204 |
|
| 205 |
# # Clear user's current image if the validation image has been annotated twice
|
| 206 |
# if (split == "train" and annotation_count > 1) or (split == "dev" and annotation_count > 2):
|
| 207 |
-
|
| 208 |
|
| 209 |
# Fetch the next image
|
| 210 |
next_image = get_next_image(session_data)
|
|
|
|
| 20 |
with open('nearest_neighbors_with_captions.json', 'r') as f:
|
| 21 |
results = json.load(f)
|
| 22 |
|
|
|
|
|
|
|
| 23 |
# Load or create the dataset
|
| 24 |
try:
|
| 25 |
dataset = load_dataset(dataset_name, split="train")
|
|
|
|
| 29 |
# Check if the 'split' column exists; if not, add it
|
| 30 |
if 'split' not in dataset.column_names:
|
| 31 |
# Define the 'split' values based on `image_id`
|
|
|
|
|
|
|
| 32 |
split_values = [
|
| 33 |
"dev" if example["image_id"] in results else "train"
|
| 34 |
for example in dataset
|
|
|
|
| 129 |
|
| 130 |
# Iterate over each image file to apply the filtering logic
|
| 131 |
for img in image_files:
|
|
|
|
| 132 |
|
| 133 |
# Match and extract the image_id from the filename
|
| 134 |
match = re.search(r'_(\d+)\.', img)
|
|
|
|
| 199 |
|
| 200 |
# # Clear user's current image if the validation image has been annotated twice
|
| 201 |
# if (split == "train" and annotation_count > 1) or (split == "dev" and annotation_count > 2):
|
| 202 |
+
session_data["current_image"] = None
|
| 203 |
|
| 204 |
# Fetch the next image
|
| 205 |
next_image = get_next_image(session_data)
|