Spaces:
Running
Running
yasir
commited on
Update script.js
Browse files
script.js
CHANGED
@@ -79,7 +79,7 @@ let nps = ' ,NSFW,deformed fingers,mutated hands,unrealistic hands,extra fingers
|
|
79 |
}
|
80 |
|
81 |
isf = false
|
82 |
-
|
83 |
reload = false
|
84 |
let fullPrompt = inp.value+prompt
|
85 |
setTimeout(()=>{
|
@@ -138,64 +138,76 @@ if (selectedIndex === -1) {
|
|
138 |
|
139 |
if(selectedOption.value == 'rv6'){
|
140 |
url = 'https://flask-hello-world-murex-sigma.vercel.app/proteus'
|
141 |
-
|
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 |
-
|
149 |
}
|
150 |
if(selectedOption.value == 'ra'){
|
151 |
url = 'https://flask-hello-world-murex-sigma.vercel.app/playground'
|
152 |
-
|
153 |
}
|
154 |
if(selectedOption.value == 'ar'){
|
155 |
url = 'https://flask-hello-world-murex-sigma.vercel.app/predict'
|
156 |
-
|
157 |
}
|
158 |
if(selectedOption.value == 'er'){
|
159 |
url = 'https://flask-hello-world-murex-sigma.vercel.app/pixart'
|
160 |
-
|
161 |
}
|
162 |
if(selectedOption.value == 'anything'){
|
163 |
url = 'https://flask-hello-world-murex-sigma.vercel.app/anything'
|
164 |
prompt = ',masterpiece,HDR,anime,anime style,beuatiful anime'
|
165 |
fullPrompt = inp.value+prompt
|
|
|
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 |
}
|
172 |
if(selectedOption.value == 'cas'){
|
173 |
url = 'https://flask-hello-world-murex-sigma.vercel.app/cascade'
|
174 |
url2 = 'https://hacking-is-serious-illegal-crime-you.onrender.com/cascade'
|
175 |
isc = true
|
|
|
176 |
}
|
177 |
if(selectedOption.value == 'w'){
|
178 |
url = 'https://flask-hello-world-murex-sigma.vercel.app/w'
|
179 |
url2 = 'https://hacking-is-serious-illegal-crime-you.onrender.com/get_prediction'
|
|
|
180 |
}
|
181 |
if(selectedOption.value == 'k'){
|
182 |
url = 'https://flask-hello-world-murex-sigma.vercel.app/k'
|
183 |
url2 = 'https://hacking-is-serious-illegal-crime-you.onrender.com/get_prediction'
|
184 |
-
|
185 |
|
186 |
}
|
187 |
if(selectedOption.value == 'op'){
|
188 |
url = 'https://flask-hello-world-murex-sigma.vercel.app/op'
|
189 |
url2 = 'https://hacking-is-serious-illegal-crime-you.onrender.com/get_prediction'
|
|
|
190 |
}
|
191 |
if(selectedOption.value == 'p3'){
|
192 |
url = 'https://flask-hello-world-murex-sigma.vercel.app/p3'
|
193 |
url2 = 'https://hacking-is-serious-illegal-crime-you.onrender.com/get_prediction'
|
|
|
194 |
}
|
195 |
if(selectedOption.value == 'emo'){
|
196 |
url = 'https://flask-hello-world-murex-sigma.vercel.app/emo'
|
197 |
url2 = 'https://hacking-is-serious-illegal-crime-you.onrender.com/get_prediction'
|
198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
}
|
200 |
|
201 |
}
|
@@ -209,112 +221,164 @@ pi.innerText = 'Generating Image... Estimated Time: 20s'
|
|
209 |
document.getElementById('imshow').append(pi)
|
210 |
let count = 0;
|
211 |
seed = seed
|
212 |
-
|
213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
.
|
272 |
-
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
273 |
const img = document.createElement('img');
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
btn.disabled = false
|
279 |
-
console.log(data)
|
280 |
-
})
|
281 |
-
.catch((error) =>{
|
282 |
btn.disabled = false
|
283 |
-
|
284 |
-
|
285 |
-
})
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
})
|
298 |
-
.then((response) => response.text())
|
299 |
-
.then((data) => {
|
300 |
-
const img = document.createElement('img');
|
301 |
-
pi.innerHTML = ''
|
302 |
-
pi.innerText = ''
|
303 |
-
img.src = data.trim().replace(/^"|"$/g, '');
|
304 |
-
div.appendChild(img);
|
305 |
-
btn.disabled = false
|
306 |
-
console.log(data)
|
307 |
-
})
|
308 |
-
|
309 |
-
.catch((error) => {
|
310 |
-
btn.disabled = false
|
311 |
-
console.error('An error occurred:', error);
|
312 |
-
pi.innerText = 'An error occurred, try changing your prompt';
|
313 |
-
});
|
314 |
}
|
|
|
|
|
|
|
315 |
|
316 |
-
|
317 |
-
|
318 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
319 |
|
320 |
}
|
|
|
79 |
}
|
80 |
|
81 |
isf = false
|
82 |
+
let isreal = false
|
83 |
reload = false
|
84 |
let fullPrompt = inp.value+prompt
|
85 |
setTimeout(()=>{
|
|
|
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 |
prompt = ',masterpiece,HDR,anime,anime style,beuatiful anime'
|
165 |
fullPrompt = inp.value+prompt
|
166 |
+
isreal = false
|
167 |
}
|
168 |
if(selectedOption.value == 'focus'){
|
169 |
url = 'https://flask-hello-world-murex-sigma.vercel.app/focus'
|
170 |
url2 = 'https://hacking-is-serious-illegal-crime-you.onrender.com/foocus'
|
171 |
isf = true
|
172 |
+
isreal = false
|
173 |
}
|
174 |
if(selectedOption.value == 'cas'){
|
175 |
url = 'https://flask-hello-world-murex-sigma.vercel.app/cascade'
|
176 |
url2 = 'https://hacking-is-serious-illegal-crime-you.onrender.com/cascade'
|
177 |
isc = true
|
178 |
+
isreal = false
|
179 |
}
|
180 |
if(selectedOption.value == 'w'){
|
181 |
url = 'https://flask-hello-world-murex-sigma.vercel.app/w'
|
182 |
url2 = 'https://hacking-is-serious-illegal-crime-you.onrender.com/get_prediction'
|
183 |
+
isreal = false
|
184 |
}
|
185 |
if(selectedOption.value == 'k'){
|
186 |
url = 'https://flask-hello-world-murex-sigma.vercel.app/k'
|
187 |
url2 = 'https://hacking-is-serious-illegal-crime-you.onrender.com/get_prediction'
|
188 |
+
isreal = false
|
189 |
|
190 |
}
|
191 |
if(selectedOption.value == 'op'){
|
192 |
url = 'https://flask-hello-world-murex-sigma.vercel.app/op'
|
193 |
url2 = 'https://hacking-is-serious-illegal-crime-you.onrender.com/get_prediction'
|
194 |
+
isreal = false
|
195 |
}
|
196 |
if(selectedOption.value == 'p3'){
|
197 |
url = 'https://flask-hello-world-murex-sigma.vercel.app/p3'
|
198 |
url2 = 'https://hacking-is-serious-illegal-crime-you.onrender.com/get_prediction'
|
199 |
+
isreal = false
|
200 |
}
|
201 |
if(selectedOption.value == 'emo'){
|
202 |
url = 'https://flask-hello-world-murex-sigma.vercel.app/emo'
|
203 |
url2 = 'https://hacking-is-serious-illegal-crime-you.onrender.com/get_prediction'
|
204 |
+
isreal = false
|
205 |
+
}
|
206 |
+
if(selectedOption.value == 'real'){
|
207 |
+
isreal = true
|
208 |
+
if(step.value>50){
|
209 |
+
step.value = 50
|
210 |
+
}
|
211 |
}
|
212 |
|
213 |
}
|
|
|
221 |
document.getElementById('imshow').append(pi)
|
222 |
let count = 0;
|
223 |
seed = seed
|
224 |
+
if(isreal == false){
|
225 |
+
async function generate(){
|
226 |
+
params={
|
227 |
+
|
228 |
+
'prompt': fullPrompt,
|
229 |
+
'negative_prompt': np.value+nps,
|
230 |
+
"steps": step.value,
|
231 |
+
'gd': gd.value
|
232 |
+
};
|
233 |
|
234 |
+
|
235 |
+
try {
|
236 |
+
const response = await fetch(url, {
|
237 |
+
method: 'POST',
|
238 |
+
headers: {
|
239 |
+
'Content-Type': 'application/json',
|
240 |
+
'Connection': 'keep-alive',
|
241 |
+
},
|
242 |
+
body: JSON.stringify(params)
|
243 |
+
});
|
244 |
+
if (response.status === 429) {
|
245 |
+
pi.innerText = 'you have reached your limit of 50 generation per hour, you will get 50 more image generaions after an hour!!'
|
246 |
+
}
|
247 |
+
/* console.log(np.value)
|
248 |
+
const imgData = await response.text();
|
249 |
+
const div = document.getElementById('imshow')
|
250 |
+
const img = document.createElement('img');
|
251 |
+
pi.innerHTML = ''
|
252 |
+
pi.innerText = ''
|
253 |
+
img.src = imgData;
|
254 |
+
div.appendChild(img);
|
255 |
+
*/
|
256 |
+
|
257 |
+
const imgData = await response.text();
|
258 |
+
idlist.push(imgData)
|
259 |
+
|
260 |
+
|
261 |
+
} catch (error) {
|
262 |
+
btn.disabled = false
|
263 |
+
console.error('An error occurred:', error);
|
264 |
+
pi.innerText = 'An error occurred, try changing your prompt';
|
265 |
+
}
|
266 |
+
|
267 |
+
|
268 |
+
}
|
269 |
+
|
270 |
+
await Promise.all([generate()]);
|
271 |
+
|
272 |
+
setTimeout(()=>{
|
273 |
+
/* function final2(){
|
274 |
+
const id = idlist[1].trim().replace(/^"|"$/g, '');
|
275 |
+
fetch(url2, {
|
276 |
+
method: 'POST',
|
277 |
+
headers: {
|
278 |
+
'Content-Type': 'application/json',
|
279 |
+
},
|
280 |
+
body: JSON.stringify({
|
281 |
+
id: id,
|
282 |
+
}),
|
283 |
+
})
|
284 |
+
.then((response) => response.text())
|
285 |
+
.then((data) => {
|
286 |
+
const img = document.createElement('img');
|
287 |
+
pi.innerHTML = ''
|
288 |
+
pi.innerText = ''
|
289 |
+
img.src = data.trim().replace(/^"|"$/g, '');
|
290 |
+
div.appendChild(img);
|
291 |
+
btn.disabled = false
|
292 |
+
console.log(data)
|
293 |
+
})
|
294 |
+
.catch((error) =>{
|
295 |
+
btn.disabled = false
|
296 |
+
console.error('An error occurred:', error);
|
297 |
+
pi.innerText = 'An error occurred, try changing your prompt';
|
298 |
+
});
|
299 |
+
}*/
|
300 |
+
function final1(){
|
301 |
+
const id = idlist[0].trim().replace(/^"|"$/g, '');
|
302 |
+
fetch(url2, {
|
303 |
+
method: 'POST',
|
304 |
+
headers: {
|
305 |
+
'Content-Type': 'application/json',
|
306 |
+
},
|
307 |
+
body: JSON.stringify({
|
308 |
+
id: id,
|
309 |
+
}),
|
310 |
+
})
|
311 |
+
.then((response)=>{
|
312 |
+
if (response.status === 500) {
|
313 |
+
pi.innerText = 'you have reached your limit of 50 generation per hour, you will get 50 more image generaions after an hour!!'
|
314 |
+
}
|
315 |
+
})
|
316 |
+
.then((response) => response.text())
|
317 |
+
.then((data) => {
|
318 |
+
if(data==`<!doctype html>
|
319 |
+
<html lang=en>
|
320 |
+
<title>500 Internal Server Error</title>
|
321 |
+
<h1>Internal Server Error</h1>
|
322 |
+
<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>`){
|
323 |
+
pi.innerText = 'you have rea'
|
324 |
+
}
|
325 |
+
else{
|
326 |
const img = document.createElement('img');
|
327 |
+
pi.innerHTML = ''
|
328 |
+
pi.innerText = ''
|
329 |
+
img.src = data.trim().replace(/^"|"$/g, '');
|
330 |
+
div.appendChild(img);
|
|
|
|
|
|
|
|
|
331 |
btn.disabled = false
|
332 |
+
console.log(data)
|
333 |
+
}
|
334 |
+
})
|
335 |
+
|
336 |
+
.catch((error) => {
|
337 |
+
btn.disabled = false
|
338 |
+
console.error('An error occurred:', error);
|
339 |
+
pi.innerText =`An error occurred, try changing your prompt or use "Realistic Vision" Model for NSFW`;
|
340 |
+
});
|
341 |
+
}
|
342 |
+
|
343 |
+
|
344 |
+
final1()
|
345 |
+
},8000)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
346 |
}
|
347 |
+
if(isreal == true){
|
348 |
+
console.log('hh')
|
349 |
+
function final1(){
|
350 |
|
351 |
+
|
352 |
+
fetch('https://hacking-is-serious-illegal-crime-you.onrender.com/real', {
|
353 |
+
method: 'POST',
|
354 |
+
headers: {
|
355 |
+
'Content-Type': 'application/json',
|
356 |
+
},
|
357 |
+
body: JSON.stringify({
|
358 |
+
prompt: inp.value,
|
359 |
+
nprompt: np.value,
|
360 |
+
steps: step.value,
|
361 |
+
gd: gd.value
|
362 |
+
}),
|
363 |
+
})
|
364 |
+
.then((response) => response.text())
|
365 |
+
.then((data) => {
|
366 |
+
const img = document.createElement('img');
|
367 |
+
pi.innerHTML = ''
|
368 |
+
pi.innerText = ''
|
369 |
+
img.src = data.trim().replace(/^"|"$/g, '');
|
370 |
+
div.appendChild(img);
|
371 |
+
btn.disabled = false
|
372 |
+
console.log(data)
|
373 |
+
})
|
374 |
+
|
375 |
+
.catch((error) => {
|
376 |
+
btn.disabled = false
|
377 |
+
console.error('An error occurred:', error);
|
378 |
+
pi.innerText = 'An error occurred, please try again or use another model';
|
379 |
+
});
|
380 |
+
}
|
381 |
+
final1()
|
382 |
+
}
|
383 |
|
384 |
}
|