File size: 3,269 Bytes
a2a83e2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
"""
Utility functions for Image Creation Studio
"""

def validate_prompt(prompt: str) -> bool:
    """Validate that prompt is not empty"""
    return bool(prompt and prompt.strip())


def format_lora_string(loras: list) -> str:
    """Format LoRA names for prompt"""
    if not loras:
        return ""
    return ", ".join([f"<lora:{name}:1.0>" for name in loras])


def parse_seed(seed_input: str) -> int:
    """Parse seed input, returning -1 for random"""
    if seed_input == "-1" or seed_input == "":
        return -1
    try:
        return int(seed_input)
    except ValueError:
        return -1


def get_model_info(model_name: str) -> dict:
    """Get model information"""
    models = {
        "Stable Diffusion 1.5": {
            "base": "SD 1.5",
            "recommended_steps": 20-30,
            "recommended_guidance": 7-8
        },
        "Stable Diffusion 2.1": {
            "base": "SD 2.1",
            "recommended_steps": 25-35,
            "recommended_guidance": 7-8
        },
        "Stable Diffusion XL 1.0": {
            "base": "SDXL",
            "recommended_steps": 30-50,
            "recommended_guidance": 6-8
        },
    }
    return models.get(model_name, {})


def create_negative_prompt_template() -> str:
    """Create a default negative prompt"""
    return "lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry"


# Example prompts for various styles
EXAMPLE_PROMPTS = {
    "photorealistic": "masterpiece, best quality, photorealistic, 8k, professional photography, detailed, natural lighting",
    "anime": "anime style, illustration, colorful, vibrant, detailed background, anime art",
    "digital_art": "digital painting, concept art, detailed, intricate, beautiful composition",
    "3d_render": "3d render, c4d, blender, octane render, detailed, realistic lighting",
    "oil_painting": "oil painting, painterly, artstation, detailed brushstrokes, classical art",
}


def get_example_prompt(style: str) -> str:
    """Get example prompt for a style"""
    return EXAMPLE_PROMPTS.get(style, "")

This is a comprehensive Gradio 6 image creation application with:

## Features:

### 1. **Text to Image Generation**
- Multiple Stable Diffusion models (SD 1.5, SD 2.1, SDXL, etc.)
- Aspect ratio presets (Square, Portrait, Landscape, etc.)
- Adjustable steps, guidance scale, and seed
- Hi-Res Fix for upscaling

### 2. **Prompt Enhancement**
- Three enhancement levels: subtle, moderate, extreme
- Adds quality tags, lighting, and detail keywords
- Copy enhanced prompt to main input

### 3. **LoRA Integration (civitai.com)**
- Search LoRAs from civitai.com
- Browse by category (Style, Character, Concept, Detail)
- Select multiple LoRAs for generation
- View download counts and ratings

### 4. **Additional Tabs**
- **Image to Image**: Transform existing images
- **Inpainting**: Edit specific areas
- **Prompt Builder**: Interactive visual prompt creation
- **Settings**: API configuration and defaults

### 5. **UI Features**
- Custom theme with soft colors
- Accordions for organized settings
- Examples for quick testing
- "Built with anycoder" link in header