multimodalart HF staff commited on
Commit
012fe3d
1 Parent(s): 37daa52

Update share_btn.py

Browse files
Files changed (1) hide show
  1. share_btn.py +7 -22
share_btn.py CHANGED
@@ -38,12 +38,9 @@ share_js = """async () => {
38
  }
39
 
40
  const gradioEl = document.querySelector("gradio-app").shadowRoot || document.querySelector('body > gradio-app');
41
- const randomLoRA_1 = gradioEl.querySelector("#component-7 img")
42
- const randomLoRA_1_title = gradioEl.querySelector("#component-7 [data-testid="block-label"] span").innerHTML
43
- const randomLoRA_2 = gradioEl.querySelector("#component-7 img")
44
- const randomLoRA_2_title = gradioEl.querySelector("#component-7 [data-testid="block-label"] span").innerHTML
45
- const prompt = gradioEl.querySelector("#prompt textarea").value
46
- const outputImgEl = gradioEl.querySelector('#component-22 img');
47
 
48
  const shareBtnEl = gradioEl.querySelector('#share-btn');
49
  const shareIconEl = gradioEl.querySelector('#share-btn-share-icon');
@@ -54,34 +51,22 @@ share_js = """async () => {
54
  loadingIconEl.style.removeProperty('display');
55
 
56
  const inputFile = await getInputImgFile(outputImgEl);
57
- const urlOutputImg = await uploadFile(inputFile);
58
-
59
- const inputFile = await getInputImgFile(randomLoRA_1);
60
- const urlLoRA1 = await uploadFile(inputFile);
61
-
62
- const inputFile = await getInputImgFile(randomLoRA_2);
63
- const urlLoRA2 = await uploadFile(inputFile);
64
 
65
  const descriptionMd = `
66
-
67
- | {randomLoRA_1_title} | | {randomLoRA_2_title}|
68
- |---------|-----------|---------|
69
- | ![{randomLoRA_1_title}]({urlLoRA1}) | + | ![{randomLoRA_1_title}]({urlLoRA2}) |
70
-
71
  ### Prompt
72
  ${inputPrompt}
73
-
74
  #### Generated Image:
75
  <img src="${urlInputImg}" />
76
  `;
77
- console.log(descriptionMd)
78
  const params = new URLSearchParams({
79
- title: prompt,
80
  description: descriptionMd,
81
  preview: true
82
  });
83
  const paramsStr = params.toString();
84
- window.open(`https://huggingface.co/spaces/multimodalart/lora-roulette/discussions/new?${paramsStr}`, '_blank');
85
  shareBtnEl.style.removeProperty('pointer-events');
86
  shareIconEl.style.removeProperty('display');
87
  loadingIconEl.style.display = 'none';
 
38
  }
39
 
40
  const gradioEl = document.querySelector("gradio-app").shadowRoot || document.querySelector('body > gradio-app');
41
+ const selectedLoRA = gradioEl.querySelector('#selected_lora').innerHTML;
42
+ const inputPrompt = gradioEl.querySelector('#prompt input').value;
43
+ const outputImgEl = gradioEl.querySelector('#result-image img');
 
 
 
44
 
45
  const shareBtnEl = gradioEl.querySelector('#share-btn');
46
  const shareIconEl = gradioEl.querySelector('#share-btn-share-icon');
 
51
  loadingIconEl.style.removeProperty('display');
52
 
53
  const inputFile = await getInputImgFile(outputImgEl);
54
+ const urlInputImg = await uploadFile(inputFile);
 
 
 
 
 
 
55
 
56
  const descriptionMd = `
57
+ ${selectedLoRA}
 
 
 
 
58
  ### Prompt
59
  ${inputPrompt}
 
60
  #### Generated Image:
61
  <img src="${urlInputImg}" />
62
  `;
 
63
  const params = new URLSearchParams({
64
+ title: inputPrompt,
65
  description: descriptionMd,
66
  preview: true
67
  });
68
  const paramsStr = params.toString();
69
+ window.open(`https://huggingface.co/spaces/multimodalart/LoraTheExplorer/discussions/new?${paramsStr}`, '_blank');
70
  shareBtnEl.style.removeProperty('pointer-events');
71
  shareIconEl.style.removeProperty('display');
72
  loadingIconEl.style.display = 'none';