mirror of https://github.com/skygpu/skynet.git
commit
7f50952088
|
@ -384,9 +384,9 @@ def dgpu(
|
||||||
@click.option(
|
@click.option(
|
||||||
'--key', '-k', default=None)
|
'--key', '-k', default=None)
|
||||||
@click.option(
|
@click.option(
|
||||||
'--hyperion-url', '-y', default=f'https://{DEFAULT_DOMAIN}')
|
'--hyperion-url', '-y', default=f'https://testnet.{DEFAULT_DOMAIN}')
|
||||||
@click.option(
|
@click.option(
|
||||||
'--node-url', '-n', default=f'https://{DEFAULT_DOMAIN}')
|
'--node-url', '-n', default=f'https://testnet.{DEFAULT_DOMAIN}')
|
||||||
@click.option(
|
@click.option(
|
||||||
'--ipfs-url', '-i', default=DEFAULT_IPFS_REMOTE)
|
'--ipfs-url', '-i', default=DEFAULT_IPFS_REMOTE)
|
||||||
@click.option(
|
@click.option(
|
||||||
|
@ -445,9 +445,9 @@ def telegram(
|
||||||
@click.option(
|
@click.option(
|
||||||
'--key', '-k', default=None)
|
'--key', '-k', default=None)
|
||||||
@click.option(
|
@click.option(
|
||||||
'--hyperion-url', '-y', default=f'https://{DEFAULT_DOMAIN}')
|
'--hyperion-url', '-y', default=f'https://testnet.{DEFAULT_DOMAIN}')
|
||||||
@click.option(
|
@click.option(
|
||||||
'--node-url', '-n', default=f'https://{DEFAULT_DOMAIN}')
|
'--node-url', '-n', default=f'https://testnet.{DEFAULT_DOMAIN}')
|
||||||
@click.option(
|
@click.option(
|
||||||
'--ipfs-url', '-i', default=DEFAULT_IPFS_REMOTE)
|
'--ipfs-url', '-i', default=DEFAULT_IPFS_REMOTE)
|
||||||
@click.option(
|
@click.option(
|
||||||
|
|
|
@ -37,7 +37,7 @@ commands work on a user per user basis!
|
||||||
config is individual to each user!
|
config is individual to each user!
|
||||||
|
|
||||||
/txt2img TEXT - request an image based on a prompt
|
/txt2img TEXT - request an image based on a prompt
|
||||||
/img2img <attach_image> TEXT - request an image base on an image and a promtp
|
/img2img <attach_image> TEXT - request an image base on an image and a prompt
|
||||||
|
|
||||||
/redo - redo last command (only works for txt2img for now!)
|
/redo - redo last command (only works for txt2img for now!)
|
||||||
|
|
||||||
|
@ -54,14 +54,17 @@ config is individual to each user!
|
||||||
{N.join(SHORT_NAMES)}
|
{N.join(SHORT_NAMES)}
|
||||||
|
|
||||||
/config step NUMBER - set amount of iterations
|
/config step NUMBER - set amount of iterations
|
||||||
/config seed NUMBER - set the seed, deterministic results!
|
/config seed [auto|NUMBER] - set the seed, deterministic results!
|
||||||
/config size WIDTH HEIGHT - set size in pixels
|
/config width NUMBER - set horizontal size in pixels
|
||||||
|
/config height NUMBER - set vertical size in pixels
|
||||||
|
/config upscaler [off/x4] - enable/disable x4 size upscaler
|
||||||
/config guidance NUMBER - prompt text importance
|
/config guidance NUMBER - prompt text importance
|
||||||
|
/config strength NUMBER - importance of the input image for img2img
|
||||||
'''
|
'''
|
||||||
|
|
||||||
UNKNOWN_CMD_TEXT = 'Unknown command! Try sending \"/help\"'
|
UNKNOWN_CMD_TEXT = 'Unknown command! Try sending \"/help\"'
|
||||||
|
|
||||||
DONATION_INFO = '0xf95335682DF281FFaB7E104EB87B69625d9622B6\ngoal: 25/650usd'
|
DONATION_INFO = '0xf95335682DF281FFaB7E104EB87B69625d9622B6\ngoal: 0.0465/1.0000 ETH'
|
||||||
|
|
||||||
COOL_WORDS = [
|
COOL_WORDS = [
|
||||||
'cyberpunk',
|
'cyberpunk',
|
||||||
|
@ -123,7 +126,16 @@ quality.
|
||||||
'guidance': '''
|
'guidance': '''
|
||||||
The guidance scale is a parameter that controls how much the image generation\
|
The guidance scale is a parameter that controls how much the image generation\
|
||||||
process follows the text prompt. The higher the value, the more image sticks\
|
process follows the text prompt. The higher the value, the more image sticks\
|
||||||
to a given text input.
|
to a given text input. Value range 0 to 20. Recomended range: 4.5-7.5.
|
||||||
|
''',
|
||||||
|
|
||||||
|
'strength': '''
|
||||||
|
Noise is added to the image you use as an init image for img2img, and then the\
|
||||||
|
diffusion process continues according to the prompt. The amount of noise added\
|
||||||
|
depends on the \"Strength of img2img\"” parameter, which ranges from 0 to 1,\
|
||||||
|
where 0 adds no noise at all and you will get the exact image you added, and\
|
||||||
|
1 completely replaces the image with noise and almost acts as if you used\
|
||||||
|
normal txt2img instead of img2img.
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,13 +152,13 @@ MAX_HEIGHT = 1024
|
||||||
MAX_GUIDANCE = 20
|
MAX_GUIDANCE = 20
|
||||||
|
|
||||||
DEFAULT_SEED = None
|
DEFAULT_SEED = None
|
||||||
DEFAULT_WIDTH = 512
|
DEFAULT_WIDTH = 1024
|
||||||
DEFAULT_HEIGHT = 512
|
DEFAULT_HEIGHT = 1024
|
||||||
DEFAULT_GUIDANCE = 7.5
|
DEFAULT_GUIDANCE = 7.5
|
||||||
DEFAULT_STRENGTH = 0.5
|
DEFAULT_STRENGTH = 0.5
|
||||||
DEFAULT_STEP = 35
|
DEFAULT_STEP = 28
|
||||||
DEFAULT_CREDITS = 10
|
DEFAULT_CREDITS = 10
|
||||||
DEFAULT_MODEL = list(MODELS.keys())[0]
|
DEFAULT_MODEL = list(MODELS.keys())[4]
|
||||||
DEFAULT_ROLE = 'pleb'
|
DEFAULT_ROLE = 'pleb'
|
||||||
DEFAULT_UPSCALER = None
|
DEFAULT_UPSCALER = None
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ class SkynetDiscordFrontend:
|
||||||
ctx: discord.ext.commands.context.Context | discord.Message,
|
ctx: discord.ext.commands.context.Context | discord.Message,
|
||||||
file_id: str | None = None,
|
file_id: str | None = None,
|
||||||
binary_data: str = ''
|
binary_data: str = ''
|
||||||
):
|
) -> bool:
|
||||||
send = ctx.channel.send
|
send = ctx.channel.send
|
||||||
|
|
||||||
if params['seed'] == None:
|
if params['seed'] == None:
|
||||||
|
@ -168,7 +168,7 @@ class SkynetDiscordFrontend:
|
||||||
await self.bot.channel.send(
|
await self.bot.channel.send(
|
||||||
status_msg,
|
status_msg,
|
||||||
'skynet has suffered an internal error trying to fill this request')
|
'skynet has suffered an internal error trying to fill this request')
|
||||||
return
|
return False
|
||||||
|
|
||||||
enqueue_tx_id = res['transaction_id']
|
enqueue_tx_id = res['transaction_id']
|
||||||
enqueue_tx_link = f'[**Your request on Skynet Explorer**](https://explorer.{DEFAULT_DOMAIN}/v2/explore/transaction/{enqueue_tx_id})'
|
enqueue_tx_link = f'[**Your request on Skynet Explorer**](https://explorer.{DEFAULT_DOMAIN}/v2/explore/transaction/{enqueue_tx_id})'
|
||||||
|
@ -230,7 +230,7 @@ class SkynetDiscordFrontend:
|
||||||
color=discord.Color.blue())
|
color=discord.Color.blue())
|
||||||
|
|
||||||
await message.edit(embed=embed)
|
await message.edit(embed=embed)
|
||||||
return
|
return False
|
||||||
|
|
||||||
tx_link = f'[**Your result on Skynet Explorer**](https://explorer.{DEFAULT_DOMAIN}/v2/explore/transaction/{tx_hash})'
|
tx_link = f'[**Your result on Skynet Explorer**](https://explorer.{DEFAULT_DOMAIN}/v2/explore/transaction/{tx_hash})'
|
||||||
|
|
||||||
|
@ -265,3 +265,5 @@ class SkynetDiscordFrontend:
|
||||||
else: # txt2img
|
else: # txt2img
|
||||||
embed.set_image(url=ipfs_link)
|
embed.set_image(url=ipfs_link)
|
||||||
await send(embed=embed, view=SkynetView(self))
|
await send(embed=embed, view=SkynetView(self))
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
|
@ -115,9 +115,9 @@ def create_handler_context(frontend: 'SkynetDiscordFrontend'):
|
||||||
await db_call(
|
await db_call(
|
||||||
'update_user_stats', user.id, 'txt2img', last_prompt=prompt)
|
'update_user_stats', user.id, 'txt2img', last_prompt=prompt)
|
||||||
|
|
||||||
ec = await work_request(user, status_msg, 'txt2img', params, ctx)
|
success = await work_request(user, status_msg, 'txt2img', params, ctx)
|
||||||
|
|
||||||
if ec == None:
|
if success:
|
||||||
await db_call('increment_generated', user.id)
|
await db_call('increment_generated', user.id)
|
||||||
|
|
||||||
@bot.command(name='redo', help='Redo last request')
|
@bot.command(name='redo', help='Redo last request')
|
||||||
|
@ -153,13 +153,13 @@ def create_handler_context(frontend: 'SkynetDiscordFrontend'):
|
||||||
**user_config
|
**user_config
|
||||||
}
|
}
|
||||||
|
|
||||||
ec = await work_request(
|
success = await work_request(
|
||||||
user, status_msg, 'redo', params, ctx,
|
user, status_msg, 'redo', params, ctx,
|
||||||
file_id=file_id,
|
file_id=file_id,
|
||||||
binary_data=binary
|
binary_data=binary
|
||||||
)
|
)
|
||||||
|
|
||||||
if ec == None:
|
if success:
|
||||||
await db_call('increment_generated', user.id)
|
await db_call('increment_generated', user.id)
|
||||||
|
|
||||||
@bot.command(name='img2img', help='Responds with an image')
|
@bot.command(name='img2img', help='Responds with an image')
|
||||||
|
@ -243,13 +243,13 @@ def create_handler_context(frontend: 'SkynetDiscordFrontend'):
|
||||||
last_binary=ipfs_hash
|
last_binary=ipfs_hash
|
||||||
)
|
)
|
||||||
|
|
||||||
ec = await work_request(
|
success = await work_request(
|
||||||
user, status_msg, 'img2img', params, ctx,
|
user, status_msg, 'img2img', params, ctx,
|
||||||
file_id=file_id,
|
file_id=file_id,
|
||||||
binary_data=ipfs_hash
|
binary_data=ipfs_hash
|
||||||
)
|
)
|
||||||
|
|
||||||
if ec == None:
|
if success:
|
||||||
await db_call('increment_generated', user.id)
|
await db_call('increment_generated', user.id)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -63,9 +63,9 @@ class Txt2ImgButton(discord.ui.Button):
|
||||||
await db_call(
|
await db_call(
|
||||||
'update_user_stats', user.id, 'txt2img', last_prompt=prompt)
|
'update_user_stats', user.id, 'txt2img', last_prompt=prompt)
|
||||||
|
|
||||||
ec = await work_request(user, status_msg, 'txt2img', params, msg)
|
success = await work_request(user, status_msg, 'txt2img', params, msg)
|
||||||
|
|
||||||
if ec == None:
|
if success:
|
||||||
await db_call('increment_generated', user.id)
|
await db_call('increment_generated', user.id)
|
||||||
|
|
||||||
|
|
||||||
|
@ -145,13 +145,13 @@ class Img2ImgButton(discord.ui.Button):
|
||||||
last_binary=ipfs_hash
|
last_binary=ipfs_hash
|
||||||
)
|
)
|
||||||
|
|
||||||
ec = await work_request(
|
success = await work_request(
|
||||||
user, status_msg, 'img2img', params, msg,
|
user, status_msg, 'img2img', params, msg,
|
||||||
file_id=file_id,
|
file_id=file_id,
|
||||||
binary_data=ipfs_hash
|
binary_data=ipfs_hash
|
||||||
)
|
)
|
||||||
|
|
||||||
if ec == None:
|
if success:
|
||||||
await db_call('increment_generated', user.id)
|
await db_call('increment_generated', user.id)
|
||||||
|
|
||||||
|
|
||||||
|
@ -195,13 +195,13 @@ class RedoButton(discord.ui.Button):
|
||||||
'prompt': prompt,
|
'prompt': prompt,
|
||||||
**user_config
|
**user_config
|
||||||
}
|
}
|
||||||
ec = await work_request(
|
success = await work_request(
|
||||||
user, status_msg, 'redo', params, interaction,
|
user, status_msg, 'redo', params, interaction,
|
||||||
file_id=file_id,
|
file_id=file_id,
|
||||||
binary_data=binary
|
binary_data=binary
|
||||||
)
|
)
|
||||||
|
|
||||||
if ec == None:
|
if success:
|
||||||
await db_call('increment_generated', user.id)
|
await db_call('increment_generated', user.id)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ class SkynetTelegramFrontend:
|
||||||
params: dict,
|
params: dict,
|
||||||
file_id: str | None = None,
|
file_id: str | None = None,
|
||||||
binary_data: str = ''
|
binary_data: str = ''
|
||||||
):
|
) -> bool:
|
||||||
if params['seed'] == None:
|
if params['seed'] == None:
|
||||||
params['seed'] = random.randint(0, 0xFFFFFFFF)
|
params['seed'] = random.randint(0, 0xFFFFFFFF)
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ class SkynetTelegramFrontend:
|
||||||
await self.update_status_message(
|
await self.update_status_message(
|
||||||
status_msg,
|
status_msg,
|
||||||
'skynet has suffered an internal error trying to fill this request')
|
'skynet has suffered an internal error trying to fill this request')
|
||||||
return
|
return False
|
||||||
|
|
||||||
enqueue_tx_id = res['transaction_id']
|
enqueue_tx_id = res['transaction_id']
|
||||||
enqueue_tx_link = hlink(
|
enqueue_tx_link = hlink(
|
||||||
|
@ -223,7 +223,7 @@ class SkynetTelegramFrontend:
|
||||||
f'\n[{timestamp_pretty()}] <b>timeout processing request</b>',
|
f'\n[{timestamp_pretty()}] <b>timeout processing request</b>',
|
||||||
parse_mode='HTML'
|
parse_mode='HTML'
|
||||||
)
|
)
|
||||||
return
|
return False
|
||||||
|
|
||||||
tx_link = hlink(
|
tx_link = hlink(
|
||||||
'Your result on Skynet Explorer',
|
'Your result on Skynet Explorer',
|
||||||
|
@ -253,7 +253,7 @@ class SkynetTelegramFrontend:
|
||||||
reply_markup=build_redo_menu(),
|
reply_markup=build_redo_menu(),
|
||||||
parse_mode='HTML'
|
parse_mode='HTML'
|
||||||
)
|
)
|
||||||
return
|
return True
|
||||||
|
|
||||||
png_img = resp.raw
|
png_img = resp.raw
|
||||||
with Image.open(io.BytesIO(resp.raw)) as image:
|
with Image.open(io.BytesIO(resp.raw)) as image:
|
||||||
|
@ -290,3 +290,5 @@ class SkynetTelegramFrontend:
|
||||||
reply_markup=build_redo_menu(),
|
reply_markup=build_redo_menu(),
|
||||||
parse_mode='HTML'
|
parse_mode='HTML'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
|
@ -157,9 +157,9 @@ def create_handler_context(frontend: 'SkynetTelegramFrontend'):
|
||||||
await db_call(
|
await db_call(
|
||||||
'update_user_stats', user.id, 'txt2img', last_prompt=prompt)
|
'update_user_stats', user.id, 'txt2img', last_prompt=prompt)
|
||||||
|
|
||||||
ec = await work_request(user, status_msg, 'txt2img', params)
|
success = await work_request(user, status_msg, 'txt2img', params)
|
||||||
|
|
||||||
if ec == 0:
|
if success:
|
||||||
await db_call('increment_generated', user.id)
|
await db_call('increment_generated', user.id)
|
||||||
|
|
||||||
|
|
||||||
|
@ -243,13 +243,13 @@ def create_handler_context(frontend: 'SkynetTelegramFrontend'):
|
||||||
last_binary=ipfs_hash
|
last_binary=ipfs_hash
|
||||||
)
|
)
|
||||||
|
|
||||||
ec = await work_request(
|
success = await work_request(
|
||||||
user, status_msg, 'img2img', params,
|
user, status_msg, 'img2img', params,
|
||||||
file_id=file_id,
|
file_id=file_id,
|
||||||
binary_data=ipfs_hash
|
binary_data=ipfs_hash
|
||||||
)
|
)
|
||||||
|
|
||||||
if ec == 0:
|
if success:
|
||||||
await db_call('increment_generated', user.id)
|
await db_call('increment_generated', user.id)
|
||||||
|
|
||||||
|
|
||||||
|
@ -307,12 +307,15 @@ def create_handler_context(frontend: 'SkynetTelegramFrontend'):
|
||||||
**user_config
|
**user_config
|
||||||
}
|
}
|
||||||
|
|
||||||
await work_request(
|
success = await work_request(
|
||||||
user, status_msg, 'redo', params,
|
user, status_msg, 'redo', params,
|
||||||
file_id=file_id,
|
file_id=file_id,
|
||||||
binary_data=binary
|
binary_data=binary
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if success:
|
||||||
|
await db_call('increment_generated', user.id)
|
||||||
|
|
||||||
|
|
||||||
# "proxy" handlers just request routers
|
# "proxy" handlers just request routers
|
||||||
|
|
||||||
|
|
|
@ -24,10 +24,10 @@ class IPFSHTTP:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def get_ipfs_file(ipfs_link: str):
|
async def get_ipfs_file(ipfs_link: str, timeout: int = 60):
|
||||||
logging.info(f'attempting to get image at {ipfs_link}')
|
logging.info(f'attempting to get image at {ipfs_link}')
|
||||||
resp = None
|
resp = None
|
||||||
for i in range(20):
|
for i in range(timeout):
|
||||||
try:
|
try:
|
||||||
resp = await asks.get(ipfs_link, timeout=3)
|
resp = await asks.get(ipfs_link, timeout=3)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue