批量处理可按照以下步骤操作:
- Organização de documentos:将所有待处理图片放入统一目录(如/imgs/batch_input/)
- Scripting:使用Python循环遍历目录文件,核心代码示例:
for img_file in os.listdir('imgs/batch_input'):
client.images.edit(image=open(f'imgs/batch_input/{img_file}','rb'),
prompt="Convert to van gogh style") - Economia de resultados:为每个输出文件添加编号或前缀避免覆盖
- Monitoramento de recursos:批量处理时注意API调用频率限制,建议每10秒不超过5次请求
项目提供了batch_processing.py示例脚本,可直接修改使用。
Essa resposta foi extraída do artigoGPT-Image-Edit: ferramenta para editar e gerar imagens usando comandos de textoO