import gradio as gr import model from config import app_config import mongo_utils as mongo def clear(): return None, 50, 0.7, None, None def create_interface(): js_enable_darkmode = """() => { document.querySelector('body').classList.add('dark'); }""" js_toggle_darkmode = """() => { if (document.querySelectorAll('.dark').length) { document.querySelector('body').classList.remove('dark'); } else { document.querySelector('body').classList.add('dark'); } }""" with gr.Blocks( title=app_config.title, theme=app_config.theme, css=app_config.css ) as app: # enable darkmode app.load(fn=None, inputs=None, outputs=None, _js=js_enable_darkmode) with gr.Row(): darkmode_checkbox = gr.Checkbox( label="Dark Mode", value=True, interactive=True ) # toggle darkmode on/off when checkbox is checked/unchecked darkmode_checkbox.change( None, None, None, _js=js_toggle_darkmode, api_name=False ) with gr.Row(): with gr.Column(): gr.Markdown( """ # The Storyteller **This app can craft captivating narratives from captivating images, potentially surpassing even Shakespearean standards.
Select an `Image` that inspires a story, choose a `Story Genre`, `Story Writing Style`, `Story Length (up to 200 words)`, and adjust the `Creativity Index` to enhance its creative flair. Then hit `Generate Story` button. Alternatively, just select one the pre-configured `Examples`**
Visit the [project's repo](https://github.com/sssingh/pic-to-story)