Skip to content

Commit 73d1f74

Browse files
committed
Update build with working ai.js script
1 parent 6c397f8 commit 73d1f74

File tree

3 files changed

+56
-51
lines changed

3 files changed

+56
-51
lines changed

online/libresprite.data

Lines changed: 55 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -197379,6 +197379,7 @@ const defaultSettings = {
197379197379
easydiffusion: {
197380197380
endpoint:'http://localhost:9000'
197381197381
},
197382+
HFMID: "nerijs/pixel-art-xl",
197382197383
model: '',
197383197384
prompt: '',
197384197385
negativePrompt: '',
@@ -197472,64 +197473,61 @@ function postJSON(endpoint, path, body, cb) {
197472197473
}
197473197474

197474197475

197475-
const sdxlturboai = {
197476-
get:getJSON.bind(null, 'https://sd.cuilutech.com'),
197477-
post:postJSON.bind(null, 'https://sd.cuilutech.com'),
197476+
const lorastudio = {
197477+
post:postJSON.bind(null, 'https://lorastudio.co'),
197478197478

197479197479
logError:function(error) {
197480197480
if (!error)
197481197481
return;
197482197482
if (error == "status:0") {
197483197483
error = "\n"
197484197484
+ "***************************************\n*\n"
197485-
+ "* Could not connect to sdxlturbo.ai at:\n"
197486-
+ "* https://sd.cuilutech.com \n*\n"
197485+
+ "* Could not connect to lorastudio.co\n*\n"
197487197486
+ "***************************************\n\n"
197488197487
}
197489197488
console.log(error);
197490197489
},
197491197490

197492197491
render:function(obj, cb) {
197493-
this.post('/sdapi/turbo/txt2img', JSON.stringify(obj), function(data, error) {
197494-
if (!error && data && data.msg != "success")
197495-
error = data.msg;
197496-
if (!error && !data.data.image_url)
197492+
this.post('/api/generate', JSON.stringify(obj), function(data, error) {
197493+
197494+
if (!error && !data.image)
197497197495
error = JSON.stringify(data);
197498197496
if (error) {
197499-
cb(null, error);
197497+
cb(null, 'render post error: ' + error);
197500197498
return;
197501197499
}
197502197500

197503-
if (app.platform == "emscripten") {
197504-
app.launch(data.data.image_url); // server without CORS, must open in new tab
197505-
cb(null, null);
197506-
} else {
197507-
get(data.data.image_url, function(obj) {
197508-
cb(
197509-
(obj.status == 200 ? obj.key : null),
197510-
(obj.status == 200 ? null : JSON.stringify(obj))
197511-
);
197512-
}, 'png', 'ai');
197513-
}
197501+
var fileName = ai.settings.uniqueFilenames ? (Math.random()*0xFFFFFF|0) + '' : 'ai';
197502+
storage.set(data.image.substr(data.image.indexOf(',') + 1), 'png', fileName);
197503+
storage.decodeBase64('png', fileName);
197504+
var path = storage.save('png', fileName);
197505+
storage.unload('png', fileName);
197506+
cb(path, null);
197514197507
});
197515197508
},
197516197509

197517197510
generate:function() {
197518197511
ai.view("wait", true);
197519-
sdxlturboai.render({
197520-
"prompt": ai.settings.prompt,
197521-
"negative_prompt": ai.settings.negativePrompt,
197522-
"source": "sdxlturbo.ai"
197523-
}, function(key, error){
197512+
lorastudio.render({
197513+
"model":{
197514+
"instance_prompt":null,
197515+
"image":"",
197516+
"id":ai.settings.HFMID,
197517+
"metadata":null,
197518+
"isPublic":false,
197519+
"gallery":[],
197520+
"infos":{}
197521+
},
197522+
"inputs":ai.settings.prompt,
197523+
"parameters":{"negative_prompt":ai.settings.negativePrompt}
197524+
}, function(path, error){
197524197525
ai.close("wait");
197525197526
if (error) {
197526-
sdxlturboai.logError(error);
197527+
lorastudio.logError(error);
197527197528
}
197528-
if (key) {
197529-
var path = storage.save(key, 'ai');
197530-
storage.unload(key);
197531-
if (path)
197532-
app.open(path);
197529+
if (path) {
197530+
app.open(path);
197533197531
}
197534197532
});
197535197533
}
@@ -197755,12 +197753,12 @@ const views = {
197755197753
]
197756197754
},
197757197755
{type:"break"},
197758-
{type:"label", text:"sdxlturbo.ai:"},
197756+
{type:"label", text:"lorastudio.co:"},
197759197757
{type:"break"},
197760197758
{
197761197759
type:"button",
197762197760
text:"Text to Image",
197763-
click:function(){ai.view("sdxlturboai_T2I");}
197761+
click:function(){ai.view("lorastudio_T2I");}
197764197762
}
197765197763
],
197766197764

@@ -197778,8 +197776,14 @@ const views = {
197778197776
}
197779197777
],
197780197778

197781-
sdxlturboai_T2I : [
197782-
{type:"label", text:"Warning: Free public service with no privacy policy."},
197779+
lorastudio_T2I : [
197780+
{type:"label", text:"Model:"},
197781+
{type:"break"},
197782+
{
197783+
type:"entry",
197784+
maxsize:128,
197785+
bind:"settings.HFMID"
197786+
},
197783197787
{type:"break"},
197784197788

197785197789
{type:"label", text:"Prompt:"},
@@ -197805,7 +197809,7 @@ const views = {
197805197809
type:"button",
197806197810
text:"Generate",
197807197811
click:function(){
197808-
sdxlturboai.generate();
197812+
lorastudio.generate();
197809197813
}
197810197814
}
197811197815
],
@@ -198278,12 +198282,18 @@ const sdxlturboai = {
198278198282
cb(null, error);
198279198283
return;
198280198284
}
198281-
get(data.data.image_url, function(obj) {
198282-
cb(
198283-
(obj.status == 200 ? obj.key : null),
198284-
(obj.status == 200 ? null : JSON.stringify(obj))
198285-
);
198286-
}, 'png', 'ai');
198285+
198286+
if (app.platform == "emscripten") {
198287+
app.launch(data.data.image_url); // server without CORS, must open in new tab
198288+
cb(null, null);
198289+
} else {
198290+
get(data.data.image_url, function(obj) {
198291+
cb(
198292+
(obj.status == 200 ? obj.key : null),
198293+
(obj.status == 200 ? null : JSON.stringify(obj))
198294+
);
198295+
}, 'png', 'ai');
198296+
}
198287198297
});
198288198298
},
198289198299

@@ -198294,13 +198304,11 @@ const sdxlturboai = {
198294198304
"negative_prompt": ai.settings.negativePrompt,
198295198305
"source": "sdxlturbo.ai"
198296198306
}, function(key, error){
198307+
ai.close("wait");
198297198308
if (error) {
198298198309
sdxlturboai.logError(error);
198299-
ai.close("wait");
198300-
return;
198301198310
}
198302198311
if (key) {
198303-
ai.close("wait");
198304198312
var path = storage.save(key, 'ai');
198305198313
storage.unload(key);
198306198314
if (path)
@@ -198925,11 +198933,8 @@ Object.assign(AI.prototype, {
198925198933
function onEvent(event) {
198926198934
if (typeof ai == "undefined")
198927198935
ai = new AI();
198928-
if (typeof ai[event] == "function") {
198936+
if (typeof ai[event] == "function")
198929198937
ai[event]();
198930-
} else {
198931-
console.log("Unknown event " + event);
198932-
}
198933198938
}
198934198939
const methods = {
198935198940
init(){

online/libresprite.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

online/libresprite.wasm

35 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)