Spaces:
Running
Running
yasir
commited on
Commit
•
f5286a4
1
Parent(s):
731e16e
Create animate.js
Browse files- animate.js +149 -0
animate.js
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
40 |
+
|
41 |
+
|
42 |
+
isf = false
|
43 |
+
reload = false
|
44 |
+
let fullPrompt = inp.value
|
45 |
+
setTimeout(()=>{
|
46 |
+
reload = true
|
47 |
+
},200000)
|
48 |
+
btn.onclick = async ()=>{
|
49 |
+
fullPrompt = inp.value
|
50 |
+
let id = ''
|
51 |
+
if(reload == true){
|
52 |
+
window.location.reload();
|
53 |
+
}
|
54 |
+
|
55 |
+
|
56 |
+
//https://hacking-is-serious-illegal-crime-you.onrender.com/sdxl
|
57 |
+
let url2 = 'https://hacking-is-serious-illegal-crime-you.onrender.com/animate'
|
58 |
+
let idlist = []
|
59 |
+
let url = 'https://flask-hello-world-murex-sigma.vercel.app/animate'
|
60 |
+
|
61 |
+
|
62 |
+
btn.disabled = true
|
63 |
+
const div = document.getElementById('imshow');
|
64 |
+
div.innerHTML = '';
|
65 |
+
document.getElementById('imshow').innerHTML = ''
|
66 |
+
let pi = document.createElement('p')
|
67 |
+
pi.innerText = 'Generating Animation... Estimated Time: 40s'
|
68 |
+
document.getElementById('imshow').append(pi)
|
69 |
+
let count = 0;
|
70 |
+
seed = seed
|
71 |
+
async function generate(){
|
72 |
+
|
73 |
+
const params = {
|
74 |
+
'prompt': fullPrompt,
|
75 |
+
'negative_prompt': np.value,
|
76 |
+
"steps": step.value,
|
77 |
+
'gd': gd.value
|
78 |
+
};
|
79 |
+
|
80 |
+
try {
|
81 |
+
const response = await fetch(url, {
|
82 |
+
method: 'POST',
|
83 |
+
headers: {
|
84 |
+
'Content-Type': 'application/json',
|
85 |
+
'Connection': 'keep-alive',
|
86 |
+
},
|
87 |
+
body: JSON.stringify(params)
|
88 |
+
});
|
89 |
+
/* console.log(np.value)
|
90 |
+
const imgData = await response.text();
|
91 |
+
const div = document.getElementById('imshow')
|
92 |
+
const img = document.createElement('img');
|
93 |
+
pi.innerHTML = ''
|
94 |
+
pi.innerText = ''
|
95 |
+
img.src = imgData;
|
96 |
+
div.appendChild(img);
|
97 |
+
*/
|
98 |
+
|
99 |
+
const imgData = await response.text();
|
100 |
+
idlist.push(imgData)
|
101 |
+
|
102 |
+
|
103 |
+
} catch (error) {
|
104 |
+
btn.disabled = false
|
105 |
+
console.error('An error occurred:', error);
|
106 |
+
pi.innerText = 'An error occurred, try changing your prompt';
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
await Promise.all([generate()]);
|
111 |
+
|
112 |
+
setTimeout(()=>{
|
113 |
+
function final1(){
|
114 |
+
const id = idlist[0].trim().replace(/^"|"$/g, '');
|
115 |
+
fetch(url2, {
|
116 |
+
method: 'POST',
|
117 |
+
headers: {
|
118 |
+
'Content-Type': 'application/json',
|
119 |
+
},
|
120 |
+
body: JSON.stringify({
|
121 |
+
id: id,
|
122 |
+
}),
|
123 |
+
})
|
124 |
+
.then((response) => response.text())
|
125 |
+
.then((data) => {
|
126 |
+
const vid = document.createElement('video');
|
127 |
+
pi.innerHTML = ''
|
128 |
+
pi.innerText = ''
|
129 |
+
vid.src = data.trim().replace(/^"|"$/g, '')
|
130 |
+
vid.autoplay = true;
|
131 |
+
vid.play();
|
132 |
+
vid.setAttribute('loop', '');
|
133 |
+
div.appendChild(vid)
|
134 |
+
btn.disabled = false
|
135 |
+
console.log(data)
|
136 |
+
|
137 |
+
})
|
138 |
+
|
139 |
+
.catch((error) => {
|
140 |
+
btn.disabled = false
|
141 |
+
console.error('An error occurred:', error);
|
142 |
+
pi.innerText = 'An error occurred, try changing your prompt';
|
143 |
+
});
|
144 |
+
}
|
145 |
+
|
146 |
+
final1()
|
147 |
+
},30000)
|
148 |
+
|
149 |
+
}
|