Spaces:
Runtime error
Runtime error
Commit
•
5495410
1
Parent(s):
eae27f0
trying to fix
Browse files
src/app/interface/bottom-bar/index.tsx
CHANGED
@@ -18,11 +18,17 @@ export function BottomBar() {
|
|
18 |
const remainingImages = allStatus.reduce((acc, s) => (acc + (s ? 1 : 0)), 0)
|
19 |
|
20 |
const handleShare = async () => {
|
21 |
-
|
22 |
// console.log("dataUrl:", dataUrl)
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
const descriptionMd = `
|
28 |
#### Prompt:
|
@@ -32,10 +38,10 @@ export function BottomBar() {
|
|
32 |
\`\`\`${preset.label}\`\`\`
|
33 |
|
34 |
#### Comic:
|
35 |
-
|
36 |
-
(
|
|
|
37 |
`;
|
38 |
-
// ![${prompt}](${uploadUrl})
|
39 |
|
40 |
console.log("descriptionMd:", descriptionMd)
|
41 |
|
|
|
18 |
const remainingImages = allStatus.reduce((acc, s) => (acc + (s ? 1 : 0)), 0)
|
19 |
|
20 |
const handleShare = async () => {
|
21 |
+
const dataUrl = await pageToImage()
|
22 |
// console.log("dataUrl:", dataUrl)
|
23 |
+
const fileToUpload = base64ToFile(dataUrl, "comic.png")
|
24 |
+
let uploadUrl = ""
|
25 |
+
try {
|
26 |
+
uploadUrl = await uploadToHuggingFace(fileToUpload)
|
27 |
+
console.log("uploadUrl:", uploadUrl)
|
28 |
+
} catch (err) {
|
29 |
+
console.error("Failed to upload the image to Hugging Face")
|
30 |
+
}
|
31 |
+
|
32 |
|
33 |
const descriptionMd = `
|
34 |
#### Prompt:
|
|
|
38 |
\`\`\`${preset.label}\`\`\`
|
39 |
|
40 |
#### Comic:
|
41 |
+
${uploadUrl
|
42 |
+
? (`![${prompt}](${uploadUrl})`)
|
43 |
+
: (`(please drag & drop your JPG image here)`)}
|
44 |
`;
|
|
|
45 |
|
46 |
console.log("descriptionMd:", descriptionMd)
|
47 |
|
src/app/interface/panel/index.tsx
CHANGED
@@ -62,7 +62,7 @@ export function Panel({
|
|
62 |
|
63 |
console.log(`Loading panel ${panel}..`)
|
64 |
|
65 |
-
let newRendered
|
66 |
try {
|
67 |
newRendered = await newRender({ prompt, width, height })
|
68 |
} catch (err) {
|
@@ -117,8 +117,9 @@ export function Panel({
|
|
117 |
if (newRendered.status === "pending") {
|
118 |
// console.log("job not finished")
|
119 |
timeoutRef.current = setTimeout(checkStatus, delay)
|
120 |
-
} else if (newRendered.status === "error"
|
121 |
-
|
|
|
122 |
try {
|
123 |
const newAttempt = await newRender({ prompt, width, height })
|
124 |
setRendered(renderedRef.current = newAttempt)
|
|
|
62 |
|
63 |
console.log(`Loading panel ${panel}..`)
|
64 |
|
65 |
+
let newRendered: RenderedScene
|
66 |
try {
|
67 |
newRendered = await newRender({ prompt, width, height })
|
68 |
} catch (err) {
|
|
|
117 |
if (newRendered.status === "pending") {
|
118 |
// console.log("job not finished")
|
119 |
timeoutRef.current = setTimeout(checkStatus, delay)
|
120 |
+
} else if (newRendered.status === "error" ||
|
121 |
+
(newRendered.status === "completed" && !newRendered.assetUrl?.length)) {
|
122 |
+
console.log(`panel got an error and/or an empty asset url :/ "${newRendered.error}", but let's try to recover..`)
|
123 |
try {
|
124 |
const newAttempt = await newRender({ prompt, width, height })
|
125 |
setRendered(renderedRef.current = newAttempt)
|