Spaces:
Runtime error
Runtime error
new uploads group by room
Browse files
frontend/.env.development.example
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
PUBLIC_WS_INPAINTING="ws://0.0.0.0:7860/gradio/queue/join"
|
2 |
-
PUBLIC_UPLOADS="https://d26smi9133w0oo.cloudfront.net
|
3 |
PUBLIC_API_BASE="/server/api"
|
|
|
1 |
PUBLIC_WS_INPAINTING="ws://0.0.0.0:7860/gradio/queue/join"
|
2 |
+
PUBLIC_UPLOADS="https://d26smi9133w0oo.cloudfront.net"
|
3 |
PUBLIC_API_BASE="/server/api"
|
frontend/.env.example
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
PUBLIC_WS_INPAINTING="wss://spaces.huggingface.tech/huggingface-projects/stable-diffusion-multiplayer/gradio/queue/join"
|
2 |
-
PUBLIC_UPLOADS="https://d26smi9133w0oo.cloudfront.net
|
3 |
PUBLIC_API_BASE="/api"
|
|
|
1 |
PUBLIC_WS_INPAINTING="wss://spaces.huggingface.tech/huggingface-projects/stable-diffusion-multiplayer/gradio/queue/join"
|
2 |
+
PUBLIC_UPLOADS="https://d26smi9133w0oo.cloudfront.net"
|
3 |
PUBLIC_API_BASE="/api"
|
frontend/src/lib/PaintCanvas.svelte
CHANGED
@@ -141,7 +141,7 @@
|
|
141 |
$isRenderingCanvas = true;
|
142 |
Promise.allSettled(
|
143 |
promptImgList.map(
|
144 |
-
({ imgURL, position, id }) =>
|
145 |
new Promise<ImageRendered>((resolve, reject) => {
|
146 |
const img = new Image();
|
147 |
img.crossOrigin = 'anonymous';
|
@@ -153,7 +153,7 @@
|
|
153 |
img.onerror = (err) => {
|
154 |
reject(err);
|
155 |
};
|
156 |
-
img.src = `${PUBLIC_UPLOADS}/${imgURL}`;
|
157 |
})
|
158 |
)
|
159 |
).then((values) => {
|
|
|
141 |
$isRenderingCanvas = true;
|
142 |
Promise.allSettled(
|
143 |
promptImgList.map(
|
144 |
+
({ imgURL, position, id, room }) =>
|
145 |
new Promise<ImageRendered>((resolve, reject) => {
|
146 |
const img = new Image();
|
147 |
img.crossOrigin = 'anonymous';
|
|
|
153 |
img.onerror = (err) => {
|
154 |
reject(err);
|
155 |
};
|
156 |
+
img.src = `${PUBLIC_UPLOADS}/${room}/${imgURL}`;
|
157 |
})
|
158 |
)
|
159 |
).then((values) => {
|
stablediffusion-infinity/app.py
CHANGED
@@ -126,6 +126,7 @@ async def run_outpaint(
|
|
126 |
guidance,
|
127 |
step,
|
128 |
fill_mode,
|
|
|
129 |
):
|
130 |
inpaint = get_model()
|
131 |
sel_buffer = np.array(input_image)
|
@@ -181,7 +182,7 @@ async def run_outpaint(
|
|
181 |
|
182 |
if not is_nsfw:
|
183 |
print("not nsfw, uploading")
|
184 |
-
image_url = await upload_file(image, prompt_text)
|
185 |
|
186 |
params = {
|
187 |
"is_nsfw": is_nsfw,
|
@@ -222,6 +223,7 @@ with blocks as demo:
|
|
222 |
)
|
223 |
|
224 |
model_input = gr.Image(label="Input", type="pil", image_mode="RGBA")
|
|
|
225 |
proceed_button = gr.Button("Proceed", elem_id="proceed")
|
226 |
params = gr.JSON()
|
227 |
|
@@ -234,6 +236,7 @@ with blocks as demo:
|
|
234 |
sd_guidance,
|
235 |
sd_step,
|
236 |
init_mode,
|
|
|
237 |
],
|
238 |
outputs=[params],
|
239 |
)
|
@@ -323,8 +326,8 @@ def slugify(value):
|
|
323 |
return out[:400]
|
324 |
|
325 |
|
326 |
-
|
327 |
-
|
328 |
image = image.convert('RGB')
|
329 |
print("Uploading file from predict")
|
330 |
temp_file = io.BytesIO()
|
@@ -333,24 +336,18 @@ async def upload_file(image: Image.Image, prompt: str):
|
|
333 |
id = shortuuid.uuid()
|
334 |
prompt_slug = slugify(prompt)
|
335 |
filename = f"{id}-{prompt_slug}.jpg"
|
336 |
-
s3.upload_fileobj(Fileobj=temp_file, Bucket=AWS_S3_BUCKET_NAME, Key="
|
337 |
filename, ExtraArgs={"ContentType": "image/jpeg", "CacheControl": "max-age=31536000"})
|
338 |
temp_file.close()
|
339 |
|
340 |
-
out = {"url": f'https://d26smi9133w0oo.cloudfront.net/
|
341 |
"filename": filename}
|
342 |
print(out)
|
343 |
return out
|
344 |
|
345 |
|
346 |
@ app.post('/api/uploadfile')
|
347 |
-
async def create_upload_file(
|
348 |
-
file: UploadFile,
|
349 |
-
prompt: str = Form(),
|
350 |
-
id: str = Form(),
|
351 |
-
position: object = Form(),
|
352 |
-
room: str = Form(),
|
353 |
-
date: int = Form()):
|
354 |
contents = await file.read()
|
355 |
file_size = len(contents)
|
356 |
if not 0 < file_size < 20E+06:
|
@@ -367,13 +364,11 @@ async def create_upload_file(background_tasks: BackgroundTasks,
|
|
367 |
temp_file = io.BytesIO()
|
368 |
temp_file.write(contents)
|
369 |
temp_file.seek(0)
|
370 |
-
s3.upload_fileobj(Fileobj=temp_file, Bucket=AWS_S3_BUCKET_NAME, Key="
|
371 |
file.filename, ExtraArgs={"ContentType": file.content_type, "CacheControl": "max-age=31536000"})
|
372 |
temp_file.close()
|
373 |
|
374 |
-
|
375 |
-
|
376 |
-
return {"url": f'https://d26smi9133w0oo.cloudfront.net/uploads/{file.filename}', "filename": file.filename}
|
377 |
|
378 |
|
379 |
app.mount("/", StaticFiles(directory="../static", html=True), name="static")
|
|
|
126 |
guidance,
|
127 |
step,
|
128 |
fill_mode,
|
129 |
+
room_id
|
130 |
):
|
131 |
inpaint = get_model()
|
132 |
sel_buffer = np.array(input_image)
|
|
|
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,
|
|
|
223 |
)
|
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 |
|
|
|
236 |
sd_guidance,
|
237 |
sd_step,
|
238 |
init_mode,
|
239 |
+
room_id,
|
240 |
],
|
241 |
outputs=[params],
|
242 |
)
|
|
|
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()
|
|
|
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()
|
342 |
|
343 |
+
out = {"url": f'https://d26smi9133w0oo.cloudfront.net/{room_id}/{filename}',
|
344 |
"filename": filename}
|
345 |
print(out)
|
346 |
return out
|
347 |
|
348 |
|
349 |
@ app.post('/api/uploadfile')
|
350 |
+
async def create_upload_file(file: UploadFile):
|
|
|
|
|
|
|
|
|
|
|
|
|
351 |
contents = await file.read()
|
352 |
file_size = len(contents)
|
353 |
if not 0 < file_size < 20E+06:
|
|
|
364 |
temp_file = io.BytesIO()
|
365 |
temp_file.write(contents)
|
366 |
temp_file.seek(0)
|
367 |
+
s3.upload_fileobj(Fileobj=temp_file, Bucket=AWS_S3_BUCKET_NAME, Key="community/" +
|
368 |
file.filename, ExtraArgs={"ContentType": file.content_type, "CacheControl": "max-age=31536000"})
|
369 |
temp_file.close()
|
370 |
|
371 |
+
return {"url": f'https://d26smi9133w0oo.cloudfront.net/community/{file.filename}', "filename": file.filename}
|
|
|
|
|
372 |
|
373 |
|
374 |
app.mount("/", StaticFiles(directory="../static", html=True), name="static")
|