yasir commited on
Commit
0b79fdd
1 Parent(s): d20c271

Create script.js

Browse files
Files changed (1) hide show
  1. script.js +369 -0
script.js ADDED
@@ -0,0 +1,369 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ document.getElementById('jd').onclick = ()=>{
2
+ window.open('https://discord.gg/ju4yQBfQ7p')
3
+ }
4
+
5
+
6
+ /*document.getElementById('ow').onclick = ()=>{
7
+ window.open('https://www.buymeacoffee.com/mygx')
8
+ }*/
9
+ document.getElementById('fumes').checked = true
10
+ let dialog = document.getElementById('dialog')
11
+ let openbtn = document.getElementById('Advance Setting')
12
+ let closebtn = document.getElementById('close')
13
+ openbtn.onclick = ()=>{
14
+ dialog.show()
15
+ document.getElementById('imshow').style.border = '0px solid black transparent'
16
+ }
17
+ closebtn.onclick= ()=>{
18
+ dialog.close()
19
+ document.getElementById('imshow').style.background = 'linear-gradient(black, black) padding-box,linear-gradient(to right, red, blue) border-box'
20
+ }
21
+ let inp = document.getElementById('inp')
22
+ let np = document.getElementById('np')
23
+ let gd = document.getElementById('gds')
24
+ let step = document.getElementById('step')
25
+ let seed = document.getElementById('seed')
26
+ let seedp = document.getElementById('seedp')
27
+ let stepp = document.getElementById('stepp')
28
+ let gdsp = document.getElementById('gdsp')
29
+ let btn = document.getElementById('create')
30
+ gd.addEventListener('input',()=>{
31
+ gdsp.innerText = gd.value
32
+ })
33
+ step.addEventListener('input',()=>{
34
+ stepp.innerText = step.value
35
+ })
36
+ seed.addEventListener('input',()=>{
37
+ seedp.innerText = seed.value
38
+ })
39
+ isFumes = true
40
+ let prompt = ',RAW photo, photorealistic, extremely detailed informations, hyper:realistic,HIGHLY INTRICATE DETAILS,EXTREMELY MASTERPIECE'
41
+ let nps = ' ,(bad hands, bad anatomy, bad body, bad face, bad teeth, bad arms, bad legs, deformities:1.3),poorly drawn,deformed hands,deformed fingers,deformed faces,deformed eyes,mutated fingers,deformedbody parts,mutated body parts,mutated hands, disfigured,oversaturated,bad anatom,cropped, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, out of frame, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, deformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck,deformed eyes'
42
+ document.getElementById('styles').onchange = ()=>{
43
+ const selectedStyle = document.querySelector('input[name="style"]:checked');
44
+ if(selectedStyle.value =='photo'){
45
+ isFumes = true
46
+ prompt = ' ,RAW photo, portrait photo,(high detailed skin:1. 2), 8k uhd, dslr, soft lighting, high quality, film grain, Fujifilm'
47
+ nps = ' ,deformed fingers,mutated hands,unrealistic hands,extra fingers,less fingers,mutated eyes,malformed hands,malformed fingers,malformed faces,malfromed eyes,malformed body parts,mutated body parts,mutated fingers,mutated hands,(deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime:1.4), text, close up, cropped, out of frame, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck'
48
+ }
49
+ if(selectedStyle.value == 'cinema'){
50
+ isFumes = true
51
+ prompt = ' ,cinematic film still awardwinning photo, highly detailed, high budget, bokeh, cinemascope, moody, epic, gorgeous, film grain, grainy'
52
+ nps = ' ,deformed fingers,mutated hands,unrealistic hands,extra fingers,less fingers,mutated eyes,malformed hands,malformed fingers,malformed faces,malfromed eyes,malformed body parts,mutated body parts,mutated fingers,mutated hands,(deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime:1.4), text, close up, cropped, out of frame, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck'
53
+ }
54
+ if(selectedStyle.value == 'real'){
55
+ isFumes = true
56
+ prompt = ' ,RAW candid cinema,Modern colors, 16mm, beautiful,attractive,color graded portra 400 film, remarkable color, ultra realistic, textured skin, remarkable detailed pupils, realistic dull skin noise, visible skin detail, skin fuzz, dry skin, shot with cinematic camera, sun soaked colors'
57
+ nps = ' ,deformed fingers,mutated hands,unrealistic hands,extra fingers,less fingers,mutated eyes,malformed hands,malformed fingers,malformed faces,malfromed eyes,malformed body parts,mutated body parts,mutated fingers,mutated hands,poorly drawn,lowres, disfigured,bad anatomy,deformed body features ,cropped, worst quality, low quality, jpeg artifacts, ugly, duplicate, out of frame, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck,deformed eyes'
58
+ }
59
+ if(selectedStyle.value == 'fantasy'){
60
+ isFumes = true
61
+ prompt = ' ,centered shot, wide angle, full body, dd, fantasy, highly detailed, digital painting, artstation, smooth, sharp focus, digital art'
62
+ nps = ' ,deformed fingers,mutated hands,unrealistic hands,extra fingers,less fingers,mutated eyes,malformed hands,malformed fingers,malformed faces,malfromed eyes,malformed body parts,mutated body parts,mutated fingers,mutated hands,missing legs, missing feet, worst quality, low quality, jpeg artifacts, signature, logo, watermark, text, realistic, hyper-realistic, ultra-detailed, RAW photo'
63
+ }
64
+ if(selectedStyle.value == 'anime'){
65
+ isFumes = true
66
+ prompt = ' ,masterpiece,HDR,anime,anime style,beuatiful anime'
67
+ nps = ' ,malformed hands,malformed fingers,malformed faces,malformed body parts,mutated body parts,malfromed eyes,mutated fingers,mutated hands,realistic,worst quality, low quality, blurry, pixelated, extra limb, extra fingers, bad hand, text, name, letters, out of frame, lowres, text, error, cropped, jpeg artifacts, ugly, duplicate, morbid, mutilated, out of frame, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck, username, watermark, signature'
68
+ }
69
+ if(selectedStyle.value == 'fumes'){
70
+ isFumes = true
71
+ let prompt = ' ,RAW photo,dynamic lights, photorealistic, extremely detailed informations, dynamic colors,realistic,SciFi,award winning photography,film grain,beautiful,attarctive'
72
+ let nps = ' ,deformed fingers,mutated hands,unrealistic hands,extra fingers,less fingers,mutated eyes,poorly drawn,malformed hands,malformed fingers,malformed faces,malformed body parts,mutated body parts,malfromed eyes,mutated fingers,mutated hands, disfigured,oversaturated,bad anatomy,deformed body features ,cropped, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, out of frame, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck,deformed eyes'
73
+ }
74
+ if(selectedStyle.value == 'no'){
75
+ prompt = ''
76
+ nps = ''
77
+ isFumes = false
78
+ }
79
+ }
80
+
81
+ isf = false
82
+ let isreal = false
83
+ reload = false
84
+ let fullPrompt = inp.value+prompt
85
+ setTimeout(()=>{
86
+ reload = true
87
+ },250000)
88
+ btn.onclick = async ()=>{
89
+ let isc = false
90
+ let id = ''
91
+ if(reload == true){
92
+ window.location.reload();
93
+ }
94
+ if(isFumes == 'no'){
95
+ fullPrompt = inp.value
96
+ const div = document.getElementById('imshow');
97
+ div.innerHTML = '';
98
+ document.getElementById('imshow').innerHTML = ''
99
+ let pi = document.createElement('p')
100
+ pi.innerText = 'Generating Image... Estimated Time: 20s'
101
+ document.getElementById('imshow').append(pi)
102
+ let chatId = Math.floor(Math.random() * 99999999) + 1;
103
+ let data = {
104
+ prompt: inp.value+prompt
105
+ };
106
+ await fetch('https://flask-hello-world-murex-sigma.vercel.app/generate', {
107
+ method: 'POST',
108
+ headers: {
109
+ 'Content-Type': 'application/json'
110
+ },
111
+ body: JSON.stringify(data)
112
+ })
113
+ .then(response => response.json())
114
+ .then(data =>{
115
+ id = data
116
+ })
117
+ .catch((error) => {
118
+ console.error('Error:', error);
119
+ });
120
+
121
+
122
+ }
123
+ else{
124
+ fullPrompt = inp.value+prompt
125
+ }
126
+
127
+
128
+ //https://hacking-is-serious-illegal-crime-you.onrender.com/sdxl
129
+ let url2 = 'https://hacking-is-serious-illegal-crime-you.onrender.com/get_prediction'
130
+ let idlist = []
131
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/predict'
132
+ var selectElement = document.getElementById("model");
133
+ var selectedIndex = selectElement.selectedIndex;
134
+ if (selectedIndex === -1) {
135
+ console.log("No option is selected.");
136
+ } else {
137
+ var selectedOption = selectElement.options[selectedIndex];
138
+
139
+ if(selectedOption.value == 'rv6'){
140
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/proteus'
141
+ isreal = false
142
+ }
143
+ if(selectedOption.value == 'ds8'){
144
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/dream'
145
+ if(step.value>50){
146
+ step.value = 50
147
+ }
148
+ isreal = false
149
+ }
150
+ if(selectedOption.value == 'ra'){
151
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/playground'
152
+ isreal = false
153
+ }
154
+ if(selectedOption.value == 'ar'){
155
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/predict'
156
+ isreal = false
157
+ }
158
+ if(selectedOption.value == 'er'){
159
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/pixart'
160
+ isreal = false
161
+ }
162
+ if(selectedOption.value == 'anything'){
163
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/anything'
164
+ isreal = false
165
+ fullPrompt = inp.value + ", anime, anime style"
166
+ }
167
+ if(selectedOption.value == 'focus'){
168
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/focus'
169
+ url2 = 'https://hacking-is-serious-illegal-crime-you.onrender.com/foocus'
170
+ isf = true
171
+ isreal = false
172
+ }
173
+ if(selectedOption.value == 'cas'){
174
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/cascade'
175
+ url2 = 'https://hacking-is-serious-illegal-crime-you.onrender.com/cascade'
176
+ isc = true
177
+ isreal = false
178
+ }
179
+ if(selectedOption.value == 'w'){
180
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/w'
181
+ url2 = 'https://hacking-is-serious-illegal-crime-you.onrender.com/get_prediction'
182
+ isreal = false
183
+ }
184
+ if(selectedOption.value == 'k'){
185
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/k'
186
+ url2 = 'https://hacking-is-serious-illegal-crime-you.onrender.com/get_prediction'
187
+ isreal = false
188
+
189
+ }
190
+ if(selectedOption.value == 'op'){
191
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/op'
192
+ url2 = 'https://hacking-is-serious-illegal-crime-you.onrender.com/get_prediction'
193
+ isreal = false
194
+ }
195
+ if(selectedOption.value == 'p3'){
196
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/p3'
197
+ url2 = 'https://hacking-is-serious-illegal-crime-you.onrender.com/get_prediction'
198
+ isreal = false
199
+ }
200
+ if(selectedOption.value == 'emo'){
201
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/emo'
202
+ url2 = 'https://hacking-is-serious-illegal-crime-you.onrender.com/get_prediction'
203
+ isreal = false
204
+ }
205
+ if(selectedOption.value == 'real'){
206
+ isreal = true
207
+ if(step.value>50){
208
+ step.value = 50
209
+ }
210
+ }
211
+
212
+ }
213
+ negative_prompt = nps
214
+ btn.disabled = true
215
+ const div = document.getElementById('imshow');
216
+ div.innerHTML = '';
217
+ document.getElementById('imshow').innerHTML = ''
218
+ let pi = document.createElement('p')
219
+ pi.innerText = 'Generating Image... Estimated Time: 20s'
220
+ document.getElementById('imshow').append(pi)
221
+ let count = 0;
222
+ seed = seed
223
+ if(isreal == false){
224
+ async function generate(){
225
+ params={
226
+
227
+ 'prompt': fullPrompt,
228
+ 'negative_prompt': np.value+nps,
229
+ "steps": step.value,
230
+ 'gd': gd.value
231
+ };
232
+
233
+
234
+ try {
235
+ const response = await fetch(url, {
236
+ method: 'POST',
237
+ headers: {
238
+ 'Content-Type': 'application/json',
239
+ 'Connection': 'keep-alive',
240
+ },
241
+ body: JSON.stringify(params)
242
+ });
243
+ if (response.status === 429) {
244
+ pi.innerText = 'you have reached your limit of 50 generation per hour, you will get 50 more image generaions after an hour!!'
245
+ }
246
+ /* console.log(np.value)
247
+ const imgData = await response.text();
248
+ const div = document.getElementById('imshow')
249
+ const img = document.createElement('img');
250
+ pi.innerHTML = ''
251
+ pi.innerText = ''
252
+ img.src = imgData;
253
+ div.appendChild(img);
254
+ */
255
+
256
+ const imgData = await response.text();
257
+ idlist.push(imgData)
258
+
259
+
260
+ } catch (error) {
261
+ btn.disabled = false
262
+ console.error('An error occurred:', error);
263
+ pi.innerText = 'An error occurred, try changing your prompt';
264
+ }
265
+
266
+
267
+ }
268
+
269
+ await Promise.all([generate()]);
270
+
271
+ setTimeout(()=>{
272
+ /* function final2(){
273
+ const id = idlist[1].trim().replace(/^"|"$/g, '');
274
+ fetch(url2, {
275
+ method: 'POST',
276
+ headers: {
277
+ 'Content-Type': 'application/json',
278
+ },
279
+ body: JSON.stringify({
280
+ id: id,
281
+ }),
282
+ })
283
+ .then((response) => response.text())
284
+ .then((data) => {
285
+ const img = document.createElement('img');
286
+ pi.innerHTML = ''
287
+ pi.innerText = ''
288
+ img.src = data.trim().replace(/^"|"$/g, '');
289
+ div.appendChild(img);
290
+ btn.disabled = false
291
+ console.log(data)
292
+ })
293
+ .catch((error) =>{
294
+ btn.disabled = false
295
+ console.error('An error occurred:', error);
296
+ pi.innerText = 'An error occurred, try changing your prompt';
297
+ });
298
+ }*/
299
+ function final1(){
300
+ const id = idlist[0].trim().replace(/^"|"$/g, '');
301
+ fetch(url2, {
302
+ method: 'POST',
303
+ headers: {
304
+ 'Content-Type': 'application/json',
305
+ },
306
+ body: JSON.stringify({
307
+ id: id,
308
+ }),
309
+ })
310
+ .then((response) => response.text())
311
+ .then((data) => {
312
+ const img = document.createElement('img');
313
+ pi.innerHTML = ''
314
+ pi.innerText = ''
315
+ img.src = data.trim().replace(/^"|"$/g, '');
316
+ div.appendChild(img);
317
+ btn.disabled = false
318
+ console.log(data)
319
+ })
320
+
321
+ .catch((error) => {
322
+ btn.disabled = false
323
+ console.error('An error occurred:', error);
324
+ pi.innerText = 'An error occurred, try changing your prompt';
325
+ });
326
+ }
327
+
328
+
329
+ final1()
330
+ },8000)
331
+ }
332
+ if(isreal == true){
333
+ console.log('hh')
334
+ function final1(){
335
+
336
+
337
+ fetch('https://hacking-is-serious-illegal-crime-you.onrender.com/real', {
338
+ method: 'POST',
339
+ headers: {
340
+ 'Content-Type': 'application/json',
341
+ },
342
+ body: JSON.stringify({
343
+ prompt: inp.value,
344
+ nprompt: np.value + ' ,(bad hands, bad anatomy, bad body, bad face, bad teeth, bad arms, bad legs, deformities:1.3),poorly drawn,deformed hands,deformed fingers,deformed faces,deformed eyes,mutated fingers,deformedbody parts,mutated body parts,mutated hands, disfigured,oversaturated,bad anatom,cropped, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, out of frame, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, deformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck,deformed eyes',
345
+ steps: step.value,
346
+ gd: gd.value
347
+ }),
348
+ })
349
+ .then((response) => response.text())
350
+ .then((data) => {
351
+ const img = document.createElement('img');
352
+ pi.innerHTML = ''
353
+ pi.innerText = ''
354
+ img.src = data.trim().replace(/^"|"$/g, '');
355
+ div.appendChild(img);
356
+ btn.disabled = false
357
+ console.log(data)
358
+ })
359
+
360
+ .catch((error) => {
361
+ btn.disabled = false
362
+ console.error('An error occurred:', error);
363
+ pi.innerText = 'An error occurred, please try again or use another model';
364
+ });
365
+ }
366
+ final1()
367
+ }
368
+
369
+ }