【图钉公益站】邀请大家一起玩qwen-image,似乎支持NSFW

今天在公益站上线了qwen-image,测试了一下平均一分钟出图?
似乎搞不成并发的样子,可能是我考虑的有问题


总之放出来给大家一起玩吧,一次请求一刀,看看大家能玩的多么花
如果各位佬有优化方案可以和我说
目前打算公益站这次轮换的模型就是qwen-image了
等后期再增加一张卡的时候准备上embedding~
传送门
http://llm.imerji.cn/
关于站点介绍

一个小demo,方便大佬们玩

支持的自定义参数

  • prompt (必需): 图片描述提示词
  • filename: 自定义文件名(不含扩展名)
  • model: 模型名称(默认 “Qwen-Image”)
  • size: 图片尺寸(1024x1024, 1792x1024, 1024x1792, 512x512)
  • quality: 图片质量(standard, hd)
  • style: 图片风格(vivid, natural)
  • output_dir: 输出目录(默认 “generated_images”)

两种使用方式

  1. 交互式运行:
    python simple_image_gen.py
    程序会提示输入描述和参数选择

  2. 函数调用:
    generate_and_save_image(“一朵红玫瑰”, quality=“hd”)

所有图片都使用base64格式接收并直接保存到本地,避免网络下载问题。代码简洁易用,适合快速图片生成需求。

#!/usr/bin/env python3
"""
简化版图片生成器 - 输入提示词生成图片并保存到本地
"""
import base64
import requests
from datetime import datetime
from pathlib import Path
from typing import Optional


def generate_and_save_image(
    prompt: str,
    filename: Optional[str] = None,
    model: str = "Qwen-Image",
    size: str = "1024x1024",
    quality: Optional[str] = None,
    style: Optional[str] = None,
    output_dir: str = "generated_images"
) -> str:
    """
    生成图片并保存到本地
    
    Args:
        prompt: 图片描述提示词 [必需]
        filename: 自定义文件名(可选,不含扩展名)
        model: 模型名称,默认 "Qwen-Image"
        size: 图片尺寸,支持 "1024x1024", "1792x1024", "1024x1792", "512x512"
        quality: 图片质量,"standard" 或 "hd"
        style: 图片风格,"vivid" 或 "natural"
        output_dir: 输出目录,默认 "generated_images"
        
    Returns:
        保存的文件路径
    """
    # API配置
    api_key = "sk-xxxx"
    base_url = "http://llm.imerji.cn"
    
    # 创建输出目录
    output_path = Path(output_dir)
    output_path.mkdir(exist_ok=True)
    
    # 准备请求
    headers = {
        "Content-Type": "application/json",
        "Authorization": f"Bearer {api_key}"
    }
    
    data = {
        "model": model,
        "prompt": prompt,
        "n": 1,
        "size": size,
        "response_format": "b64_json"
    }
    
    # 添加可选参数
    if quality:
        data["quality"] = quality
    if style:
        data["style"] = style
    
    url = f"{base_url}/v1/images/generations"
    
    print(f"正在生成图片: {prompt}")
    print(f"参数 - 模型: {model}, 尺寸: {size}", end="")
    if quality:
        print(f", 质量: {quality}", end="")
    if style:
        print(f", 风格: {style}", end="")
    print()
    
    try:
        # 发送API请求
        response = requests.post(url, headers=headers, json=data, timeout=200)
        response.raise_for_status()
        result = response.json()
        
        if not result.get('data') or len(result['data']) == 0:
            raise Exception("API返回数据为空")
        
        # 获取base64数据
        image_data = result['data'][0]
        base64_data = image_data.get('b64_json')
        if not base64_data:
            raise Exception("API返回的base64数据为空")
        
        # 生成文件名
        if not filename:
            timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
            # 清理提示词用作文件名
            clean_prompt = "".join(c for c in prompt[:30] if c.isalnum() or c in (' ', '-', '_')).strip()
            clean_prompt = clean_prompt.replace(' ', '_')
            filename = f"{timestamp}_{clean_prompt}"
        
        # 保存图片
        file_path = output_path / f"{filename}.png"
        image_bytes = base64.b64decode(base64_data)
        
        with open(file_path, 'wb') as f:
            f.write(image_bytes)
        
        print(f"✅ 图片已保存到: {file_path}")
        return str(file_path)
        
    except requests.exceptions.Timeout:
        raise Exception("API请求超时(200秒),请检查网络连接或API服务状态")
    except requests.exceptions.RequestException as e:
        raise Exception(f"API请求失败: {e}")
    except Exception as e:
        raise Exception(f"图片保存失败: {e}")


