Spaces:
Runtime error
Runtime error
| from src import gradio_fn | |
| import gradio as gr | |
| from src import script_gen | |
| with gr.Blocks() as demo: | |
| currComic = gr.State(None) | |
| current_status = gr.State("") | |
| episode_idx = gr.State(-1) | |
| scene_idx = gr.State(0) | |
| regenerate = gr.State(True) | |
| instruction = gr.Markdown(value="Enter the comic meta data.") | |
| with gr.Column(visible=True) as metadata: | |
| with gr.Row(): | |
| comic_id = gr.Textbox(label="Enter Comic ID:", placeholder="Enter Comic ID") | |
| comic_name = gr.Textbox( | |
| label="Enter Comic Title:", placeholder="Enter Comic Title" | |
| ) | |
| comic_location = gr.Textbox( | |
| label="Enter Comic Location:", placeholder="Enter Comic Location" | |
| ) | |
| comic_genre = gr.Dropdown( | |
| choices=gradio_fn.GENRE_CHOICES, label="Current Genre", interactive=True | |
| ) | |
| metadata_btn = gr.Button("Submit Metadata") | |
| with gr.Column(visible=False) as synopsis: | |
| with gr.Row(): | |
| user_input = gr.Textbox(label="Enter Your Idea for the comic:") | |
| preamble = gr.Textbox( | |
| label="Model Instruction:", | |
| value=script_gen.generate_synopsis_instruction, | |
| lines=10, | |
| ) | |
| with gr.Row() as navigation: | |
| previous_btn = gr.Button("Previous", visible=False) | |
| generate_btn = gr.Button("Generate") | |
| regenerate_btn = gr.Button("Re-Generate", visible=False) | |
| next_btn = gr.Button("Next", visible=False) | |
| model_response = gr.HTML(label="Model Output") | |
| submit_btn = gr.Button("Submit", visible=False) | |
| epi = gr.Textbox(label="Current Episode Synopsis", visible=False) | |
| scene = gr.Textbox(label="Current Scene Synopsis", visible=False) | |
| metadata_btn.click( | |
| gradio_fn.load_metadata, | |
| inputs=[comic_id, comic_name, comic_location, comic_genre], | |
| outputs=[currComic, instruction, metadata, synopsis, current_status], | |
| ) | |
| generate_btn.click( | |
| gradio_fn.generate_llm_output, | |
| inputs=[ | |
| user_input, | |
| preamble, | |
| current_status, | |
| currComic, | |
| episode_idx, | |
| scene_idx, | |
| ], | |
| outputs=[ | |
| previous_btn, | |
| next_btn, | |
| generate_btn, | |
| regenerate_btn, | |
| model_response, | |
| submit_btn, | |
| ], | |
| ) | |
| regenerate_btn.click( | |
| gradio_fn.generate_llm_output, | |
| inputs=[ | |
| user_input, | |
| preamble, | |
| current_status, | |
| currComic, | |
| episode_idx, | |
| scene_idx, | |
| regenerate, # regenrate option | |
| ], | |
| outputs=[ | |
| previous_btn, | |
| next_btn, | |
| generate_btn, | |
| regenerate_btn, | |
| model_response, | |
| submit_btn, | |
| ], | |
| ) | |
| submit_btn.click( | |
| gradio_fn.submit_data, | |
| inputs=[current_status, currComic, episode_idx, model_response], | |
| outputs=[ | |
| episode_idx, | |
| current_status, | |
| user_input, | |
| preamble, | |
| previous_btn, | |
| next_btn, | |
| generate_btn, | |
| regenerate_btn, | |
| model_response, | |
| ], | |
| ) | |
| next_btn.click( | |
| gradio_fn.next_button, | |
| inputs=[current_status, currComic, episode_idx], | |
| outputs=[ | |
| previous_btn, | |
| next_btn, | |
| generate_btn, | |
| regenerate_btn, | |
| model_response, | |
| submit_btn, | |
| episode_idx, | |
| ], | |
| ) | |
| previous_btn.click( | |
| gradio_fn.prev_button, | |
| inputs=[current_status, currComic, episode_idx], | |
| outputs=[ | |
| previous_btn, | |
| next_btn, | |
| generate_btn, | |
| regenerate_btn, | |
| model_response, | |
| submit_btn, | |
| episode_idx, | |
| ], | |
| ) | |
| demo.launch(auth=("admin", "Qrt@12*34#immersfy"), share=True, ssr_mode=False, debug=True) | |
| # demo.launch(share=True, ssr_mode=False, debug=True) | |