# How to use the model functions within Gradio

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-use-the-model-functions-within-gradio%2F20673%3E%5C
**Category:** 🔒 Gradio\
**Created:** [July 21, 2022, 7:07am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-use-the-model-functions-within-gradio%2F20673 "2022-07-21T07:07:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JayR7](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/jayr7/32/5451_2.png) [@JayR7](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJayR7)%5C
**Post date:** [July 21, 2022, 7:07am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-use-the-model-functions-within-gradio%2F20673%2F1 "2022-07-21T07:07:56Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![abidlabs](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/abidlabs/32/21878_2.png) [@abidlabs](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fabidlabs)%5C
**Post date:** [August 17, 2022, 6:12pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-use-the-model-functions-within-gradio%2F20673%2F2 "2022-08-17T18:12:17Z")

</div>

Hi @JayR7, check out [Gradio Blocks](https://gradio.app/getting_started/#blocks-more-flexibility-and-control), 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
