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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<!-- smartphone fix -->
|
6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
7 |
+
<title>Stable Diffusion</title>
|
8 |
+
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
9 |
+
<!--Bootstrap -->
|
10 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.1/js/bootstrap.min.js" integrity="sha512-fHY2UiQlipUq0dEabSM4s+phmn+bcxSYzXP4vAXItBvBHU7zAM/mkhCZjtBEIJexhOMzZbgFlPLuErlJF2b+0g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
11 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.1/css/bootstrap.min.css" integrity="sha512-Z/def5z5u2aR89OuzYcxmDJ0Bnd5V1cKqBEbvLOiUNWdg9PQeXVvXLI90SE4QOHGlfLqUnDNVAYyZi8UwUTmWQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
12 |
+
</head>
|
13 |
+
<body style="padding-inline: 0.5em;padding-block: 0.5em;">
|
14 |
+
<label for="promptInput" class="form-label">Prompt:</label>
|
15 |
+
<input type="text" id="promptInput" class="form-control" placeholder="Prompt">
|
16 |
+
<br>
|
17 |
+
<label for="negativePromptInput" class="form-label">Negative Prompt:</label>
|
18 |
+
<input type="text" id="negativePromptInput" class="form-control" placeholder="Negative prompt">
|
19 |
+
<br>
|
20 |
+
<div class="row">
|
21 |
+
<div class="col">
|
22 |
+
<label for="styleSelect" class="form-label">Style:</label>
|
23 |
+
<select id="styleSelect" class="form-select">
|
24 |
+
</select>
|
25 |
+
</div>
|
26 |
+
<div class="col">
|
27 |
+
<label for="sizeSelect" class="form-label">Image dimensions:</label>
|
28 |
+
<select id="sizeSelect" class="form-select">
|
29 |
+
<option value="square">Square</option>
|
30 |
+
<option value="portrait">Portrait</option>
|
31 |
+
<option value="landscape">Landscape</option>
|
32 |
+
<option value="stories">Stories</option>
|
33 |
+
<option value="ultrawide">Ultrawide</option>
|
34 |
+
</select>
|
35 |
+
</div>
|
36 |
+
</div>
|
37 |
+
<br>
|
38 |
+
<!--Advanced options-->
|
39 |
+
<div class="accordion accordion-flush" id="accordionFlushAdvancedOptions">
|
40 |
+
<div class="accordion-item">
|
41 |
+
<h2 class="accordion-header">
|
42 |
+
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapseOne" aria-expanded="false" aria-controls="flush-collapseOne">
|
43 |
+
Advanced options
|
44 |
+
</button>
|
45 |
+
</h2>
|
46 |
+
<div id="flush-collapseOne" class="accordion-collapse collapse" data-bs-parent="#accordionFlushAdvancedOptions">
|
47 |
+
<br>
|
48 |
+
<!--Number of inference steps-->
|
49 |
+
<label for="numInferenceStepsInput" class="form-label">Number of inference steps:</label>
|
50 |
+
<input type="number" id="numInferenceStepsInput" class="form-control" value="20" placeholder="Number of inference steps" min="0" max="30">
|
51 |
+
<br>
|
52 |
+
<!--Guidance scale-->
|
53 |
+
<label for="guidanceScaleInput" class="form-label">Guidance Scale:</label>
|
54 |
+
<input type="number" id="guidanceScaleInput" class="form-control" value="7.5" placeholder="guidanceScale" min="4" max="10">
|
55 |
+
<br>
|
56 |
+
<!--Seed-->
|
57 |
+
<label for="seedInput" class="form-label">Seed:</label>
|
58 |
+
<input type="number" id="seedInput" class="form-control" value="0" placeholder="Seed" min="0">
|
59 |
+
<br>
|
60 |
+
<!--Deepinfra API token-->
|
61 |
+
<label for="authTokenInput" class="form-label">Deepinfra API token:</label>
|
62 |
+
<input type="password" id="authTokenInput" class="form-control" placeholder="Deepinfra API token">
|
63 |
+
</div>
|
64 |
+
</div>
|
65 |
+
</div>
|
66 |
+
<br>
|
67 |
+
<button id="generateButton" class="btn btn-primary">Generate image</button>
|
68 |
+
<br><br>
|
69 |
+
<img id="generatedImage" style="max-width: 90vw;" width="512">
|
70 |
+
</body>
|
71 |
+
<script type="module">
|
72 |
+
|
73 |
+
const stylesArray = [
|
74 |
+
{
|
75 |
+
name:'Default',
|
76 |
+
prompt: '',
|
77 |
+
negative_prompt: ''
|
78 |
+
},
|
79 |
+
{
|
80 |
+
name:'Anime',
|
81 |
+
prompt: ',realistic anime, realistic manga, illustration, artwork, realistic anime illumination, realistic anime shading, [realistic anime Deviantart], [realistic anime Artstation], realistic anime wallpaper,[realistic anime fanart], [realistic anime Pinterest], realistic and detailed anime background, realistic anime shadows,',
|
82 |
+
negative_prompt: ',black and white,b&w, monochrome, 3d render, photography, photo, [cartoon], abstract art, poorly drawn, (text), (dialog bubble), (letters), [cartoon comics], [superhero comics], signature, [minimalist art], 3d model, amateur anime artist,canvas frame,bad art,ugly,nude,porn,naked,nsfw,hentai,'
|
83 |
+
},
|
84 |
+
{
|
85 |
+
name:'Photo',
|
86 |
+
prompt: ',sharp image, full hd, 1080p,4k, [8k] ,[uhd], high quality, detailed, high resolution, [high res],[RAW photo], [HDR], [hard shadows], [cinematic shot], [dramatic lighting], [soft lighting], [dslr], professional photographer,photorealistic, realistic,real,',
|
87 |
+
negative_prompt: ',blurry, low res, low resolution, low quality,ugly,nude,porn,naked,nsfw,hentai,'
|
88 |
+
},
|
89 |
+
{
|
90 |
+
name:'Renaissance',
|
91 |
+
prompt: ',renaissance painting style, [chiaroscuro],[detailed brushwork],[classical beauty],oil on canvas,[classical art],[historical art],oil painting,[fine details],[perspective],[masterpiece],[artwork style],[sharp image],[high resolution],[detailed],[professional style],[frescoes],',
|
92 |
+
negative_prompt: ',(black and white),sepia,blurry, low res, low resolution, low quality,ugly,artist painting,artist drawing,(digital painting style),3d render,photo,nude,porn,naked,nsfw,'
|
93 |
+
},
|
94 |
+
{
|
95 |
+
name:'Impressionism',
|
96 |
+
prompt: ',impressionist painting style,[brushstrokes],[loose brushwork style],[natural light],[vibrant colors],[oil on canvas],',
|
97 |
+
negative_prompt: ',(black and white),sepia, low res, low resolution, low quality,ugly,artist painting,artist drawing,(digital painting style),3d render,photo,nude,porn,naked,nsfw,'
|
98 |
+
},
|
99 |
+
{
|
100 |
+
name:'Painting',
|
101 |
+
prompt: ',(painting style),artwork style,[masterpiece],art style,[sharp image],[high resolution],[beautiful],[detailed],[professional style],',
|
102 |
+
negative_prompt: ',blurry, low res, low resolution, low quality,ugly,artist painting,artist drawing,digital painting style,nude,porn,naked,nsfw,'
|
103 |
+
},
|
104 |
+
{
|
105 |
+
name:'Illustration',
|
106 |
+
prompt: ',illustration,artwork style,masterpiece,art style,sharp image,high resolution,beautiful,detailed,professional style,',
|
107 |
+
negative_prompt: ',blurry, low res, low resolution, low quality,ugly,artist painting,artist drawing,nude,porn,naked,nsfw,'
|
108 |
+
},
|
109 |
+
{
|
110 |
+
name: "Art Nouveau",
|
111 |
+
prompt: ",Art Nouveau, beautiful art, sleek, organic forms, long, sinuous, art nouveau style,",
|
112 |
+
negative_prompt: ",ugly, deformed, noisy, blurry, low contrast, industrial, mechanical,"
|
113 |
+
},
|
114 |
+
{
|
115 |
+
name: "Faded Polaroid Photo",
|
116 |
+
prompt: ",Faded Polaroid Photo, analog, old faded photo, old polaroid,",
|
117 |
+
negative_prompt: ",ugly, deformed, noisy, blurry, low contrast, vibrant, colorful,"
|
118 |
+
},
|
119 |
+
{
|
120 |
+
name: "Japanese Ink Drawing",
|
121 |
+
prompt: ",Japanese Ink Drawing, ink drawing, inkwash, Japanese Ink Drawing,",
|
122 |
+
negative_prompt: ",ugly, deformed, noisy, blurry, low contrast, colorful, vibrant,"
|
123 |
+
},
|
124 |
+
{
|
125 |
+
name: "Rococo",
|
126 |
+
prompt: ",Rococo, flamboyant, pastel colors, curved lines, elaborate detail, Rococo,",
|
127 |
+
negative_prompt: ",ugly, deformed, noisy, blurry, low contrast,"
|
128 |
+
},
|
129 |
+
{
|
130 |
+
name: "Sticker Designs",
|
131 |
+
prompt: ",Vector Art Stickers, professional vector design, sticker designs, Sticker Sheet,",
|
132 |
+
negative_prompt: ",ugly, deformed, noisy, blurry, low contrast,"
|
133 |
+
},
|
134 |
+
{
|
135 |
+
name: "Action Figure",
|
136 |
+
prompt: ",Action Figure, plastic collectable action figure, collectable toy action figure,",
|
137 |
+
negative_prompt: ",ugly, deformed, noisy, blurry, low contrast,"
|
138 |
+
},
|
139 |
+
{
|
140 |
+
name: "Art Deco",
|
141 |
+
prompt: ",Art Deco, sleek, geometric forms, art deco style,",
|
142 |
+
negative_prompt: ",ugly, deformed, noisy, blurry, low contrast,"
|
143 |
+
},
|
144 |
+
{
|
145 |
+
name: "Flat 2D Art",
|
146 |
+
prompt: ",Flat 2D Art, simple flat color, 2-dimensional, Flat 2D Art Style,",
|
147 |
+
negative_prompt: ",ugly, deformed, noisy, blurry, low contrast, 3D, photo, realistic,"
|
148 |
+
},
|
149 |
+
{
|
150 |
+
name: "Baroque",
|
151 |
+
prompt: ",Baroque, dramatic, exuberant, grandeur, baroque art,",
|
152 |
+
negative_prompt: ",ugly, deformed, noisy, blurry, low contrast,"
|
153 |
+
},
|
154 |
+
{
|
155 |
+
name: "Doodle Art",
|
156 |
+
prompt: ",Doodle Art Style, drawing, freeform, swirling patterns, doodle art style,",
|
157 |
+
negative_prompt: ",ugly, deformed, noisy, blurry, low contrast,"
|
158 |
+
},
|
159 |
+
{
|
160 |
+
name: "Medievalism",
|
161 |
+
prompt: ",Medievalism, inspired by The Middle Ages, medieval art, elaborate patterns and decoration, Medievalism,",
|
162 |
+
negative_prompt: ",ugly, deformed, noisy, blurry, low contrast,"
|
163 |
+
},
|
164 |
+
{
|
165 |
+
name: "Pencil Sketch Drawing",
|
166 |
+
prompt: ",Pencil Sketch Drawing, black and white drawing, graphite drawing,",
|
167 |
+
negative_prompt: ",ugly, deformed, noisy, blurry, low contrast,"
|
168 |
+
},
|
169 |
+
{
|
170 |
+
name: "3D Model",
|
171 |
+
prompt: ",professional 3d model, octane render, highly detailed, volumetric, dramatic lighting,",
|
172 |
+
negative_prompt: ",ugly, deformed, noisy, low poly, blurry, painting,"
|
173 |
+
},
|
174 |
+
{
|
175 |
+
name: "Analog Film",
|
176 |
+
prompt: ",analog film photo, faded film, desaturated, 35mm photo, grainy, vignette, vintage, Kodachrome, Lomography, stained, highly detailed, found footage,",
|
177 |
+
negative_prompt: ",painting, drawing, illustration, glitch, deformed, mutated, cross-eyed, ugly, disfigured,"
|
178 |
+
},
|
179 |
+
{
|
180 |
+
name: "Comic Book",
|
181 |
+
prompt: ",comic, graphic illustration, comic art, graphic novel art, vibrant, highly detailed,",
|
182 |
+
negative_prompt: ",photograph, deformed, glitch, noisy, realistic, stock photo,"
|
183 |
+
},
|
184 |
+
{
|
185 |
+
name: "Origami",
|
186 |
+
prompt: ",origami style, paper art, pleated paper, folded, origami art, pleats, cut and fold, centered composition,",
|
187 |
+
negative_prompt: ",noisy, sloppy, messy, grainy, highly detailed, ultra textured, photo,"
|
188 |
+
},
|
189 |
+
{
|
190 |
+
name: "Pixel art",
|
191 |
+
prompt: ",pixel-art, low-res, blocky, pixel art style, 8-bit graphics,",
|
192 |
+
negative_prompt: ",sloppy, messy, blurry, noisy, highly detailed, ultra textured, photo, realistic,"
|
193 |
+
},
|
194 |
+
]
|
195 |
+
|
196 |
+
function loadingButton(boolean){
|
197 |
+
if (boolean){
|
198 |
+
document.getElementById('generateButton').innerHTML = '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Loading...';
|
199 |
+
document.getElementById('generateButton').disabled = true;
|
200 |
+
} else {
|
201 |
+
document.getElementById('generateButton').innerHTML = 'Generate image';
|
202 |
+
document.getElementById('generateButton').disabled = false;
|
203 |
+
}
|
204 |
+
}
|
205 |
+
|
206 |
+
function loadStyleSelect() {
|
207 |
+
const styleSelect = document.getElementById('styleSelect');
|
208 |
+
|
209 |
+
stylesArray.forEach(style => {
|
210 |
+
const option = document.createElement('option');
|
211 |
+
option.value = style.name;
|
212 |
+
option.textContent = style.name;
|
213 |
+
styleSelect.appendChild(option);
|
214 |
+
});
|
215 |
+
}
|
216 |
+
loadStyleSelect();
|
217 |
+
|
218 |
+
|
219 |
+
|
220 |
+
document.getElementById('generateButton').addEventListener('click', generateImage);
|
221 |
+
async function generateImage(){
|
222 |
+
const authTokenTemp = document.getElementById('authTokenInput').value;
|
223 |
+
let prompt = document.getElementById('promptInput').value;
|
224 |
+
let negativePrompt = document.getElementById('negativePromptInput').value;
|
225 |
+
let height = 512;
|
226 |
+
let width = 512;
|
227 |
+
const style = document.getElementById('styleSelect').value;
|
228 |
+
const size = document.getElementById('sizeSelect').value;
|
229 |
+
const guidanceScale = document.getElementById('guidanceScaleInput').value;
|
230 |
+
const numInferenceSteps = document.getElementById('numInferenceStepsInput').value;
|
231 |
+
const seed = document.getElementById('seedInput').value;
|
232 |
+
const model = 'stability-ai/sdxl';
|
233 |
+
|
234 |
+
if (size === 'square'){
|
235 |
+
height = 1024;
|
236 |
+
width = 1024;
|
237 |
+
} else if (size === 'portrait'){
|
238 |
+
height = 1024;
|
239 |
+
width = 768;
|
240 |
+
} else if (size === 'landscape'){
|
241 |
+
height = 768;
|
242 |
+
width = 1024;
|
243 |
+
} else if (size === 'stories'){
|
244 |
+
height = 1024;
|
245 |
+
width = 512;
|
246 |
+
} else if (size === 'ultrawide'){
|
247 |
+
height = 512;
|
248 |
+
width = 1024;
|
249 |
+
}
|
250 |
+
|
251 |
+
const selectedStyleObj = stylesArray.find(styleObj => styleObj.name === style);
|
252 |
+
if (selectedStyleObj) {
|
253 |
+
prompt += selectedStyleObj.prompt;
|
254 |
+
negativePrompt += selectedStyleObj.negative_prompt;
|
255 |
+
}
|
256 |
+
|
257 |
+
const formData = new FormData();
|
258 |
+
formData.append('prompt', prompt);
|
259 |
+
formData.append('negative_prompt', negativePrompt);
|
260 |
+
formData.append('height', height);
|
261 |
+
formData.append('width', width);
|
262 |
+
formData.append('guidance_scale', guidanceScale);
|
263 |
+
formData.append('num_inference_steps', numInferenceSteps);
|
264 |
+
if (seed > 0){
|
265 |
+
formData.append('seed', seed);
|
266 |
+
}
|
267 |
+
|
268 |
+
if (authTokenTemp){
|
269 |
+
localStorage.setItem('authToken', authTokenTemp);
|
270 |
+
}
|
271 |
+
|
272 |
+
function getAuthToken(){
|
273 |
+
const authToken = localStorage.getItem('authToken');
|
274 |
+
if (!authToken){
|
275 |
+
alert('Please enter your Deepinfra API token.');
|
276 |
+
return;
|
277 |
+
}
|
278 |
+
return authToken;
|
279 |
+
}
|
280 |
+
|
281 |
+
const requestOptions = {
|
282 |
+
method: 'POST',
|
283 |
+
headers: {
|
284 |
+
'Authorization': `bearer ${getAuthToken()}`,
|
285 |
+
},
|
286 |
+
body: formData
|
287 |
+
};
|
288 |
+
|
289 |
+
try {
|
290 |
+
loadingButton(true);
|
291 |
+
const url = `https://api.deepinfra.com/v1/inference/${model}`;
|
292 |
+
const response = await fetch(url, requestOptions);
|
293 |
+
const data = await response.json();
|
294 |
+
loadingButton(false);
|
295 |
+
console.log("API response:",data);
|
296 |
+
|
297 |
+
if (data.output && data.output.length > 0) {
|
298 |
+
const imageElement = document.getElementById('generatedImage');
|
299 |
+
imageElement.src = data.output[0];
|
300 |
+
}
|
301 |
+
} catch (error) {
|
302 |
+
alert('There was an error while making the request. Check the console for more information.');
|
303 |
+
console.error('There was an error while making the request:', error);
|
304 |
+
}
|
305 |
+
}
|
306 |
+
</script>
|
307 |
+
</html>
|