fix image
All checks were successful
Build and Deploy Backend / build-and-deploy (push) Successful in 5m17s

This commit is contained in:
repair-agent 2026-03-24 18:19:25 +08:00
parent fe0dcb78c3
commit f6d1559c90
2 changed files with 18 additions and 23 deletions

View File

@ -148,26 +148,20 @@ def generate_i2i_stream(user, badge_image, image_bytes, prompt='', style=None,
image_model = config.get('IMAGE_MODEL_NAME', 'doubao-seedream-4-5-251128') image_model = config.get('IMAGE_MODEL_NAME', 'doubao-seedream-4-5-251128')
image_size = f'{width}x{height}' image_size = f'{width}x{height}'
# 尝试带参考图的生成,若 SDK 不支持则回退到纯文生图 # 将前端 strength(0.1~1.0) 映射到 guidance_scale(1.0~20.0)
try: # strength 越大 → 越贴近参考图 → guidance_scale 越低(更依赖图片)
result = client.images.generate( # strength 越小 → 越自由发挥 → guidance_scale 越高(更依赖提示词)
model=image_model, guidance = 1.0 + (1.0 - strength) * 19.0
prompt=full_prompt,
size=image_size, result = client.images.generate(
response_format='url', model=image_model,
watermark=False, prompt=full_prompt,
reference_image=ref_url, size=image_size,
reference_strength=strength, response_format='url',
) watermark=False,
except TypeError: image=ref_url,
logger.warning('Seedream SDK does not support reference_image, falling back to t2i') guidance_scale=guidance,
result = client.images.generate( )
model=image_model,
prompt=full_prompt,
size=image_size,
response_format='url',
watermark=False,
)
temp_url = result.data[0].url temp_url = result.data[0].url

View File

@ -40,12 +40,13 @@ class DeviceBatchCreateSerializer(serializers.ModelSerializer):
class DeviceSerializer(serializers.ModelSerializer): class DeviceSerializer(serializers.ModelSerializer):
"""设备序列化器""" """设备序列化器"""
device_type = DeviceTypeSerializer(read_only=True)
device_type_info = DeviceTypeSerializer(source='device_type', read_only=True) device_type_info = DeviceTypeSerializer(source='device_type', read_only=True)
class Meta: class Meta:
model = Device model = Device
fields = ['id', 'sn', 'device_type', 'device_type_info', 'mac_address', fields = ['id', 'sn', 'device_type', 'device_type_info', 'mac_address',
'name', 'status', 'firmware_version', 'last_online_at', 'created_at'] 'name', 'status', 'firmware_version', 'last_online_at', 'created_at']