Spaces:
Runtime error
Runtime error
add pdr options
Browse filesFiles changed (3)
- README.md+1-1
- app.py+17-10
- env-sample+4-1
12345---title: PDR-stable-diffusionemoji: 👁️colorFrom: yellowcolorTo: red12345---title: PDR Stable Diffusionemoji: 👁️colorFrom: yellowcolorTo: red
68 unmodified lines69707172737475767730 unmodified lines10810911011111211311428 unmodified lines143144145146147148149150151152153154155101 unmodified lines25725825926026126217 unmodified lines28028128228328428528628768 unmodified linesupdated_gallery = [(path, label if show_labels else "") for path, label in zip(image_paths_global, image_labels_global)]return updated_gallerydef generate_images_wrapper(prompts, pw, model, show_labels):global image_paths_global, image_labels_globalimage_paths, image_labels = generate_images(prompts, pw, model)image_paths_global = image_paths# store this as a global so we can handle toggle state30 unmodified linesimage_labels_global = [] # Reset the global variablereturn zip_pathdef generate_images(prompts, pw, model):# Check for a valid passwordif pw != os.getenv("PW"):28 unmodified linesresponse = replicate.run("stability-ai/stable-diffusion:ac732df83cea7fff18b8472768c88ad041fa750ff7682a21affe81863cbe77e4",input={"width": 768, #must be multiples of 64"height": 768,"prompt": prompt_w_challenge,"scheduler": "K_EULER", #controlling the steps of the diffusion process to balance between image quality, generation speed, and resource consumption - DDIM, K_EULER, DPMSolverMultistep, K_EULER_ANCESTRAL, PNDM, KLMS"num_outputs": 1, #images to generate"guidance_scale": 7.5, #0-20, higher the number, more it sticks to the prompt"num_inference_steps": 50 #1-500 - higher the better, generally})print(response)101 unmodified linestext = gr.Textbox(label="What do you want to create?", placeholder="Enter your text and then click on the \"Image Generate\" button")with gr.Column(scale=1):model = gr.Dropdown(choices=["stable-diffusion"], label="Model", value="stable-diffusion")with gr.Row():btn = gr.Button("Generate Images")17 unmodified lines#submissions#trigger generation either through hitting enter in the text field, or clicking the button.btn.click(fn=generate_images_wrapper, inputs=[text, pw, model, show_labels], outputs=output_images, api_name=False)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 / HFshow_labels.change(fn=update_labels, inputs=[show_labels], outputs=[output_images])#downloads68 unmodified lines69707172737475767730 unmodified lines10810911011111211311428 unmodified lines143144145146147148149150151152153154155101 unmodified lines25725825926026126226326426526626726826917 unmodified lines28728828929029129229329468 unmodified linesupdated_gallery = [(path, label if show_labels else "") for path, label in zip(image_paths_global, image_labels_global)]return updated_gallerydef generate_images_wrapper(prompts, pw, model, show_labels,size, guidance, steps, scheduler):global image_paths_global, image_labels_globalimage_paths, image_labels = generate_images(prompts, pw, model,size,guidance,steps,scheduler)image_paths_global = image_paths# store this as a global so we can handle toggle state30 unmodified linesimage_labels_global = [] # Reset the global variablereturn zip_pathdef generate_images(prompts, pw, model,size,guidance,steps,scheduler):# Check for a valid passwordif pw != os.getenv("PW"):28 unmodified linesresponse = replicate.run("stability-ai/stable-diffusion:ac732df83cea7fff18b8472768c88ad041fa750ff7682a21affe81863cbe77e4",input={"width": int(size), #must be multiples of 64"height": int(size),"prompt": prompt_w_challenge,"scheduler": scheduler, #controlling the steps of the diffusion process to balance between image quality, generation speed, and resource consumption - DDIM, K_EULER, DPMSolverMultistep, K_EULER_ANCESTRAL, PNDM, KLMS"num_outputs": 1, #images to generate"guidance_scale": int(guidance), #0-20, higher the number, more it sticks to the prompt"num_inference_steps": int(steps) #1-500 - higher the better, generally})print(response)101 unmodified linestext = gr.Textbox(label="What do you want to create?", placeholder="Enter your text and then click on the \"Image Generate\" button")with gr.Column(scale=1):model = gr.Dropdown(choices=["stable-diffusion"], label="Model", value="stable-diffusion")with gr.Row():with gr.Column():size = gr.Dropdown(choices=[512,768,1024], label="Size", value=768)scheduler = gr.Dropdown(choices=["DDIM", "K_EULER", "DPMSolverMultistep", "K_EULER_ANCESTRAL", "PNDM", "KLMS"], label="Scheduler", value="K_EULER", info="attempt to balance between image quality, generation speed, and resource consumption")with gr.Column():guidance = gr.Slider(minimum=0, maximum=20, value=7, step=1,label="Guidance",info="0-20, higher the number, more it sticks to the prompt")steps = gr.Slider(minimum=10, maximum=500, value=50, step=10,label="Steps",info="10-500 - higher = better quality, lower = faster")with gr.Row():btn = gr.Button("Generate Images")17 unmodified lines#submissions#trigger generation either through hitting enter in the text field, or clicking the button.btn.click(fn=generate_images_wrapper, inputs=[text, pw, model, show_labels, size, guidance, steps, scheduler ], outputs=output_images, api_name=False)text.submit(fn=generate_images_wrapper, inputs=[text, pw, model, show_labels, size, guidance, steps, scheduler], outputs=output_images, api_name="generate_image") # Generate an api endpoint in Gradio / HFshow_labels.change(fn=update_labels, inputs=[show_labels], outputs=[output_images])#downloads
12OPENAI_API_KEY = <YOUR_OPENAI_API_KEY>PW = <YOUR_PW>12345OPENAI_API_KEY = <YOUR_OPENAI_API_KEY>PW = <YOUR_PW>REPLICATE_API_TOKEN=<YOUR_REPLICATE_API_KEY>MODE=devMONGO_URI=<YOUR_MONGO_URI>
README.md+1-1
app.py+17-10
env-sample+4-1