readme
This commit is contained in:
@@ -95,7 +95,7 @@ def create_highlighted_visualization(image: Image.Image, masks, output_path: str
|
||||
# Save
|
||||
Image.fromarray(result_np).save(output_path)
|
||||
|
||||
def analyze_demographics_with_qwen(image_path: str) -> dict:
|
||||
def analyze_demographics_with_qwen(image_path: str, model_name: str = 'qwen-vl-max') -> dict:
|
||||
"""
|
||||
调用 Qwen-VL 模型分析人物的年龄和性别
|
||||
"""
|
||||
@@ -122,7 +122,7 @@ def analyze_demographics_with_qwen(image_path: str) -> dict:
|
||||
]
|
||||
|
||||
# 调用模型
|
||||
response = MultiModalConversation.call(model=QWEN_MODEL, messages=messages)
|
||||
response = MultiModalConversation.call(model=model_name, messages=messages)
|
||||
|
||||
if response.status_code == 200:
|
||||
content = response.output.choices[0].message.content[0]['text']
|
||||
@@ -143,7 +143,8 @@ def process_face_segmentation_and_analysis(
|
||||
processor,
|
||||
image: Image.Image,
|
||||
prompt: str = "head",
|
||||
output_base_dir: str = "static/results"
|
||||
output_base_dir: str = "static/results",
|
||||
qwen_model: str = "qwen-vl-max"
|
||||
) -> dict:
|
||||
"""
|
||||
核心处理逻辑:
|
||||
@@ -208,7 +209,7 @@ def process_face_segmentation_and_analysis(
|
||||
cropped_img.save(save_path)
|
||||
|
||||
# 3. 识别
|
||||
analysis = analyze_demographics_with_qwen(save_path)
|
||||
analysis = analyze_demographics_with_qwen(save_path, model_name=qwen_model)
|
||||
|
||||
# 构造返回结果
|
||||
# 注意:URL 生成需要依赖外部的 request context,这里只返回相对路径或文件名
|
||||
|
||||
Reference in New Issue
Block a user