mirror of https://github.com/skygpu/skynet.git
Add frontend image reduction and fix ipfs sudo issue
parent
e63d395d5c
commit
a85518152a
|
@ -140,16 +140,22 @@ async def work_request(
|
|||
|
||||
if file_id:
|
||||
image_raw = await bot.download_file(file_path)
|
||||
image = Image.open(io.BytesIO(image_raw))
|
||||
with Image.open(io.BytesIO(image_raw)) as image:
|
||||
w, h = image.size
|
||||
logging.info(f'user sent img of size {image.size}')
|
||||
|
||||
if w > 512 or h > 512:
|
||||
logging.warning(f'user sent img of size {image.size}')
|
||||
image.thumbnail((512, 512))
|
||||
logging.warning(f'resized it to {image.size}')
|
||||
img_byte_arr = io.BytesIO()
|
||||
image.save(img_byte_arr, format='PNG')
|
||||
image_raw = img_byte_arr.getvalue()
|
||||
|
||||
binary = image_raw.hex()
|
||||
|
||||
else:
|
||||
binary = ''
|
||||
|
||||
ec, out = cleos.push_action(
|
||||
'telos.gpu', 'enqueue', [account, body, binary, '20.0000 GPU'], f'{account}@{permission}'
|
||||
)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import os
|
||||
import logging
|
||||
|
||||
from pathlib import Path
|
||||
|
@ -7,6 +8,7 @@ from contextlib import contextmanager as cm
|
|||
|
||||
import docker
|
||||
|
||||
from docker.types import Mount
|
||||
from docker.models.containers import Container
|
||||
|
||||
|
||||
|
@ -48,13 +50,27 @@ def open_ipfs_node():
|
|||
'4001/tcp': 4001,
|
||||
'5001/tcp': ('127.0.0.1', 5001)
|
||||
},
|
||||
volumes=[
|
||||
str(Path().resolve() / 'tmp/ipfs-docker-staging') + ':/export',
|
||||
str(Path().resolve() / 'tmp/ipfs-docker-data') + ':/data/ipfs'
|
||||
mounts=[
|
||||
Mount(
|
||||
'/export',
|
||||
str(Path().resolve() / 'tmp/ipfs-docker-staging'),
|
||||
'bind'
|
||||
),
|
||||
Mount(
|
||||
'/data/ipfs',
|
||||
str(Path().resolve() / 'tmp/ipfs-docker-data'),
|
||||
'bind'
|
||||
)
|
||||
],
|
||||
detach=True,
|
||||
remove=True
|
||||
)
|
||||
uid = os.getuid()
|
||||
gid = os.getgid()
|
||||
ec, out = container.exec_run(['chown', f'{uid}:{gid}', '-R', '/export'])
|
||||
assert ec == 0
|
||||
ec, out = container.exec_run(['chown', f'{uid}:{gid}', '-R', '/data/ipfs'])
|
||||
assert ec == 0
|
||||
try:
|
||||
|
||||
for log in container.logs(stream=True):
|
||||
|
|
Loading…
Reference in New Issue