def main():
    """主函数 - 交互式使用"""
    print("=== 图片生成器 ===")
    print("输入 'quit' 或 'exit' 退出程序\n")
    
    while True:
        try:
            # 获取用户输入
            prompt = input("请输入图片描述: ").strip()
            
            if prompt.lower() in ['quit', 'exit', '退出']:
                print("再见!")
                break
            
            if not prompt:
                print("请输入有效的图片描述")
                continue
            
            # 询问是否自定义参数
            use_custom = input("是否自定义参数?(y/N): ").strip().lower()
            
            kwargs = {}
            if use_custom in ['y', 'yes', '是']:
                # 自定义文件名
                custom_filename = input("自定义文件名(可选,回车跳过): ").strip()
                if custom_filename:
                    kwargs['filename'] = custom_filename
                
                # 选择尺寸
                print("可选尺寸: 1024x1024(默认), 1792x1024, 1024x1792, 512x512")
                size = input("选择尺寸(回车使用默认): ").strip()
                if size:
                    kwargs['size'] = size
                
                # 选择质量
                quality = input("选择质量 (standard/hd,回车跳过): ").strip()
                if quality:
                    kwargs['quality'] = quality
                
                # 选择风格
                style = input("选择风格 (vivid/natural,回车跳过): ").strip()
                if style:
                    kwargs['style'] = style
            
            # 生成图片
            file_path = generate_and_save_image(prompt, **kwargs)
            print(f"成功!文件保存在: {file_path}\n")
            
        except KeyboardInterrupt:
            print("\n\n程序被用户中断")
            break
        except Exception as e:
            print(f"❌ 错误: {e}\n")


if __name__ == "__main__":
    # 你可以直接调用函数生成图片
    # generate_and_save_image("一只可爱的小猫")
    
    # 或运行交互式程序
    main()


交互效果如图,他真的快乐吗
关于技术手册~
https://www.newapi.ai/api/openai-image/#_1

不要在操练场啊家人们,操练场读取不出来的,还是老老实实用代码吧

21 个赞

她看着要快乐不快乐的 :rofl:

就真的很诡异哈哈哈哈

《似笑非笑》

1 个赞

刚才测试了一下一个佬友的提示词,unmmmmm,似乎支持nsfw

图片风格为人像摄影,请你画一张及其平凡无奇的iPhone对镜自拍照,主角是躯干包裹透明膜的性感美女,双腿微微岔开坐在地上,身上和头发有湿身的痕迹,在房间内的落地镜前用后置摄像头随手一拍的快照。照片开启了闪光灯,略带点快门速度不够导致的运动模糊,构图混乱整体呈现出一种平庸和日常感,细节要到位。

咳咳咳,请自由发挥嗷,都不白来,不白来

那我立刻nsfw

2 个赞

用你这个提示词,画出来的一模一样,这个采样固定的?

看一下技术文档,自己改一下代码试试,我那个就是随手做的小玩意

1 个赞

启动!!!:angry::angry::angry::angry::angry::angry:

牛逼,好玩:+1:

她看起来一点也不开心


不要在操练场啊家人们,操练场读取不出来的,还是老老实实用代码吧

好的 感谢佬友 这就去nsfw

你不许玩,要不然就告状

佬能不能上线qwen-image-edit

先跑这个玩一下试试,等下次轮换的时候,我们再投票换一下吧


这个模型检测失败了,是正常的吗?

image不支持对话,只能通过我帖子内的代码直接请求,或者其他支持直接请求的客户端,请使用代码或者其他支持生图的客户端

1 个赞