Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
image_search
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
service
image_search
Commits
1bd6fd5b
Commit
1bd6fd5b
authored
1 month ago
by
zhengyaoqiu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
创建表&索引
parent
256977d0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
create.py
app/tmp/db/create.py
+26
-0
No files found.
app/tmp/db/create.py
0 → 100644
View file @
1bd6fd5b
from
typing
import
List
from
pymilvus
import
FieldSchema
,
DataType
from
app.services.milvus
import
MilvusClient
def
main
():
host
=
"10.0.40.12"
fields
:
List
[
FieldSchema
]
=
[
FieldSchema
(
name
=
"image"
,
dtype
=
DataType
.
VARCHAR
,
max_length
=
256
,
is_primary
=
True
,
auto_id
=
False
),
FieldSchema
(
name
=
"key"
,
dtype
=
DataType
.
VARCHAR
,
max_length
=
256
),
FieldSchema
(
name
=
"vector"
,
dtype
=
DataType
.
FLOAT_VECTOR
,
dim
=
512
)
# CLIP ViT-B/32的特征维度为512
]
MilvusClient
(
host
=
host
)
.
connect
()
.
create_collection
(
"mpc"
,
fields
,
"mpc 图片向量存储"
)
index_params
=
{
"index_type"
:
"HNSW"
,
"metric_type"
:
"IP"
,
# 内积相似度
"params"
:
{
"M"
:
40
,
"efConstruction"
:
600
,
"ef"
:
400
}
}
MilvusClient
(
host
=
host
)
.
connect
()
.
create_index
(
"mpc"
,
"vector"
,
index_params
)
if
__name__
==
"__main__"
:
main
()
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment