Allow users to set their stable horde api key on the settings page. (#1627)

This commit is contained in:
Alejandro Gil 2022-10-30 04:26:33 -07:00 committed by GitHub
commit fccc12a806
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 4 deletions

View File

@ -23,6 +23,7 @@ general:
streamlit_telemetry: False
default_theme: dark
huggingface_token: ''
stable_horde_api: '0000000000'
gpu: 0
outdir: outputs
default_model: "Stable Diffusion v1.5"

View File

@ -275,6 +275,15 @@ def layout():
and WILL NOT be share with us or anyone. You can get your access token \
at https://huggingface.co/settings/tokens. Default: None")
st.title("Stable Horde")
st.session_state["defaults"].general.stable_horde_api = st.text_input("Stable Horde Api", value=st.session_state["defaults"].general.stable_horde_api, type="password",
help="First Register an account at https://stablehorde.net/register which will generate for you \
an API key. Store that key somewhere safe. \n \
If you do not want to register, you can use `0000000000` as api_key to connect anonymously.\
However anonymous accounts have the lowest priority when there's too many concurrent requests! \
To increase your priority you will need a unique API key and then to increase your Kudos \
read more about them at https://dbzer0.com/blog/the-kudos-based-economy-for-the-koboldai-horde/.")
with txt2img_tab:
col1, col2, col3, col4, col5 = st.columns(5, gap='medium')

View File

@ -106,7 +106,7 @@ def stable_horde(outpath, prompt, seed, sampler_name, save_grid, batch_size,
log.append("Generating image with Stable Horde.")
st.session_state["progress_bar_text"].code('\n'.join(str(log)), language='')
st.session_state["progress_bar_text"].code('\n'.join(log), language='')
# start time after garbage collection (or before?)
start_time = time.time()
@ -157,7 +157,7 @@ def stable_horde(outpath, prompt, seed, sampler_name, save_grid, batch_size,
logger.debug(submit_results)
log.append(submit_results)
st.session_state["progress_bar_text"].code('\n'.join(str(log)), language='')
st.session_state["progress_bar_text"].code(''.join(str(log)), language='')
req_id = submit_results['id']
is_done = False
@ -282,7 +282,7 @@ def txt2img(prompt: str, ddim_steps: int, sampler_name: str, n_iter: int, batch_
RealESRGAN_model: str = "RealESRGAN_x4plus_anime_6B", use_LDSR: bool = True, LDSR_model: str = "model",
fp = None, variant_amount: float = 0.0,
variant_seed: int = None, ddim_eta:float = 0.0, write_info_files:bool = True,
use_stable_horde: bool = False, stable_horde_key:str = ''):
use_stable_horde: bool = False, stable_horde_key:str = "0000000000"):
outpath = st.session_state['defaults'].general.outdir_txt2img
@ -502,7 +502,7 @@ def layout():
with st.expander("Advanced"):
with st.expander("Stable Horde"):
use_stable_horde = st.checkbox("Use Stable Horde", value=False, help="Use the Stable Horde to generate images. More info can be found at https://stablehorde.net/")
stable_horde_key = st.text_input("Stable Horde Api Key", value='', type="password",
stable_horde_key = st.text_input("Stable Horde Api Key", value=st.session_state['defaults'].general.stable_horde_api, type="password",
help="Optional Api Key used for the Stable Horde Bridge, if no api key is added the horde will be used anonymously.")
with st.expander("Output Settings"):