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: 'Image' object has no attribute 'value' #8300

Closed
1 task done
liuchangzong opened this issue May 16, 2024 · 2 comments
Closed
1 task done

AttributeError: 'Image' object has no attribute 'value' #8300

liuchangzong opened this issue May 16, 2024 · 2 comments
Labels
bug Something isn't working pending clarification

Comments

@liuchangzong
Copy link

liuchangzong commented May 16, 2024

Describe the bug

I want to change the gradio.Image.value dynamically. But it seems like there is a little way to change the value.
I want to call a function in other files to actively change the gradio.Image.value in the main function.
You can find out that I rewrite the new function in class to make sure that targetImage's memory address will not change.
I pass a parameter which is image path and then the targetImage's value will change. In the main.py, everythin is fine. But in another file, I got an error which said that 'Image' object has no attribute 'value'.
I guess the reasaon is that gradio can't make a gradio.Image component in another file.
I need help, please.
Can gradio achieve the goal about dynamically changing image value?
Sorry for my poor English.

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

#main.py
import gradio as gr
from block2 import gradioImage
frame_show =  gr.Image(value="path1", label="frameshowing", width= 200)
gradioImageClass=gradioImage(frame_show)
gradioImageClass.show_image('path2")
#block2.py
class gradioImage():
    __instance=None
    def __new__(cls, Image):
        if not cls.__instance:
            cls.__instance = super().__new__(cls)
            cls.__instance.targetImage = Image
        return cls.__instance
    @classmethod
    def show_image(cls, imagePath):
        middle_gradioImage = gr.Image(value=imagePath, visible=False)
        cls.__instance.targetImage.value = middle_gradioImage.value
#other file.py
from block2 import gradioImage
gradioImage.show_image("path3")

Screenshot

No response

Logs

Traceback (most recent call last):
    gradioImage.show_image("E:/AIResource/Image/digimon/86557814_p0_master1200.jpg")
   in show_image
    cls.__instance.targetImage.value = middle_gradioImage.value
AttributeError: 'Image' object has no attribute 'value'

System Info

win11
gradio 4.28.3

Severity

@liuchangzong liuchangzong added the bug Something isn't working label May 16, 2024
@liuchangzong liuchangzong reopened this May 16, 2024
@abidlabs
Copy link
Member

Hi @liuchangzong I'm really sorry but this issue is not very clear to me. I'm not sure what you're trying to do, or what the behavior you're seeing is. The code you've provided is also incomplete and not properly formatted, which makes it hard for me to follow the issue. Could you please edit the issue for clarity?

@abidlabs
Copy link
Member

going to close this. we can reopen with a clearer issue

@abidlabs abidlabs closed this as not planned Won't fix, can't repro, duplicate, stale May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending clarification
Projects
None yet
Development

No branches or pull requests

2 participants