可以用openai的最gpt-image-1或者google的gemini的api实现
我们以免费的gemini api为例来实现:
+
让左面美女的手中拿的盒子变成吹分机

点击查看全文
from google import genai
from google.genai import types
from PIL import Image
from io import BytesIO
#
import PIL.Image
image1 = PIL.Image.open('prod2.png')
image2 = PIL.Image.open('prod3.png')
client = genai.Client(api_key="apikey")
text_input = ('更新图片:图片1中的人物手中拿的物品更换成图片2,并保持整体协调')
response = client.models.generate_content(
model="gemini-2.0-flash-exp-image-generation",
contents=[text_input, image1,image2],
config=types.GenerateContentConfig(
response_modalities=['TEXT', 'IMAGE']
)
)
for part in response.candidates[0].content.parts:
if part.text is not None:
print(part.text)
elif part.inline_data is not None:
image = Image.open(BytesIO(part.inline_data.data))
image.show() 网友回复
有没有不依赖embedding向量的RAG技术?
有没有支持实时打断语音通话并后台帮你执行任何的ai模型?
开源ai大模型文件格式GGUF、MLX、Safetensors、 ONNX 有什么区别?
出海挣钱支付收款PayPal、Wise 、PingPong、Stripe如何选择?
如何实现类似google的图片隐形水印添加和识别技术?
linux上如何运行任意windows程序?
ai能写出比黑客还厉害的零日漏洞等攻击工具攻击任意软件系统工程?
js如何获取浏览器的音频上下文指纹、Canvas指纹、WebGL渲染特征?
为啥ai开始抛弃markdown文本,重新偏好html文本了?
网站有没有办法鉴别访问请求是由ai操控chrome-devtools-mcp发出的?


