# AttributeError: 'GPT2LMHeadModel' object has no attribute '\_\_name\_\_'

**URL:** <https://discuss.huggingface.co/t/attributeerror-gpt2lmheadmodel-object-has-no-attribute-name/24100>\
**Category:** 🔒 Gradio\
**Created:** [October 7, 2022, 7:18am UTC](https://discuss.huggingface.co/t/attributeerror-gpt2lmheadmodel-object-has-no-attribute-name/24100 "2022-10-07T07:18:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rexoscare](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/rexoscare/32/28400_2.png) [@rexoscare](https://discuss.huggingface.co/u/rexoscare)\
**Post date:** [October 7, 2022, 7:18am UTC](https://discuss.huggingface.co/t/attributeerror-gpt2lmheadmodel-object-has-no-attribute-name/24100/1 "2022-10-07T07:18:43Z")

</div>

Hello guys,  
I fine-tuned a GPT2 model on some stable diffusion text and I’m trying to create a Gradio space for it but I’m getting this error. The code is mentioned below:-

```auto
import gradio as gr
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("rexoscare/sd-prompt-generator-gpt-2")
model = AutoModelForCausalLM.from_pretrained("rexoscare/sd-prompt-generator-gpt-2")

input_1 = gr.components.Textbox(placeholder= 'Enter your prompt here...', label = 'Auto Generate Prompt', show_label= True)

iface = gr.Interface(model, inputs= input_1, outputs = 'text', theme = 'huggingface')
iface.launch()

```

Can somebody please help me with this?

---

<div class="post-metadata">

**Author:** ![abidlabs](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/abidlabs/32/21878_2.png) [@abidlabs](https://discuss.huggingface.co/u/abidlabs)\
**Post date:** [October 13, 2022, 6:35pm UTC](https://discuss.huggingface.co/t/attributeerror-gpt2lmheadmodel-object-has-no-attribute-name/24100/2 "2022-10-13T18:35:23Z")

</div>

Hi @rexoscare, the `gr.Interface` class is designed to take functions as the argument for the first parameter, not model objects. In other words, you have to wrap a function around the model and pass that into the `gr.Interface` constructor.

Here’s a GPT-2 example that might be helpful: [gpt-2/run-gradio.py at 56208991c8f8df51880336bf2e8f508dee180aaa · gradio-app/gpt-2 · GitHub](https://github.com/gradio-app/gpt-2/blob/56208991c8f8df51880336bf2e8f508dee180aaa/run-gradio.py#L2)

---

<div class="post-metadata">

**Author:** ![rexoscare](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/rexoscare/32/28400_2.png) [@rexoscare](https://discuss.huggingface.co/u/rexoscare)\
**Post date:** [October 14, 2022, 9:55am UTC](https://discuss.huggingface.co/t/attributeerror-gpt2lmheadmodel-object-has-no-attribute-name/24100/3 "2022-10-14T09:55:43Z")

</div>

Oh yes ! Stupid me. Thank you !

---

<div class="post-metadata">

**Author:** ![abidlabs](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/abidlabs/32/21878_2.png) [@abidlabs](https://discuss.huggingface.co/u/abidlabs)\
**Post date:** [October 17, 2022, 5:17am UTC](https://discuss.huggingface.co/t/attributeerror-gpt2lmheadmodel-object-has-no-attribute-name/24100/4 "2022-10-17T05:17:38Z")

</div>

No problem, thanks for asking!
