FABLESLIP commited on
Commit
afd2a57
·
verified ·
1 Parent(s): b01ddf3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +59 -7
app.py CHANGED
@@ -839,7 +839,29 @@ const warmupLogs = document.getElementById('warmup-logs');
839
  const warmupCloseBtn = document.getElementById('warmupCloseBtn');
840
 
841
  // Helpers popup
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
842
  function openWarmupPopup(){ if(warmupPopup) warmupPopup.style.display = 'block'; }
 
843
  function closeWarmupPopup(){ if(warmupPopup) warmupPopup.style.display = 'none'; }
844
  if (warmupCloseBtn) warmupCloseBtn.addEventListener('click', closeWarmupPopup);
845
 
@@ -879,21 +901,51 @@ async function refreshWarmupUI(){
879
  // Boutons
880
  if (warmupStartBtn){
881
  warmupStartBtn.addEventListener('click', async ()=>{
882
- // Optionnel : l’utilisateur peut saisir une liste (CSV). Vide => configuration serveur (WARMUP_MODELS)
883
- const txt = prompt('Modèles (optionnel, séparés par des virgules). Laisse vide pour utiliser la config du serveur :','');
884
- let body = {};
 
 
 
 
 
 
 
 
 
 
885
  if (txt && txt.trim()){
886
- body = { models: txt.split(',').map(s=>s.trim()).filter(Boolean) };
 
 
 
887
  }
 
888
  try{
889
- const r = await fetch('/warmup/start',{ method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify(body) });
890
- if(!r.ok){ const t = await r.text(); alert('Échec démarrage: ' + r.status + ' ' + t); return; }
 
 
 
 
 
 
 
 
891
  openWarmupPopup();
892
  await refreshWarmupUI();
893
  if (!warmupTimer) warmupTimer = setInterval(refreshWarmupUI, 1000);
894
- }catch(e){ alert('Erreur réseau'); }
 
 
895
  });
896
  }
 
 
 
 
 
 
897
  if (warmupLogsBtn){
898
  warmupLogsBtn.addEventListener('click', async ()=>{
899
  openWarmupPopup();
 
839
  const warmupCloseBtn = document.getElementById('warmupCloseBtn');
840
 
841
  // Helpers popup
842
+
843
+
844
+
845
+
846
+
847
+ // >>> A2B2P3_BEGIN warmup_defaults
848
+ // Modèles par défaut si l’utilisateur laisse la saisie vide.
849
+ // (Liste “safe” validée chez toi ; on pourra l’étendre plus tard.)
850
+ const DEFAULT_MODELS = [
851
+ "runwayml/stable-diffusion-v1-5",
852
+ "facebook/sam-vit-base",
853
+ "stabilityai/sd-vae-ft-mse"
854
+ ];
855
+ // >>> A2B2P3_END warmup_defaults
856
+
857
+
858
+
859
+
860
+
861
+
862
+
863
  function openWarmupPopup(){ if(warmupPopup) warmupPopup.style.display = 'block'; }
864
+
865
  function closeWarmupPopup(){ if(warmupPopup) warmupPopup.style.display = 'none'; }
866
  if (warmupCloseBtn) warmupCloseBtn.addEventListener('click', closeWarmupPopup);
867
 
 
901
  // Boutons
902
  if (warmupStartBtn){
903
  warmupStartBtn.addEventListener('click', async ()=>{
904
+
905
+
906
+
907
+
908
+
909
+ // Saisie optionnelle ; vide => on lance avec DEFAULT_MODELS définis plus haut (P4.1)
910
+ const txt = prompt(
911
+ 'Modèles (optionnel, séparés par des virgules).\n' +
912
+ 'Laisse vide pour utiliser la liste par défaut.',
913
+ ''
914
+ );
915
+
916
+ let body;
917
  if (txt && txt.trim()){
918
+ const mods = txt.split(',').map(s=>s.trim()).filter(Boolean);
919
+ body = { models: mods.length ? mods : DEFAULT_MODELS };
920
+ } else {
921
+ body = { models: DEFAULT_MODELS };
922
  }
923
+
924
  try{
925
+ const r = await fetch('/warmup/start', {
926
+ method:'POST',
927
+ headers:{ 'Content-Type':'application/json' },
928
+ body: JSON.stringify(body)
929
+ });
930
+ if(!r.ok){
931
+ const t = await r.text();
932
+ alert('Échec démarrage: ' + r.status + ' ' + t);
933
+ return;
934
+ }
935
  openWarmupPopup();
936
  await refreshWarmupUI();
937
  if (!warmupTimer) warmupTimer = setInterval(refreshWarmupUI, 1000);
938
+ }catch(e){
939
+ alert('Erreur réseau');
940
+ }
941
  });
942
  }
943
+
944
+
945
+
946
+
947
+
948
+
949
  if (warmupLogsBtn){
950
  warmupLogsBtn.addEventListener('click', async ()=>{
951
  openWarmupPopup();