-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
schema.py
35 lines (32 loc) · 763 Bytes
/
schema.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import os
import weaviate
client = weaviate.Client(
url = "http://localhost:8080",
)
schemaConfig = {
'class': 'MyImages', # class name for schema config in Weaviate (change it with a custom name for your images)
'vectorizer': 'img2vec-neural',
'vectorIndexType': 'hnsw',
'moduleConfig': {
'img2vec-neural': {
'imageFields': [
'image'
]
}
},
'properties': [
{
'name': 'image',
'dataType': ['blob']
},
{
'name': 'text',
'dataType': ['string']
}
]
}
try:
client.schema.create_class(schemaConfig)
print("Schema defined")
except Exception:
print("Schema already defined, skipping...")