This commit is contained in:
felix
2025-11-22 19:19:58 +08:00
parent 3185bcba65
commit 0d871644f0

View File

@@ -164,23 +164,6 @@ class ImageService:
"""计算图片的SHA256哈希值"""
return hashlib.sha256(image_bytes).hexdigest()
@staticmethod
def _local_embedding(image_bytes: bytes) -> np.ndarray:
"""本地嵌入生成回退方法"""
try:
# 使用轻量级模型生成嵌入 (示例使用伪代码)
img = PILImage.open(io.BytesIO(image_bytes))
img = img.resize((224, 224))
img_array = np.array(img) / 255.0
# 伪代码 - 实际应使用预训练模型
embedding = np.random.rand(1024)
embedding = embedding / np.linalg.norm(embedding)
return embedding
except Exception as e:
logger.error(f"Local embedding failed: {str(e)}")
return np.zeros(1024) # 返回零向量
@staticmethod
async def generate_thumbnail(image_id: int, file_id: int) -> None:
"""生成缩略图并更新image记录"""