-
Notifications
You must be signed in to change notification settings - Fork 2.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
Flagging #37
Flagging #37
Conversation
gradio/inputs.py
Outdated
@@ -63,6 +63,11 @@ def get_shortcut_implementations(cls): | |||
""" | |||
return {} | |||
|
|||
def rebuild_flagged(self, dir, msg): |
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.
We probably want to use this method for more than just flagging. Any time we have an image / sample in the front end, and we want to convert it back to a Python object, we should use this method. So I actually think a better name for this might just be rebuild
or pythonify
or deprocess
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.
changed name to rebuild
gradio/networking.py
Outdated
@@ -36,7 +36,7 @@ | |||
ASSOCIATION_PATH_IN_STATIC = "static/apple-app-site-association" | |||
ASSOCIATION_PATH_IN_ROOT = "apple-app-site-association" | |||
|
|||
FLAGGING_DIRECTORY = 'static/flagged/' | |||
FLAGGING_DIRECTORY = 'flagged/' |
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 can be the default, but I would allow this to be overridden with a parameter in the Interface class.
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.
Added flagging_dir
parameter to Interface
, set to "flagged" by default
gradio/inputs.py
Outdated
@@ -290,6 +295,16 @@ def process_example(self, example): | |||
else: | |||
return example | |||
|
|||
def rebuild_flagged(self, dir, msg): |
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.
msg
is not used?
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.
msg
here is what I named the input data I get from the api. Changed the name to data
. This isn't the old message feature
@@ -56,12 +56,12 @@ var io_master_template = { | |||
this.target.find(".output_interfaces").css("opacity", 1); | |||
} | |||
}, | |||
flag: function(message) { | |||
flag: function() { |
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.
Can we just remove message
if we're not using it?
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.
There's no message anymore, this change was to remove it. See above for msg/message confusion.
@@ -121,6 +123,18 @@ def get_output_instance(iface): | |||
except (ImportError, AttributeError): # If they are using TF >= 2.0 or don't have TF, just ignore this. | |||
pass | |||
|
|||
if self.allow_flagging: |
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 think it's more elegant to come up with the directory name in 1 step rather than 2. So something like:
base_dir_name = "-".join(self.title.split(" "))
index = 0
while os.path.exists(os.path.join(FLAGGING_DIRECTORY, base_dir_name , index)):
index += 1
dir_name = os.path.join(FLAGGING_DIRECTORY, base_dir_name , index)
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.
To be clear join
will add a /
separator so it would be "FLAGGING_DIRECTORY/base_dir_name/index"
. I thought it would be too nested so I wrote similar code that produces "FLAGGING_DIRECTORY/base_dir_name_index"
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.
Or do you think nested is better?
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.
Ah good point, no I think what you wrote is better
gradio/networking.py
Outdated
@@ -36,8 +35,7 @@ | |||
ASSOCIATION_PATH_IN_STATIC = "static/apple-app-site-association" | |||
ASSOCIATION_PATH_IN_ROOT = "apple-app-site-association" | |||
|
|||
FLAGGING_DIRECTORY = 'flagged/' | |||
FLAGGING_FILENAME = 'data.txt' | |||
FLAGGING_FILENAME = 'flagged.txt' |
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.
Again, this is fine for the default (although I would have probably used something like log.txt
), but consider allowing user to override
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.
Changed it to log.txt
, but haven't added it as a parameter. We're starting to have too many parameters in Interface
right now. Do you think that's an annoyance?
gradio/inputs.py
Outdated
""" | ||
All interfaces should define a method that rebuilds the flagged input when it's passed back (i.e. rebuilds image from base64) | ||
""" | ||
pass |
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.
Maybe it makes sense to define a default method? Or are you planning on implementing this method for every AbstractInput and AbstractOutput?
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.
There is a default method, you are commenting on an outdated commit. By default the data
is returned with no processing. (Like with Text)
gradio/inputs.py
Outdated
@@ -67,7 +67,7 @@ def rebuild_flagged(self, dir, msg): | |||
""" | |||
All interfaces should define a method that rebuilds the flagged input when it's passed back (i.e. rebuilds image from base64) | |||
""" | |||
pass | |||
return msg |
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 thought msg
is always blank?
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.
See above for msg
/message
confusion. changed msg
to data
.
gradio/outputs.py
Outdated
@@ -48,7 +48,7 @@ def rebuild_flagged(self, dir, msg): | |||
""" | |||
All interfaces should define a method that rebuilds the flagged input when it's passed back (i.e. rebuilds image from base64) | |||
""" | |||
pass | |||
return msg |
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.
Same comment as above
No description provided.