How to use the model functions within Gradio

Greetings everyone,

I have my model hosted in huggingface hub, and now i’m trying to create a demo for it using Gradio. The demo is supposed to be asking the user for the model mode, based on that it generates the output, so how can we access the model’s functions in aim to have a if-else flow while creating Gradio demo?

example:
def model(mode, output):
model=Model(mode=mode)
if output==‘Generate Image Randomly’:
img= model.generate_randomly()
elif output==‘Generate Art Grid’:
imimga = model.generate_grid()
return img

Thanks!

Hi @JayR7, check out Gradio Blocks, which is a low-level API which should allow you to do what you want. Specifically, you could update the visibility of different components to achieve the desired configuration of components