Spaces:
Runtime error
Runtime error
add image position to file name
Browse files
frontend/src/lib/App.svelte
CHANGED
@@ -54,6 +54,7 @@
|
|
54 |
$loadingState = 'Pending';
|
55 |
const prompt = $myPresence.currentPrompt;
|
56 |
const position = $myPresence.frame;
|
|
|
57 |
const room = $selectedRoomID || 'default';
|
58 |
console.log('Generating...', prompt, position);
|
59 |
myPresence.update({
|
@@ -68,7 +69,7 @@
|
|
68 |
};
|
69 |
|
70 |
const datapayload = {
|
71 |
-
data: [base64Crop, prompt, 0.75, 7.5, 40, 'patchmatch', room]
|
72 |
};
|
73 |
|
74 |
const websocket = new WebSocket(PUBLIC_WS_INPAINTING);
|
@@ -122,7 +123,6 @@
|
|
122 |
if (isNSWF) {
|
123 |
throw new Error('NFSW');
|
124 |
}
|
125 |
-
const key = getKey(position);
|
126 |
// const imgBlob = await base64ToBlob(imgBase64);
|
127 |
const promptImgParams = {
|
128 |
prompt,
|
@@ -134,7 +134,7 @@
|
|
134 |
};
|
135 |
// const imgURL = await uploadImage(imgBlob, promptImgParams);
|
136 |
|
137 |
-
$promptImgStorage.set(
|
138 |
console.log(params.image.url);
|
139 |
$loadingState = data.success ? 'Complete' : 'Error';
|
140 |
setTimeout(() => {
|
|
|
54 |
$loadingState = 'Pending';
|
55 |
const prompt = $myPresence.currentPrompt;
|
56 |
const position = $myPresence.frame;
|
57 |
+
const imageKey = getKey(position);
|
58 |
const room = $selectedRoomID || 'default';
|
59 |
console.log('Generating...', prompt, position);
|
60 |
myPresence.update({
|
|
|
69 |
};
|
70 |
|
71 |
const datapayload = {
|
72 |
+
data: [base64Crop, prompt, 0.75, 7.5, 40, 'patchmatch', room, imageKey]
|
73 |
};
|
74 |
|
75 |
const websocket = new WebSocket(PUBLIC_WS_INPAINTING);
|
|
|
123 |
if (isNSWF) {
|
124 |
throw new Error('NFSW');
|
125 |
}
|
|
|
126 |
// const imgBlob = await base64ToBlob(imgBase64);
|
127 |
const promptImgParams = {
|
128 |
prompt,
|
|
|
134 |
};
|
135 |
// const imgURL = await uploadImage(imgBlob, promptImgParams);
|
136 |
|
137 |
+
$promptImgStorage.set(imageKey, promptImgParams);
|
138 |
console.log(params.image.url);
|
139 |
$loadingState = data.success ? 'Complete' : 'Error';
|
140 |
setTimeout(() => {
|
stablediffusion-infinity/app.py
CHANGED
@@ -126,7 +126,8 @@ async def run_outpaint(
|
|
126 |
guidance,
|
127 |
step,
|
128 |
fill_mode,
|
129 |
-
room_id
|
|
|
130 |
):
|
131 |
inpaint = get_model()
|
132 |
sel_buffer = np.array(input_image)
|
@@ -182,7 +183,7 @@ async def run_outpaint(
|
|
182 |
|
183 |
if not is_nsfw:
|
184 |
print("not nsfw, uploading")
|
185 |
-
image_url = await upload_file(image, prompt_text, room_id)
|
186 |
|
187 |
params = {
|
188 |
"is_nsfw": is_nsfw,
|
@@ -224,6 +225,7 @@ with blocks as demo:
|
|
224 |
|
225 |
model_input = gr.Image(label="Input", type="pil", image_mode="RGBA")
|
226 |
room_id = gr.Textbox(label="Room ID")
|
|
|
227 |
proceed_button = gr.Button("Proceed", elem_id="proceed")
|
228 |
params = gr.JSON()
|
229 |
|
@@ -237,6 +239,7 @@ with blocks as demo:
|
|
237 |
sd_step,
|
238 |
init_mode,
|
239 |
room_id,
|
|
|
240 |
],
|
241 |
outputs=[params],
|
242 |
)
|
@@ -326,8 +329,9 @@ def slugify(value):
|
|
326 |
return out[:400]
|
327 |
|
328 |
|
329 |
-
async def upload_file(image: Image.Image, prompt: str, room_id: str):
|
330 |
room_id = room_id.strip() or "uploads"
|
|
|
331 |
image = image.convert('RGB')
|
332 |
print("Uploading file from predict")
|
333 |
temp_file = io.BytesIO()
|
@@ -335,7 +339,7 @@ async def upload_file(image: Image.Image, prompt: str, room_id: str):
|
|
335 |
temp_file.seek(0)
|
336 |
id = shortuuid.uuid()
|
337 |
prompt_slug = slugify(prompt)
|
338 |
-
filename = f"{id}-{prompt_slug}.jpg"
|
339 |
s3.upload_fileobj(Fileobj=temp_file, Bucket=AWS_S3_BUCKET_NAME, Key=f"{room_id}/" +
|
340 |
filename, ExtraArgs={"ContentType": "image/jpeg", "CacheControl": "max-age=31536000"})
|
341 |
temp_file.close()
|
|
|
126 |
guidance,
|
127 |
step,
|
128 |
fill_mode,
|
129 |
+
room_id,
|
130 |
+
image_key
|
131 |
):
|
132 |
inpaint = get_model()
|
133 |
sel_buffer = np.array(input_image)
|
|
|
183 |
|
184 |
if not is_nsfw:
|
185 |
print("not nsfw, uploading")
|
186 |
+
image_url = await upload_file(image, prompt_text, room_id, image_key)
|
187 |
|
188 |
params = {
|
189 |
"is_nsfw": is_nsfw,
|
|
|
225 |
|
226 |
model_input = gr.Image(label="Input", type="pil", image_mode="RGBA")
|
227 |
room_id = gr.Textbox(label="Room ID")
|
228 |
+
image_key = gr.Textbox(label="image_key")
|
229 |
proceed_button = gr.Button("Proceed", elem_id="proceed")
|
230 |
params = gr.JSON()
|
231 |
|
|
|
239 |
sd_step,
|
240 |
init_mode,
|
241 |
room_id,
|
242 |
+
image_key
|
243 |
],
|
244 |
outputs=[params],
|
245 |
)
|
|
|
329 |
return out[:400]
|
330 |
|
331 |
|
332 |
+
async def upload_file(image: Image.Image, prompt: str, room_id: str, image_key: str):
|
333 |
room_id = room_id.strip() or "uploads"
|
334 |
+
image_key = image_key.strip() or ""
|
335 |
image = image.convert('RGB')
|
336 |
print("Uploading file from predict")
|
337 |
temp_file = io.BytesIO()
|
|
|
339 |
temp_file.seek(0)
|
340 |
id = shortuuid.uuid()
|
341 |
prompt_slug = slugify(prompt)
|
342 |
+
filename = f"{id}-{image_key}-{prompt_slug}.jpg"
|
343 |
s3.upload_fileobj(Fileobj=temp_file, Bucket=AWS_S3_BUCKET_NAME, Key=f"{room_id}/" +
|
344 |
filename, ExtraArgs={"ContentType": "image/jpeg", "CacheControl": "max-age=31536000"})
|
345 |
temp_file.close()
|