合并分支

* Merge branch 'main' into cluster-gemini
* PERF 修复时间最大限制问题
* Merge branch 'main' into cluster-gemini
* FIX 修复缩放分辨率计算问题 ADD Gemini推理改为二阶段 FIX 修复时间合并计算问题
* Merge branch 'main' into cluster-gemini
* ADD gemini数据源使用cloud storage

---------

Merge request URL: https://g-ldyi2063.coding.net/p/dev/d/modalDeploy/git/merge/4819
Co-authored-by: 康宇佳
This commit is contained in:
康宇佳 2025-06-18 19:20:34 +08:00 committed by Coding
parent d394d822a9
commit dec1123534
3 changed files with 21 additions and 11 deletions

View File

@ -111,6 +111,13 @@ def merge_product_data(data, start_time_str, end_time_str, merge_diff=5):
end_time = parse_time(end_time_str)
duration = end_time - start_time
# 手动格式化时间差
total_seconds = duration.total_seconds()
hours, remainder = divmod(total_seconds, 3600)
minutes, seconds = divmod(remainder, 60)
microseconds = duration.microseconds
max_time_str = f"{int(hours):02d}:{int(minutes):02d}:{int(seconds):02d}.{microseconds//1000:03d}"
product_dict = {}
# 按产品名称分组
@ -133,7 +140,7 @@ def merge_product_data(data, start_time_str, end_time_str, merge_diff=5):
else:
new_start_str = start_str
if (parse_time(new_start_str) - datetime.strptime("00:00:00.000", '%H:%M:%S.%f')) > duration:
new_start_str = end_time_str
new_start_str = max_time_str
end_str = format_time(end)
if (end - datetime.strptime("00:00:00.000",'%H:%M:%S.%f')) > duration and not end_str.startswith("00"):
@ -141,7 +148,7 @@ def merge_product_data(data, start_time_str, end_time_str, merge_diff=5):
else:
new_end_str = end_str
if (parse_time(new_end_str) - datetime.strptime("00:00:00.000", '%H:%M:%S.%f')) > duration:
new_end_str = end_time_str
new_end_str = max_time_str
activity = item.split(' (', 1)[1].rstrip(')')
new_item = f"{new_start_str} - {new_end_str} ({activity})"
new_timeline.append(new_item)

View File

@ -112,9 +112,9 @@ with downloader_image.imports():
"matched_product": "匹配到的标准商品名称或null",
"match_confidence": 95,
"visual_features": {{
"color": "商品详细颜色配色等色彩特征",
"pattern": "商品详细图案纹理等材质特征",
"style": "商品详细款式版型等风格特征"
"color": "商品详细颜色配色等有辨识度的色彩特征",
"pattern": "商品详细图案纹理等有辨识度的材质特征",
"style": "商品详细款式版型等有辨识度的风格特征"
}}
}}
]
@ -142,9 +142,11 @@ with downloader_image.imports():
- (穿着本品+他品) - 主播穿着该商品但正在介绍其他商品
- (穿着本品+无关) - 主播穿着该商品但在做无关商品的事情
**时间格式要求**
- 格式HH:MM:SS.mmm - HH:MM:SS.mmm
- 示例00:05:23.500 表示0小时5分钟23.5
**时间格式标准**
- 必须严格使用格式HH:MM:SS.mmm - HH:MM:SS.mmm
- HH是小时(00-23)MM是分钟(00-59)SS是秒(00-59)mmm是毫秒(000-999)
- 示例00:05:23.500 表示0小时5分钟23.5不是5小时23分钟
- 常见错误不要将05:23:500解释为5小时23分钟应该是0小时5分钟23.5
**已识别商品清单(product-商品名 feature-商品特征 feature.color-商品详细颜色配色等色彩特征 feature.pattern-商品详细图案纹理等材质特征 feature.style-商品详细款式版型等风格特征)**
{IDENTIFIED_PRODUCTS}
@ -178,7 +180,7 @@ with downloader_image.imports():
f"Uploading name = {filename}, size = {content_length}, type = {content_type} to google file")
with httpx.Client(timeout=1800) as client:
upload_response = client.post(
url=f"https://storage.googleapis.com/upload/storage/v1/b/dy-media-storage/o?uploadType=media&name=video%2F{filename}",
url=f"https://storage.googleapis.com/upload/storage/v1/b/dy-media-storage/o?uploadType=media&name=videos%2F{filename}",
content=video,
headers={
"Authorization": f"Bearer {google_api_key}",
@ -186,7 +188,7 @@ with downloader_image.imports():
})
upload_response.raise_for_status()
upload_url = f"gs://dy-media-storage/video/{filename}"
upload_url = f"gs://dy-media-storage/videos/{filename}"
return upload_url, upload_response.status_code
@ -409,6 +411,7 @@ with downloader_image.imports():
parts = result_text.split("```")[-2].replace("```", "").replace("json\n", "").replace("\n",
"").replace("\\", "")
parts = json.loads(parts)
logger.info(f"👌合并前 {json.dumps(parts, indent=4, ensure_ascii=False)}")
# 合并产品和时间线
parts = merge_product_data(parts, start_time, end_time, merge_diff=5)
for part in parts:

View File

@ -271,7 +271,7 @@ with downloader_image.imports():
print(f"上传文件: {filename}, 大小: {content_length} bytes, 类型: {content_type}")
# 构建上传URL
object_name = f"videos/{filename}"
object_name = f"images/{filename}"
object_name_quote = object_name.replace("/", "%2F")
upload_url = f"https://storage.googleapis.com/upload/storage/v1/b/{bucket_name}/o?uploadType=media&name={object_name_quote}"