tiny fix to prevent generate-ahead from freaking out with alerts if something goes wrong

This commit is contained in:
tim h 2023-01-08 16:44:46 -06:00
parent db3875ad09
commit 40c69d7dd6
2 changed files with 12 additions and 6 deletions

View file

@ -339,7 +339,7 @@
<script src="js/global.js?v=3a1cde6" type="text/javascript"></script> <script src="js/global.js?v=3a1cde6" type="text/javascript"></script>
<!-- Base Libs --> <!-- Base Libs -->
<script src="js/lib/util.js?v=7f6847c" type="text/javascript"></script> <script src="js/lib/util.js?v=5838390" type="text/javascript"></script>
<script src="js/lib/events.js?v=2ab7933" type="text/javascript"></script> <script src="js/lib/events.js?v=2ab7933" type="text/javascript"></script>
<script src="js/lib/input.js?v=09298ac" type="text/javascript"></script> <script src="js/lib/input.js?v=09298ac" type="text/javascript"></script>
<script src="js/lib/layers.js?v=a1f8aea" type="text/javascript"></script> <script src="js/lib/layers.js?v=a1f8aea" type="text/javascript"></script>
@ -368,10 +368,10 @@
<!-- Load Tools --> <!-- Load Tools -->
<script <script
src="js/ui/tool/generic.js?v=2bcd36d" src="js/ui/tool/generic.js?v=f1a19a4"
type="text/javascript"></script> type="text/javascript"></script>
<script src="js/ui/tool/dream.js?v=18e3b66" type="text/javascript"></script> <script src="js/ui/tool/dream.js?v=a2932df" type="text/javascript"></script>
<script <script
src="js/ui/tool/maskbrush.js?v=1e8a893" src="js/ui/tool/maskbrush.js?v=1e8a893"
type="text/javascript"></script> type="text/javascript"></script>

View file

@ -177,6 +177,7 @@ const _dream = async (endpoint, request) => {
* @returns {Promise<HTMLImageElement | null>} * @returns {Promise<HTMLImageElement | null>}
*/ */
const _generate = async (endpoint, request, bb, options = {}) => { const _generate = async (endpoint, request, bb, options = {}) => {
var alertCount = 0;
defaultOpt(options, { defaultOpt(options, {
drawEvery: 0.2 / request.n_iter, drawEvery: 0.2 / request.n_iter,
keepUnmask: null, keepUnmask: null,
@ -532,9 +533,14 @@ const _generate = async (endpoint, request, bb, options = {}) => {
seeds.push(...dreamData.seeds); seeds.push(...dreamData.seeds);
imageindextxt.textContent = `${at}/${images.length - 1}`; imageindextxt.textContent = `${at}/${images.length - 1}`;
} catch (e) { } catch (e) {
if (alertCount < 2) {
alert( alert(
`Error generating images. Please try again or see console for more details` `Error generating images. Please try again or see console for more details`
); );
} else {
eagerGenerateCount = 0;
}
alertCount++;
console.warn(`[dream] Error generating images:`); console.warn(`[dream] Error generating images:`);
console.warn(e); console.warn(e);
} finally { } finally {