Spaces:
Runtime error
Runtime error
add ability to toggle tips / prompts
Browse files121 unmodified lines12212312412512612712836 unmodified lines165166167168169170171172173174175176177178179180181182183184185186187188189190191192121 unmodified linesprompts_list = [prompt for prompt in prompts.split(';') if prompt]for i, entry in enumerate(prompts_list):print(i)entry_parts = entry.split('-', 1) # Split by the first dash foundif len(entry_parts) == 2:#raise gr.Error("Invalid prompt format. Please ensure it is in 'initials-prompt' format.")36 unmodified linesimage_paths.append(image_url)image_labels.append(image_label)except Exception as error:print(str(error))raise gr.Error(f"An error occurred while generating the image for: {entry}")return image_paths, image_labels # Return both image paths and labelswith gr.Blocks() as demo:gr.Markdown("# <center>Prompt de Resistance Image Generator</center>")gr.Markdown("**Instructions**: To use this service, please enter the password. Then generate an image from the prompt field below in response to the challenge, then click the download arrow from the top right of the image to save it.")gr.Markdown("**Tips**: Use adjectives (size,color,mood), specify the visual style (realistic,cartoon,8-bit), explain the point of view (from above,first person,wide angle) ")challenge_display = gr.Textbox(label="Challenge", value=get_challenge())challenge_display.disabled = Trueregenerate_btn = gr.Button("New Challenge")pw = gr.Textbox(label="Password", type="password",placeholder="Enter the password to unlock the service")text = gr.Textbox(label="What do you want to create?",placeholder="Enter your text and then click on the \"Image Generate\" button")model = gr.Dropdown(choices=["dall-e-2", "dall-e-3"], label="Model", value="dall-e-3")show_labels = gr.Checkbox(label="Show Image Labels", value=False)btn = gr.Button("Generate Images")output_images = gr.Gallery(label="Image Outputs", show_label=True, columns=[3], rows=[1], object_fit="contain",height="auto", allow_preview=False)#trigger generation either through hitting enter in the text field, or clicking the button.text.submit(fn=generate_images_wrapper, inputs=[text, pw, model, show_labels], outputs=output_images, api_name="generate_image") # Generate an api endpoint in Gradio / HFbtn.click(fn=generate_images_wrapper, inputs=[text, pw, model, show_labels], outputs=output_images, api_name=False)121 unmodified lines12212312412512612736 unmodified lines164165166167168169170171172173174175176177178179180181182183184185186187188189190121 unmodified linesprompts_list = [prompt for prompt in prompts.split(';') if prompt]for i, entry in enumerate(prompts_list):entry_parts = entry.split('-', 1) # Split by the first dash foundif len(entry_parts) == 2:#raise gr.Error("Invalid prompt format. Please ensure it is in 'initials-prompt' format.")36 unmodified linesimage_paths.append(image_url)image_labels.append(image_label)except Exception as e:print(e)raise gr.Error(f"An error occurred while generating the image for: {entry}")return image_paths, image_labels # Return both image paths and labelswith gr.Blocks() as demo:gr.Markdown("# <center>Prompt de Resistance Image Generator</center>")with gr.Accordion("Instructions & Tips",label="Instructions & Tips",open=True):gr.Markdown("**Instructions**: To use this service, please enter the password. Then generate an image from the prompt field below in response to the challenge, then click the download arrow from the top right of the image to save it.")gr.Markdown("**Tips**: Use adjectives (size,color,mood), specify the visual style (realistic,cartoon,8-bit), explain the point of view (from above,first person,wide angle) ")challenge_display = gr.Textbox(label="Challenge", value=get_challenge())challenge_display.disabled = Trueregenerate_btn = gr.Button("New Challenge")pw = gr.Textbox(label="Password", type="password", placeholder="Enter the password to unlock the service")with gr.Accordion("Prompts",label="Prompts",open=True):text = gr.Textbox(label="What do you want to create?", placeholder="Enter your text and then click on the \"Image Generate\" button")model = gr.Dropdown(choices=["dall-e-2", "dall-e-3"], label="Model", value="dall-e-3")show_labels = gr.Checkbox(label="Show Image Labels", value=False)btn = gr.Button("Generate Images")output_images = gr.Gallery(label="Image Outputs", show_label=True, columns=[3], rows=[1], object_fit="contain", height="auto", allow_preview=False)#trigger generation either through hitting enter in the text field, or clicking the button.text.submit(fn=generate_images_wrapper, inputs=[text, pw, model, show_labels], outputs=output_images, api_name="generate_image") # Generate an api endpoint in Gradio / HFbtn.click(fn=generate_images_wrapper, inputs=[text, pw, model, show_labels], outputs=output_images, api_name=False)
app.py+9-11