Created
January 29, 2024 03:40
-
-
Save Muazzeem/a501d1d1ab1ad4e1c6a27533be18851f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from google.cloud import storage | |
bucket_name = "" | |
folder_name = "unchecked_checkbox" | |
def list_items_in_folder(folder_path): | |
client = storage.Client() | |
bucket = client.get_bucket(bucket_name) | |
# List objects in the specified folder path | |
blobs = bucket.list_blobs(prefix=folder_path) | |
# Print the names of the items in the folder | |
list_of_items = [] | |
for blob in blobs: | |
data = { | |
"imageGcsUri": f"gs://{bucket_name}/{blob.name}", | |
"classificationAnnotation": { | |
"displayName": f"{folder_name}" | |
} | |
} | |
list_of_items.append(data) | |
with open(f'{folder_name}.jsonl', 'w') as file: | |
for entry in list_of_items: | |
json.dump(entry, file) | |
file.write('\n') | |
list_items_in_folder( | |
'images_for_vision_ai/new_dataset/cropped_images_v2/unchecked' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment