John6666's picture
Upload 6 files
9b199dd verified
import gradio as gr
from t2i_space import get_t2i_space_contents
css = """
.title { text-align: center; }
"""
with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", fill_width=True, css=css) as demo:
gr.Markdown("# Gradio Demo Space creation helper V2", elem_classes="title")
gr.Markdown(
f"""
**The steps are the following**:
- Input model Repo ID which you want to use. e.g. 'user/model'.
- Click "Submit" and download generated README.md and app.py.
- [Create your new Gradio space](https://huggingface.co/new-space) with blank.
- Upload README.md and app.py to your space.
- If you got 500 / 504 error, it happens often, just restart space.
- If it does not work no matter how many times you try, there is often a problem with the settings of the original repo itself, or there is no generation function.
"""
)
with gr.Column():
repo_id = gr.Textbox(label="Model repo ID", placeholder="username/modelname", value="", max_lines=1)
with gr.Accordion("Advanced", open=False):
with gr.Row():
gradio_version = gr.Textbox(label="Gradio version", placeholder="username/modelname", value="5.0.1", max_lines=1)
private_ok = gr.Checkbox(label="Allow private repo", value=True)
with gr.Row():
hf_user = gr.Textbox(label="Your HF user ID (Optional)", placeholder="username", value="", max_lines=1)
hf_repo = gr.Textbox(label="New space name (Optional)", placeholder="spacename", info="If empty, auto-complete", value="", max_lines=1)
hf_token = gr.Textbox(label="Your HF write token (Optional)", placeholder="hf_...", value="", max_lines=1)
with gr.Row():
is_private = gr.Checkbox(label="Create private repo (Optional)", value=True)
is_setkey = gr.Checkbox(label="Set your token to space (Optional)", info="For private / gated models", value=False)
run_button = gr.Button(value="Submit")
space_file = gr.Files(label="Output", interactive=False)
output_md = gr.Markdown(label="Output")
gr.on(
triggers=[repo_id.submit, run_button.click],
fn=get_t2i_space_contents,
inputs=[repo_id, gradio_version, private_ok, hf_user, hf_repo, is_private, is_setkey, hf_token],
outputs=[space_file, output_md],
)
demo.queue()
demo.launch()