yasir commited on
Commit
817cb68
·
verified ·
1 Parent(s): cdb482a

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +90 -59
index.html CHANGED
@@ -607,71 +607,104 @@ async function generate(){
607
 
608
  await Promise.all([generate(), generate()]);
609
 
610
- if(isf==false){
611
- function final2(){
612
- const id = idlist[1].trim().replace(/^"|"$/g, '');
613
- fetch(url2, {
614
- method: 'POST',
615
- headers: {
616
- 'Content-Type': 'application/json',
617
- },
618
- body: JSON.stringify({
619
- id: id,
620
- }),
621
- })
622
- .then((response) => response.text())
623
- .then((data) => {
624
- const img = document.createElement('img');
625
- pi.innerHTML = ''
626
- pi.innerText = ''
627
- img.src = data.trim().replace(/^"|"$/g, '');
628
- div.appendChild(img);
629
- btn.disabled = false
630
- console.log(data)
631
- })
632
- .catch((error) =>{
633
- btn.disabled = false
634
- console.error('An error occurred:', error);
635
- pi.innerText = 'An error occurred, try changing your prompt';
636
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
637
  }
638
- function final1(){
639
- const id = idlist[0].trim().replace(/^"|"$/g, '');
640
- fetch(url2, {
641
- method: 'POST',
642
- headers: {
643
- 'Content-Type': 'application/json',
644
- },
645
- body: JSON.stringify({
646
- id: id,
647
- }),
648
- })
649
- .then((response) => response.text())
650
- .then((data) => {
651
- const img = document.createElement('img');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
652
  pi.innerHTML = ''
653
  pi.innerText = ''
654
- img.src = data.trim().replace(/^"|"$/g, '');
655
  div.appendChild(img);
656
- btn.disabled = false
657
- console.log(data)
658
- })
659
- .catch((error) => {
660
- btn.disabled = false
 
 
 
661
  console.error('An error occurred:', error);
662
  pi.innerText = 'An error occurred, try changing your prompt';
663
- });
664
  }
665
 
666
- final2()
667
- final1()
668
-
669
-
670
 
671
- }
672
- else{
673
- setTimeout(()=>{
674
- function final2(){
675
  const id = idlist[1].trim().replace(/^"|"$/g, '');
676
  fetch(url2, {
677
  method: 'POST',
@@ -728,14 +761,12 @@ fetch(url2, {
728
 
729
  final2()
730
  final1()
 
731
 
732
 
733
 
734
- },3500)
735
  }
736
 
737
-
738
- }
739
  </script>
740
 
741
 
 
607
 
608
  await Promise.all([generate(), generate()]);
609
 
610
+ isf = false
611
+ btn.onclick = async ()=>{
612
+ let url2 = 'https://flask-hello-world-murex-sigma.vercel.app/get_prediction'
613
+ let idlist = []
614
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/predict'
615
+ var selectElement = document.getElementById("model");
616
+ var selectedIndex = selectElement.selectedIndex;
617
+ if (selectedIndex === -1) {
618
+ console.log("No option is selected.");
619
+ } else {
620
+ var selectedOption = selectElement.options[selectedIndex];
621
+
622
+ if(selectedOption.value == 'rv6'){
623
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/proteus'
624
+
625
+ }
626
+ if(selectedOption.value == 'ds8'){
627
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/dream'
628
+ if(step.value>50){
629
+ step.value = 50
630
+ }
631
+
632
+ }
633
+ if(selectedOption.value == 'ra'){
634
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/playground'
635
+
636
+ }
637
+ if(selectedOption.value == 'ar'){
638
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/predict'
639
+
640
+ }
641
+ if(selectedOption.value == 'er'){
642
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/pixart'
643
+
644
+ }
645
+ if(selectedOption.value == 'anything'){
646
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/anything'
647
+
648
+ }
649
+ if(selectedOption.value == 'focus'){
650
+ url = 'https://flask-hello-world-murex-sigma.vercel.app/focus'
651
+ url2 = 'https://flask-hello-world-murex-sigma.vercel.app/foocus'
652
+ isf = true
653
+ }
654
  }
655
+ negative_prompt = nps
656
+ btn.disabled = true
657
+ const div = document.getElementById('imshow');
658
+ div.innerHTML = '';
659
+ document.getElementById('imshow').innerHTML = ''
660
+ let pi = document.createElement('p')
661
+ pi.innerText = 'Generating Image... generation Usually Complete Within 15 seconds'
662
+ document.getElementById('imshow').append(pi)
663
+ let count = 0;
664
+ seed = seed
665
+ async function generate(){
666
+
667
+ const params = {
668
+ 'prompt': inp.value+prompt,
669
+ 'negative_prompt': np.value+nps,
670
+ "steps": step.value,
671
+ 'gd': gd.value
672
+ };
673
+
674
+ try {
675
+ const response = await fetch(url, {
676
+ method: 'POST',
677
+ headers: {
678
+ 'Content-Type': 'application/json',
679
+ 'Connection': 'keep-alive',
680
+ },
681
+ body: JSON.stringify(params)
682
+ });
683
+ /* console.log(np.value)
684
+ const imgData = await response.text();
685
+ const div = document.getElementById('imshow')
686
+ const img = document.createElement('img');
687
  pi.innerHTML = ''
688
  pi.innerText = ''
689
+ img.src = imgData;
690
  div.appendChild(img);
691
+ */
692
+
693
+ const imgData = await response.text();
694
+ idlist.push(imgData)
695
+
696
+
697
+ } catch (error) {
698
+ btn.disabled = false
699
  console.error('An error occurred:', error);
700
  pi.innerText = 'An error occurred, try changing your prompt';
701
+ }
702
  }
703
 
704
+ await Promise.all([generate(), generate()]);
 
 
 
705
 
706
+ setTimeout(()=>{
707
+ function final2(){
 
 
708
  const id = idlist[1].trim().replace(/^"|"$/g, '');
709
  fetch(url2, {
710
  method: 'POST',
 
761
 
762
  final2()
763
  final1()
764
+ },21000)
765
 
766
 
767
 
 
768
  }
769
 
 
 
770
  </script>
771
 
772