alpaca-lora icon indicating copy to clipboard operation
alpaca-lora copied to clipboard

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

Open Wenzhi-Ding opened this issue 1 year ago • 18 comments

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?

Wenzhi-Ding avatar Nov 12 '23 07:11 Wenzhi-Ding

Facing the same problem.

rudza avatar Nov 14 '23 17:11 rudza

https://github.com/gradio-app/gradio/issues/6384

Muqi-Zou avatar Nov 14 '23 20:11 Muqi-Zou

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

Nimisha-Pabbichetty avatar Nov 16 '23 19:11 Nimisha-Pabbichetty

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

qiye45 avatar Nov 18 '23 01:11 qiye45

pip install gradio==3.50 was ok tks

RodolpheCalvet avatar Nov 26 '23 02:11 RodolpheCalvet

pip install gradio==3.50 was ok tks

Actionable suggestions, thanks for sharing

wanyukang avatar Nov 26 '23 11:11 wanyukang

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

rudza avatar Dec 03 '23 17:12 rudza

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

gaut9m avatar Jan 25 '24 07:01 gaut9m

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!

claverohub avatar Jan 25 '24 13:01 claverohub

This does work thanks and good luck

!pip install gradio==3.43.1

Wonderwill627 avatar Jan 27 '24 22:01 Wonderwill627

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'

BHEESETTIANAND avatar Feb 04 '24 04:02 BHEESETTIANAND

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>(...)

alexandriabindas avatar Feb 04 '24 21:02 alexandriabindas

#@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'

chiarapero1993 avatar Feb 29 '24 11:02 chiarapero1993

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

Alchemist21 avatar Apr 07 '24 16:04 Alchemist21

pip install gradio==3.50

thank you for sharing

Elham-Keshavarz avatar Apr 23 '24 13:04 Elham-Keshavarz

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.

OfficialLuciano avatar May 05 '24 23:05 OfficialLuciano

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

Hey, can you please tell the step for that

sakjais avatar May 30 '24 17:05 sakjais

The error you people are encountering is due to using deprecated attribute names in Gradio. As of Gradio v3.0 and later, the module attributes inputs and outputs have been replaced with components.

You could use like gr.Textbox for both input and output

mahmoodalikhan1999 avatar Jun 06 '24 11:06 mahmoodalikhan1999