alpaca-lora
alpaca-lora copied to clipboard
AttributeError: module 'gradio' has no attribute 'inputs'
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
?
Facing the same problem.
https://github.com/gradio-app/gradio/issues/6384
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
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
pip install gradio==3.50 was ok tks
pip install gradio==3.50 was ok tks
Actionable suggestions, thanks for sharing
I fixed the issues by using Components from gradio
object directly.
I am facing the same issue and gradio==3.50 does not seem to fix it
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!
This does work thanks and good luck
!pip install gradio==3.43.1
AttributeError Traceback (most recent call last)
AttributeError: module 'gradio' has no attribute 'outputs'
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>(...)
#@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)
AttributeError: module 'gradio' has no attribute 'inputs'
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
pip install gradio==3.50
thank you for sharing
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.
I fixed the issues by using Components from
gradio
object directly.
Hey, can you please tell the step for that
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