-
Notifications
You must be signed in to change notification settings - Fork 26.7k
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
Fix gradio tool demos #31230
Fix gradio tool demos #31230
Conversation
0492b4e
to
24a3889
Compare
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
c2ecd5b
to
663071c
Compare
@@ -88,7 +88,8 @@ class AgentImage(AgentType, ImageType): | |||
""" | |||
|
|||
def __init__(self, value): | |||
super().__init__(value) | |||
AgentType.__init__(self, value) | |||
ImageType.__init__(self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found that without this, the ImageType
attributes would not be inherited.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm I'm curious why that is the case, I'll investigate
@@ -125,6 +128,10 @@ def to_raw(self): | |||
self._raw = Image.open(self._path) | |||
return self._raw | |||
|
|||
if self._tensor is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This case was missing in the original function
@@ -125,6 +128,10 @@ def to_raw(self): | |||
self._raw = Image.open(self._path) | |||
return self._raw | |||
|
|||
if self._tensor is not None: | |||
array = self._tensor.cpu().detach().numpy() | |||
return Image.fromarray((255 - array * 255).astype(np.uint8)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I invert the image colors with this (255 - array*255)
, else the image appears in negative.
|
||
class AgentAudio(AgentType): | ||
class AgentAudio(AgentType, str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I add the str type so that gradio
postprocessor can recognize the AgentAudio
as a path to an audio.
306a52d
to
5163ab6
Compare
b9c774e
to
af90dab
Compare
af90dab
to
c886bf9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok it looks good! I'm just curious about the need to instantiate the two types, it shouldn't be the case (I'll investigate and we can merge afterwards)
@@ -88,7 +88,8 @@ class AgentImage(AgentType, ImageType): | |||
""" | |||
|
|||
def __init__(self, value): | |||
super().__init__(value) | |||
AgentType.__init__(self, value) | |||
ImageType.__init__(self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm I'm curious why that is the case, I'll investigate
* Fix gradio tool demos
What does this PR do?
Resolves Gradio demos on Spaces for tools not working properly.