File size: 6,404 Bytes
3ab0a79
 
 
 
 
 
 
 
 
 
 
 
 
 
c3fb706
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3ab0a79
c3fb706
3ab0a79
c3fb706
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3ab0a79
391a49d
 
 
 
 
 
 
 
 
 
 
3ab0a79
c3fb706
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3ab0a79
 
 
c3fb706
 
 
 
 
 
 
 
 
3ab0a79
 
 
 
 
 
c3fb706
 
 
 
 
3ab0a79
 
 
c3fb706
 
 
 
 
3ab0a79
 
61aa9e5
3ab0a79
 
 
 
 
 
 
 
 
61aa9e5
3ab0a79
61aa9e5
 
 
 
 
 
 
 
 
 
c3fb706
 
 
 
391a49d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c3fb706
391a49d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3ab0a79
391a49d
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<!DOCTYPE html>
<html>
<head>
    <title>API Documentation</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            padding: 20px;
        }
        
        h1 {
            margin-bottom: 20px;
        }
        
        .endpoint {
            margin-bottom: 30px;
        }
        
        .endpoint h3 {
            margin-top: 0;
            font-size: 1.2em;
            font-weight: bold;
        }
        
        .method {
            margin-bottom: 10px;
        }
        
        .code-block {
            background-color: #f4f4f4;
            padding: 10px;
            font-family: monospace;
            margin-bottom: 20px;
        }
        
        .code-block pre {
            margin: 0;
        }
        
        .sample-code {
            background-color: #f4f4f4;
            padding: 10px;
            margin-bottom: 20px;
        }
        
        .sample-code pre {
            margin: 0;
            overflow-x: auto;
        }
        
        .image-style {
            width: 100px;
            height: auto;
        }
        
        .style-info {
            margin-top: 10px;
            font-size: 0.8em;
            color: #888;
        }
    </style>
    <script>
        document.addEventListener("DOMContentLoaded", function() {
            const endpoints = document.querySelectorAll(".endpoint");

            endpoints.forEach(function(endpoint) {
                const codeBlock = endpoint.querySelector(".code-block");
                const sampleCode = endpoint.querySelector(".sample-code");
                const showButton = document.createElement("button");
                showButton.textContent = "Show Example Code";

                showButton.addEventListener("click", function() {
                    codeBlock.style.display = "block";
                    sampleCode.style.display = "block";
                    showButton.style.display = "none";
                });

                endpoint.appendChild(showButton);
            });
        });
    </script>
</head>
<body>
    <h1>API Documentation</h1>
    
    <div class="endpoint">
        <h3>Generate Image</h3>
        <p class="method">Endpoint: <code>/api/generate</code></p>
        <p class="method">Method: <code>POST</code></p>
        <p class="method">Description: Generate an image based on the provided parameters.</p>
        <div class="code-block" style="display: none;">
            <p>Request Payload:</p>
            <pre>
{
    "prompt": "Woman sitting on a table, looking at the sky, seen from behind",
    "style": "ANIME_V2",
    "ratio": "RATIO_16X9",
    "model": "REALISTIC"
}
            </pre>
        </div>
        <div class="code-block" style="display: none;">
            <p>Response:</p>
            <pre>
{
    "error": "An error occurred while generating the image."
}
            </pre>
        </div>
        <div class="sample-code" style="display: none;">
            <p>Sample Code:</p>
            <pre>
import requests

url = 'https://imseldrith-imagine.hf.space/api/generate' 

headers = {'Content-Type':'application/json'}
payload = {
    'prompt': "Woman sitting on a table, looking at the sky, seen from behind",
    'style': 'ANIME_V2',
    'ratio': 'RATIO_16X9',
    'model': 'REALISTIC'
}

response = requests.post(url, json=payload)

if response.status_code == 200:
    # Image generation successful
    with open('generated_image.jpg', 'wb') as image_file:
        image_file.write(response.content)
    print('Image saved successfully!')
else:
    # Error occurred during image generation
    error_data = response.json()
    error_message = error_data.get('error', 'Unknown error')
    print(f'Failed to generate image: {error_message}')
            </pre>
        </div>
    </div>
    
    <div class="endpoint">
        <h3>Supported Ratios</h3>
        <div class="style-info">
            <p><strong>RATIO_1X1:</strong> 1:1</p>
            <p><strong>RATIO_4X3:</strong> 4:3</p>
            <p><strong>RATIO_3X2:</strong> 3:2</p>
            <p><strong>RATIO_2X3:</strong> 2:3</p>
            <p><strong>RATIO_16X9:</strong> 16:9</p>
            <p><strong>RATIO_9X16:</strong> 9:16</p>
            <p><strong>RATIO_5X4:</strong> 5:4</p>
            <p><strong>RATIO_4X5:</strong> 4:5</p>
            <p><strong>RATIO_3X1:</strong> 3:1</p>
            <p><strong>RATIO_3X4:</strong> 3:4</p>
        </div>
    </div>
    
    <div class="endpoint">
        <h3>Supported Models</h3>
        <div class="style-info">
            <p><strong>V4_BETA:</strong> V4(Beta)</p>
            <p><strong>CREATIVE:</strong> Creative</p>
            <p><strong>V3:</strong> V3</p>
            <p><strong>V1:</strong> V1</p>
            <p><strong>PORTRAIT:</strong> Portrait</p>
            <p><strong>REALISTIC:</strong> Realistic</p>
            <p><strong>ANIME:</strong> Anime</p>
        </div>
    </div>
    
    <div class="endpoint">
        <h3>Supported Styles</h3>
        <div class="style-info">
            <p><strong>NO_STYLE:</strong> No style</p>
            <p><strong>EUPHORIC:</strong> Euphoric</p>
            <p><strong>FANTASY:</strong> Fantasy</p>
            <p><strong>CYBERPUNK:</strong> Cyberpunk</p>
            <p><strong>STUDIO_GHIBLI:</strong> Studio Ghibli</p>
            <p><strong>DISNEY:</strong> Disney</p>
            <p><strong>GTA:</strong> GTA</p>
            <p><strong>KAWAII_CHIBI:</strong> Kawaii Chibi</p>
            <p><strong>ANIME_V2:</strong> Anime V2</p>
            <p><strong>ABSTRACT_VIBRANT:</strong> Abstract Vibrant</p>
            <p><strong>VIBRANT:</strong> Vibrant</p>
            <p><strong>PSYCHEDELIC:</strong> Psychedelic</p>
            <p><strong>EXTRA_TERRESTRIAL:</strong> Extra-terrestrial</p>
            <p><strong>COSMIC:</strong> Cosmic</p>
            <p><strong>MACRO_PHOTOGRAPHY:</strong> Macro Photography</p>
            <p><strong>PRODUCT_PHOTOGRAPHY:</strong> Product Photography</p>
            <p><strong>POLAROID:</strong> Polaroid</p>
            <p><strong>NEO_FAUVISM:</strong> Neo fauvism</p>
            <p><strong>POP_ART:</strong> Pop Art</p>
            <p><strong>POP_ART_II:</strong> Pop Art II</p>
            <p><strong>GRAFFITI:</strong> Graffiti</p>
            <p><strong>SURREALISM:</strong> Surrealism</p>
            <p><strong>BAUHAUS:</strong> Bauhaus</p>
        </div>
    </div>
</body>
  </html>