Skip to content
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

AttributeError: module 'gradio' has no attribute 'inputs' #605

Open
Wenzhi-Ding opened this issue Nov 12, 2023 · 16 comments
Open

AttributeError: module 'gradio' has no attribute 'inputs' #605

Wenzhi-Ding opened this issue Nov 12, 2023 · 16 comments

Comments

@Wenzhi-Ding
Copy link

Hi,

I am running python generate.py and found that in the most recent version of gradio, they have changed their gradio.inputs.Textbox to gradio.Textbox, so I encountered the following errors.

Traceback (most recent call last):
  File "/home/wenzhi/alpaca-lora/generate.py", line 189, in <module>
    fire.Fire(main)
  File "/home/wenzhi/miniconda3/envs/d2l/lib/python3.9/site-packages/fire/core.py", line 141, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/home/wenzhi/miniconda3/envs/d2l/lib/python3.9/site-packages/fire/core.py", line 475, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "/home/wenzhi/miniconda3/envs/d2l/lib/python3.9/site-packages/fire/core.py", line 691, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "/home/wenzhi/alpaca-lora/generate.py", line 137, in main
    gr.inputs.Textbox(
AttributeError: module 'gradio' has no attribute 'inputs'

Although most users should be able to fix it, I think maybe you can either update this script or specify a fixed version of gradio in requirements.txt?

@rudza
Copy link

rudza commented Nov 14, 2023

Facing the same problem.

@Muqi-Zou
Copy link

gradio-app/gradio#6384

@Nimisha-Pabbichetty
Copy link

I had the same issue as well, if you just want to generate outputs for some input prompts and you don't need to gradio interface then you can prompt the model like this: https://github.com/Nimisha-Pabbichetty/alpaca-lora/blob/main/generate.py

@qiye45
Copy link

qiye45 commented Nov 18, 2023

I also faced the same problem. The solution that worked for me is to install an older version of Gradio.
pip install gradio==3.50

@RodolpheCalvet
Copy link

pip install gradio==3.50 was ok tks

@wanyukang
Copy link

pip install gradio==3.50 was ok tks

Actionable suggestions, thanks for sharing

@rudza
Copy link

rudza commented Dec 3, 2023

I fixed the issues by using Components from gradio object directly.

@gaut9m
Copy link

gaut9m commented Jan 25, 2024

I am facing the same issue and gradio==3.50 does not seem to fix it

@claverohub
Copy link

Hi! I'm very new in all of this so I'd appreciate your help.
As mention others, gradio==3.50 does not seem to fix it. After installing it, now I'm running app.py but then it shows the following message: ModuleNotFoundError: No module named 'distutils'
Python website mentions that distutils are now obsolete. So... I don't know what to do. Any idea?
Thanks!

@Wonderwill627
Copy link

This does work thanks and good luck

!pip install gradio==3.43.1

@BHEESETTIANAND
Copy link

AttributeError Traceback (most recent call last)
in <cell line: 3>()
2
3 demo = gr.Interface(
----> 4 fn=classify_audio, inputs=gr.Audio(type="filepath"), outputs=gr.outputs.Label()
5 )
6 demo.launch(debug=True)

AttributeError: module 'gradio' has no attribute 'outputs'

@alexandriabindas
Copy link

alexandriabindas commented Feb 4, 2024

gradio deprecated gradio.inputs and gradio.ouputs. Use gradio.components for newer versions. See example:

import gradio as gr

# Component eg. Image, Label ...etc

outputs=gr.components.<Component>(...) 
inputs=gr.components.<Component>(...)

@chiarapero1993
Copy link

#@title Demo UI
import gradio as gr
import numpy as np

def generate_image(seed, c0, c1, c2, c3, c4, c5, c6):
seed = int(seed)
params = {'c0': c0,
'c1': c1,
'c2': c2,
'c3': c3,
'c4': c4,
'c5': c5,
'c6': c6}

# Assigns slider to the principal components
param_indexes = {'c0': 0,
          'c1': 1,
          'c2': 2,
          'c3': 3,
          'c4': 4,
          'c5': 5,
          'c6': 6}

# Save the values from the sliders
directions = []
distances = []
for k, v in params.items():
    directions.append(latent_dirs[param_indexes[k]])
    distances.append(v)

# Additional settings for image generation
start_layer = 0
end_layer = 14
truncation = 0.5

return display_sample_pytorch(seed, truncation, directions, distances, scale, int(start_layer), int(end_layer), disp=False)

Create a number input for seed

seed = gr.inputs.Number(default=0, label="Seed 1")

slider_max_val = 20
slider_min_val = -20
slider_step = 1

Create the sliders input

c0 = gr.inputs.Slider(label="Sleeve & Size", minimum=slider_min_val, maximum=slider_max_val, default=0)
c1 = gr.inputs.Slider(label="Dress - Jacket", minimum=slider_min_val, maximum=slider_max_val, default=0)
c2 = gr.inputs.Slider(label="Female Coat", minimum=slider_min_val, maximum=slider_max_val, default=0)
c3 = gr.inputs.Slider(label="Coat", minimum=slider_min_val, maximum=slider_max_val, default=0)
c4 = gr.inputs.Slider(label="Graphics", minimum=slider_min_val, maximum=slider_max_val, default=0)
c5 = gr.inputs.Slider(label="Dark", minimum=slider_min_val, maximum=slider_max_val, default=0)
c6 = gr.inputs.Slider(label="Less Cleavage", minimum=slider_min_val, maximum=slider_max_val, default=0)

inputs = [seed, c0, c1, c2, c3, c4, c5, c6]

Launch demo

gr.Interface(generate_image, inputs, ["image"], live=True, title="ClothingGAN").launch(debug=True)

AttributeError Traceback (most recent call last)
in <cell line: 39>()
37
38 # Create a number input for seed
---> 39 seed = gr.inputs.Number(default=0, label="Seed 1")
40
41 slider_max_val = 20

AttributeError: module 'gradio' has no attribute 'inputs'

@Alchemist21
Copy link

This is so helpful. I was able to make it work when I realized gradio deprecated input/output into simply components. Thank you again @alexandrabindas

@Elham-Keshavarz
Copy link

pip install gradio==3.50

thank you for sharing

@OfficialLuciano
Copy link

I also faced the same problem. The solution that worked for me is to install an older version of Gradio. pip install gradio==3.50

Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests