Spaces:
Sleeping
Sleeping
Commit
·
aa89488
1
Parent(s):
9aec593
updates
Browse files
app.py
CHANGED
|
@@ -7,6 +7,8 @@ from huggingface_hub import login
|
|
| 7 |
import json
|
| 8 |
import re
|
| 9 |
|
|
|
|
|
|
|
| 10 |
# Authenticate with Hugging Face
|
| 11 |
token = os.getenv("HUGGINGFACE_TOKEN")
|
| 12 |
if token:
|
|
@@ -52,6 +54,8 @@ try:
|
|
| 52 |
annotation_counts[image_id] = count
|
| 53 |
|
| 54 |
print("Annotation counts:", annotation_counts)
|
|
|
|
|
|
|
| 55 |
except Exception as e:
|
| 56 |
print(f"Error loading dataset: {e}")
|
| 57 |
# Create an empty dataset if it doesn't exist
|
|
@@ -102,9 +106,12 @@ def get_next_image(session_data):
|
|
| 102 |
# Available images filter
|
| 103 |
available_images = [
|
| 104 |
img for img in image_files
|
|
|
|
|
|
|
|
|
|
| 105 |
if img not in annotation_counts or
|
| 106 |
-
(
|
| 107 |
-
(
|
| 108 |
]
|
| 109 |
|
| 110 |
print("Available images:", available_images) # Debugging line
|
|
|
|
| 7 |
import json
|
| 8 |
import re
|
| 9 |
|
| 10 |
+
reset = True
|
| 11 |
+
|
| 12 |
# Authenticate with Hugging Face
|
| 13 |
token = os.getenv("HUGGINGFACE_TOKEN")
|
| 14 |
if token:
|
|
|
|
| 54 |
annotation_counts[image_id] = count
|
| 55 |
|
| 56 |
print("Annotation counts:", annotation_counts)
|
| 57 |
+
|
| 58 |
+
|
| 59 |
except Exception as e:
|
| 60 |
print(f"Error loading dataset: {e}")
|
| 61 |
# Create an empty dataset if it doesn't exist
|
|
|
|
| 106 |
# Available images filter
|
| 107 |
available_images = [
|
| 108 |
img for img in image_files
|
| 109 |
+
match = re.search(r'_(\d+)\.', img)
|
| 110 |
+
image_id = match.group(1).lstrip('0') # Remove leading zeros
|
| 111 |
+
|
| 112 |
if img not in annotation_counts or
|
| 113 |
+
(image_id in results and annotation_counts.get(img, 0) < 2) or
|
| 114 |
+
(image_id not in results and annotation_counts.get(img, 0) == 0)
|
| 115 |
]
|
| 116 |
|
| 117 |
print("Available images:", available_images) # Debugging line
|