Ankitajadhav commited on
Commit
b7ea8ed
·
verified ·
1 Parent(s): c11b108

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -1
app.py CHANGED
@@ -60,4 +60,28 @@ IMAGE_FOLDER = 'images'
60
  image_uris = sorted([os.path.join(IMAGE_FOLDER, image_name) for image_name in os.listdir(IMAGE_FOLDER) if not image_name.endswith('.txt')])
61
  ids = [str(i) for i in range(len(image_uris))]
62
 
63
- collection_images.add(ids=ids, uris=image_uris)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  image_uris = sorted([os.path.join(IMAGE_FOLDER, image_name) for image_name in os.listdir(IMAGE_FOLDER) if not image_name.endswith('.txt')])
61
  ids = [str(i) for i in range(len(image_uris))]
62
 
63
+ collection_images.add(ids=ids, uris=image_uris)
64
+
65
+ # Path to the backup file
66
+ load_path = 'text_collection_backup.json'
67
+
68
+ # Load the data from the JSON file
69
+ with open(load_path, 'r') as f:
70
+ loaded_data = json.load(f)
71
+
72
+ # Extract the documents and IDs
73
+ loaded_documents = loaded_data['documents']
74
+ loaded_ids = loaded_data['ids']
75
+
76
+ # Assuming 'client' is already set up for ChromaDB
77
+ # Create or get a collection to store the loaded data
78
+ # collection_text = client.create_collection(
79
+ # name='collection_text', # Ensure the collection name is consistent if required
80
+ # embedding_function=default_ef # Use the same embedding function as before
81
+ # )
82
+ # Add data to the collection
83
+ collection_text.add(
84
+ documents=loaded_documents,
85
+ ids=loaded_ids
86
+ )
87
+