-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathplayground.py
More file actions
50 lines (39 loc) · 1.29 KB
/
playground.py
File metadata and controls
50 lines (39 loc) · 1.29 KB
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
import os
from typing import Dict, Literal
from microsoftdesigner.gen_images import create_img
from dotenv import load_dotenv
load_dotenv()
ResolutionType = Literal['square', 'widescreen', 'portrait']
RESOLUTIONS: Dict[ResolutionType, str] = {
'square': '1024x1024',
'portrait': '1024x1792',
'widescreen': '1792x1024' # Fixed typo in 'portrait'
}
ACTIONS = [
"sitting",
"riding",
"laying",
]
PROMPTS = [f"anime girl {action} on an exercise ball in a room with exercise balls" for action in ACTIONS ]
DEFAULT_NUM_IMAGES = 40
def generate_images(
prompt: str,
resolution_type: ResolutionType = 'widescreen',
) -> None:
"""
Generate images using Microsoft Designer API.
Args:
prompt: The text prompt for image generation
resolution_type: Type of resolution from RESOLUTIONS
num_images: Number of images to generate
"""
user_id = os.getenv("USER_ID")
auth_token = os.getenv("AUTH_TOKEN")
if not user_id or not auth_token:
raise ValueError("USER_ID and AUTH_TOKEN must be set in .env file")
# for _ in range(num_images):
resolution = RESOLUTIONS[resolution_type]
create_img(user_id, auth_token, prompt, resolution=resolution)
if __name__ == "__main__":
prompt = PROMPTS[1]
generate_images(prompt)