Spaces:
Runtime error
Runtime error
catch NSFW
Browse files- frontend/src/lib/App.svelte +7 -11
frontend/src/lib/App.svelte
CHANGED
@@ -137,14 +137,7 @@
|
|
137 |
const sessionHash = crypto.randomUUID();
|
138 |
const payload = {
|
139 |
fn_index: 0,
|
140 |
-
data: [
|
141 |
-
getImageCrop($clickedPosition),
|
142 |
-
_prompt,
|
143 |
-
0.75,
|
144 |
-
7.5,
|
145 |
-
30,
|
146 |
-
'patchmatch'
|
147 |
-
],
|
148 |
session_hash: sessionHash
|
149 |
};
|
150 |
console.log('payload', payload);
|
@@ -184,7 +177,9 @@
|
|
184 |
try {
|
185 |
const imgBase64 = data.output.data[0] as string;
|
186 |
const isNSWF = data.output.data[1] as boolean;
|
187 |
-
|
|
|
|
|
188 |
const imgBlob = await base64ToBlob(imgBase64);
|
189 |
const imgURL = await uploadImage(imgBlob, _prompt);
|
190 |
|
@@ -196,8 +191,9 @@
|
|
196 |
});
|
197 |
console.log(imgURL);
|
198 |
$loadingState = data.success ? 'Complete' : 'Error';
|
199 |
-
} catch (
|
200 |
-
|
|
|
201 |
}
|
202 |
websocket.close();
|
203 |
$isLoading = false;
|
|
|
137 |
const sessionHash = crypto.randomUUID();
|
138 |
const payload = {
|
139 |
fn_index: 0,
|
140 |
+
data: [getImageCrop($clickedPosition), _prompt, 0.75, 7.5, 30, 'patchmatch'],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
session_hash: sessionHash
|
142 |
};
|
143 |
console.log('payload', payload);
|
|
|
177 |
try {
|
178 |
const imgBase64 = data.output.data[0] as string;
|
179 |
const isNSWF = data.output.data[1] as boolean;
|
180 |
+
if (isNSWF) {
|
181 |
+
throw new Error('Potential NFSW content, please try again');
|
182 |
+
}
|
183 |
const imgBlob = await base64ToBlob(imgBase64);
|
184 |
const imgURL = await uploadImage(imgBlob, _prompt);
|
185 |
|
|
|
191 |
});
|
192 |
console.log(imgURL);
|
193 |
$loadingState = data.success ? 'Complete' : 'Error';
|
194 |
+
} catch (err) {
|
195 |
+
const tError = err as Error;
|
196 |
+
$loadingState = tError?.message;
|
197 |
}
|
198 |
websocket.close();
|
199 |
$isLoading = false;
|