yasir commited on
Commit
8feb4dc
·
verified ·
1 Parent(s): 32e2cfb

Create script.js

Browse files
Files changed (1) hide show
  1. script.js +283 -0
script.js ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ reload = false
83
+ let fullPrompt = inp.value+prompt
84
+ setTimeout(()=>{
85
+ reload = true
86
+ },200000)
87
+ btn.onclick = async ()=>{
88
+ let id = ''
89
+ if(reload == true){
90
+ window.location.reload();
91
+ }
92
+ if(isFumes == 'no'){
93
+ fullPrompt = inp.value
94
+ const div = document.getElementById('imshow');
95
+ div.innerHTML = '';
96
+ document.getElementById('imshow').innerHTML = ''
97
+ let pi = document.createElement('p')
98
+ pi.innerText = 'Generating Image... Estimated Time: 20s'
99
+ document.getElementById('imshow').append(pi)
100
+ let chatId = Math.floor(Math.random() * 99999999) + 1;
101
+ let data = {
102
+ prompt: inp.value+prompt
103
+ };
104
+ await fetch('https://flask-hello-world-murex-sigma.vercel.app/generate', {
105
+ method: 'POST',
106
+ headers: {
107
+ 'Content-Type': 'application/json'
108
+ },
109
+ body: JSON.stringify(data)
110
+ })
111
+ .then(response => response.json())
112
+ .then(data =>{
113
+ id = data
114
+ })
115
+ .catch((error) => {
116
+ console.error('Error:', error);
117
+ });
118
+
119
+
120
+ }
121
+ else{
122
+ fullPrompt = inp.value+prompt
123
+ }
124
+
125
+
126
+ //https://hacking-is-serious-illegal-crime-you.onrender.com/sdxl
127
+ let url2 = 'https://hacking-is-serious-illegal-crime-you.onrender.com/get_prediction'
128
+ let idlist = []
129
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/predict'
130
+ var selectElement = document.getElementById("model");
131
+ var selectedIndex = selectElement.selectedIndex;
132
+ if (selectedIndex === -1) {
133
+ console.log("No option is selected.");
134
+ } else {
135
+ var selectedOption = selectElement.options[selectedIndex];
136
+
137
+ if(selectedOption.value == 'rv6'){
138
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/proteus'
139
+
140
+ }
141
+ if(selectedOption.value == 'ds8'){
142
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/dream'
143
+ if(step.value>50){
144
+ step.value = 50
145
+ }
146
+
147
+ }
148
+ if(selectedOption.value == 'ra'){
149
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/playground'
150
+
151
+ }
152
+ if(selectedOption.value == 'ar'){
153
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/predict'
154
+
155
+ }
156
+ if(selectedOption.value == 'er'){
157
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/pixart'
158
+
159
+ }
160
+ if(selectedOption.value == 'anything'){
161
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/anything'
162
+ prompt = ',masterpiece,HDR,anime,anime style,beuatiful anime'
163
+ fullPrompt = inp.value+prompt
164
+ }
165
+ if(selectedOption.value == 'focus'){
166
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/focus'
167
+ url2 = 'https://hacking-is-serious-illegal-crime-you.onrender.com/foocus'
168
+ isf = true
169
+ }
170
+ }
171
+ negative_prompt = nps
172
+ btn.disabled = true
173
+ const div = document.getElementById('imshow');
174
+ div.innerHTML = '';
175
+ document.getElementById('imshow').innerHTML = ''
176
+ let pi = document.createElement('p')
177
+ pi.innerText = 'Generating Image... Estimated Time: 20s'
178
+ document.getElementById('imshow').append(pi)
179
+ let count = 0;
180
+ seed = seed
181
+ async function generate(){
182
+
183
+ const params = {
184
+ 'prompt': fullPrompt,
185
+ 'negative_prompt': np.value+nps,
186
+ "steps": step.value,
187
+ 'gd': gd.value
188
+ };
189
+
190
+ try {
191
+ const response = await fetch(url, {
192
+ method: 'POST',
193
+ headers: {
194
+ 'Content-Type': 'application/json',
195
+ 'Connection': 'keep-alive',
196
+ },
197
+ body: JSON.stringify(params)
198
+ });
199
+ /* console.log(np.value)
200
+ const imgData = await response.text();
201
+ const div = document.getElementById('imshow')
202
+ const img = document.createElement('img');
203
+ pi.innerHTML = ''
204
+ pi.innerText = ''
205
+ img.src = imgData;
206
+ div.appendChild(img);
207
+ */
208
+
209
+ const imgData = await response.text();
210
+ idlist.push(imgData)
211
+
212
+
213
+ } catch (error) {
214
+ btn.disabled = false
215
+ console.error('An error occurred:', error);
216
+ pi.innerText = 'An error occurred, try changing your prompt';
217
+ }
218
+ }
219
+
220
+ await Promise.all([generate(), generate()]);
221
+
222
+ setTimeout(()=>{
223
+ function final2(){
224
+ const id = idlist[1].trim().replace(/^"|"$/g, '');
225
+ fetch(url2, {
226
+ method: 'POST',
227
+ headers: {
228
+ 'Content-Type': 'application/json',
229
+ },
230
+ body: JSON.stringify({
231
+ id: id,
232
+ }),
233
+ })
234
+ .then((response) => response.text())
235
+ .then((data) => {
236
+ const img = document.createElement('img');
237
+ pi.innerHTML = ''
238
+ pi.innerText = ''
239
+ img.src = data.trim().replace(/^"|"$/g, '');
240
+ div.appendChild(img);
241
+ btn.disabled = false
242
+ console.log(data)
243
+ })
244
+ .catch((error) =>{
245
+ btn.disabled = false
246
+ console.error('An error occurred:', error);
247
+ pi.innerText = 'An error occurred, try changing your prompt';
248
+ });
249
+ }
250
+ function final1(){
251
+ const id = idlist[0].trim().replace(/^"|"$/g, '');
252
+ fetch(url2, {
253
+ method: 'POST',
254
+ headers: {
255
+ 'Content-Type': 'application/json',
256
+ },
257
+ body: JSON.stringify({
258
+ id: id,
259
+ }),
260
+ })
261
+ .then((response) => response.text())
262
+ .then((data) => {
263
+ const img = document.createElement('img');
264
+ pi.innerHTML = ''
265
+ pi.innerText = ''
266
+ img.src = data.trim().replace(/^"|"$/g, '');
267
+ div.appendChild(img);
268
+ btn.disabled = false
269
+ console.log(data)
270
+ })
271
+
272
+ .catch((error) => {
273
+ btn.disabled = false
274
+ console.error('An error occurred:', error);
275
+ pi.innerText = 'An error occurred, try changing your prompt';
276
+ });
277
+ }
278
+
279
+ final2()
280
+ final1()
281
+ },8000)
282
+
283
+ }