-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using loaded interface as a function in Blocks return error #2369
Comments
Thanks for filing @fffiloni ! My guess is that fn_index=0 probably corresponds to the examples component and not the actual text to image generation. I would check with fn_index=2. |
Hello @freddyaboulton ! I tried with
|
Thanks for the info @fffiloni ! Will look into this |
Hi @fffiloni ! I think I understand what's happening - the stable diffusion space is returning a path to a gallery. The images in the gallery are stored as files in that path. If you modify your function to return a list of the image files instead it works import gradio as gr
import os
stable_diffusion = gr.Blocks.load(name="spaces/stabilityai/stable-diffusion")
def get_images(prompt):
gallery_dir = stable_diffusion(prompt, fn_index=2)
return [os.path.join(gallery_dir, img) for img in os.listdir(gallery_dir)]
with gr.Blocks() as demo:
with gr.Column():
with gr.Row():
prompt = gr.Text()
gallery = gr.Gallery()
submit_btn = gr.Button()
submit_btn.click(get_images, inputs=[prompt], outputs=[gallery])
demo.launch() |
Ouh nice @freddyaboulton ! Yes it works ! |
Describe the bug
I want to use Stable Diffusion as a loaded interface in a Block, and use it as a function run by a button.
Calling that function leads to a
AttributeError: 'Dataset' object has no attribute 'serialize'
error in logsIs there an existing issue for this?
Reproduction
Screenshot
No response
Logs
Severity
annoying
The text was updated successfully, but these errors were encountered: