File size: 1,821 Bytes
273b8b1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import os
from openai import OpenAI
from PIL import Image
from io import BytesIO
import base64
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from config import api_key, base_url

# OpenAI API configuration
API_KEY = api_key
API_PROVIDER = base_url

client = OpenAI(
    api_key=API_KEY,
    base_url=API_PROVIDER,
)


from openai import OpenAI
import base64
import os

client = OpenAI(
    api_key=API_KEY,
    base_url=API_PROVIDER
)

result = client.images.generate(
    model="gpt-image-1",
    prompt=prompt,
    n=1, # 单次出图数量,最多 10 张
    size="1024x1024", # 1024x1024 (square), 1536x1024 (3:2 landscape), 1024x1536 (2:3 portrait), auto (default) 
    quality="low", # high, medium, low, auto (default)
    moderation="low", # low, auto (default) 需要升级 openai 包 📍
    background="auto", # transparent, opaque, auto (default)
)


design_prompt_template = """
[TASK START]
OBJECTIVE: Generate a text-to-image prompt for a single, isolated clipart icon based on the provided inputs.

INPUTS:
Topic: TOPIC_PLACEHOLDER
Style Keyword: STYLE_KEYWORD_PLACEHOLDER

PROCESS:

Conceptualize: First, determine a single, specific, and universally recognizable visual concept (a concrete object or scene) that best represents the broad Topic.
Generate: Second, write a text-to-image prompt describing this visual concept, rendered using the specified Style Keyword.

CONSTRAINTS:

The output must be a single icon or a small, unified group of objects.
The icon MUST be isolated on a plain white background.
The final prompt must be concise and descriptive.

REQUIRED OUTPUT: (Provide your answer in this exact structure)
Selected Concept: [The specific visual metaphor you chose for the topic]
Image Prompt: [The final text-to-image prompt]

[TASK END]
"""