prithivMLmods commited on
Commit
ca8eae9
·
verified ·
1 Parent(s): c3c00e3

update app [ncii blocks]

Browse files
Files changed (1) hide show
  1. app.py +24 -11
app.py CHANGED
@@ -924,7 +924,9 @@ function init() {
924
 
925
  window.__clickGradioRunBtn = function() {
926
  if (!validateBeforeRun()) return;
927
- syncPromptToGradio(); syncImagesToGradio(); showLoader();
 
 
928
  setTimeout(() => {
929
  const gradioBtn = document.getElementById('gradio-run-btn');
930
  if (!gradioBtn) return;
@@ -966,8 +968,8 @@ function watchOutputs() {
966
 
967
  function syncImage() {
968
  const resultImg = resultContainer.querySelector('img');
969
- const loader = document.getElementById('output-loader');
970
- if (resultImg && resultImg.src) {
971
  if (outPh) outPh.style.display = 'none';
972
  let existing = outBody.querySelector('img.modern-out-img');
973
  if (!existing) {
@@ -980,14 +982,6 @@ function watchOutputs() {
980
  if (dlBtn) dlBtn.classList.add('visible');
981
  if (window.__hideLoader) window.__hideLoader();
982
  }
983
- } else {
984
- if (loader && loader.classList.contains('active')) {
985
- if (window.__hideLoader) window.__hideLoader();
986
- const existing = outBody.querySelector('img.modern-out-img');
987
- if (existing) existing.remove();
988
- if (dlBtn) dlBtn.classList.remove('visible');
989
- if (outPh) outPh.style.display = '';
990
- }
991
  }
992
  }
993
  const observer = new MutationObserver(syncImage);
@@ -1270,8 +1264,27 @@ with gr.Blocks() as demo:
1270
  const imgsJson = JSON.stringify(b64Array);
1271
  const promptEl = document.getElementById('custom-prompt-input');
1272
  const promptVal = promptEl ? promptEl.value : p;
 
1273
  return [imgsJson, promptVal, s, rs, gs, st];
1274
  }""",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1275
  )
1276
 
1277
  example_load_btn.click(
 
924
 
925
  window.__clickGradioRunBtn = function() {
926
  if (!validateBeforeRun()) return;
927
+ syncPromptToGradio(); syncImagesToGradio();
928
+ if (window.__showLoader) window.__showLoader();
929
+ window.__isProcessing = true;
930
  setTimeout(() => {
931
  const gradioBtn = document.getElementById('gradio-run-btn');
932
  if (!gradioBtn) return;
 
968
 
969
  function syncImage() {
970
  const resultImg = resultContainer.querySelector('img');
971
+ // Only hide loader and show image if a valid new image is fully present
972
+ if (resultImg && resultImg.src && resultImg.src !== window.location.href) {
973
  if (outPh) outPh.style.display = 'none';
974
  let existing = outBody.querySelector('img.modern-out-img');
975
  if (!existing) {
 
982
  if (dlBtn) dlBtn.classList.add('visible');
983
  if (window.__hideLoader) window.__hideLoader();
984
  }
 
 
 
 
 
 
 
 
985
  }
986
  }
987
  const observer = new MutationObserver(syncImage);
 
1264
  const imgsJson = JSON.stringify(b64Array);
1265
  const promptEl = document.getElementById('custom-prompt-input');
1266
  const promptVal = promptEl ? promptEl.value : p;
1267
+ window.__isProcessing = true;
1268
  return [imgsJson, promptVal, s, rs, gs, st];
1269
  }""",
1270
+ ).then(
1271
+ fn=None,
1272
+ js=r"""() => {
1273
+ window.__isProcessing = false;
1274
+ const resultContainer = document.getElementById('gradio-result');
1275
+ const resultImg = resultContainer ? resultContainer.querySelector('img') : null;
1276
+ // If the process finishes and no image is present (e.g., NCII blocked), safely hide loader
1277
+ if (!resultImg || !resultImg.src) {
1278
+ if (window.__hideLoader) window.__hideLoader();
1279
+ const outBody = document.getElementById('output-image-container');
1280
+ const existing = outBody ? outBody.querySelector('img.modern-out-img') : null;
1281
+ if (existing) existing.remove();
1282
+ const dlBtn = document.getElementById('dl-btn-output');
1283
+ if (dlBtn) dlBtn.classList.remove('visible');
1284
+ const outPh = document.getElementById('output-placeholder');
1285
+ if (outPh) outPh.style.display = '';
1286
+ }
1287
+ }"""
1288
  )
1289
 
1290
  example_load_btn.click(