added rebuild flagged to inputs/outputs

This commit is contained in:
aliabd 2020-07-27 15:53:53 -07:00
parent b9a3b62fc1
commit 593af4ebf6
2 changed files with 22 additions and 2 deletions

View File

@ -67,7 +67,7 @@ class AbstractInput(ABC):
"""
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
class Textbox(AbstractInput):
"""
@ -356,6 +356,16 @@ class Sketchpad(AbstractInput):
def process_example(self, example):
return preprocessing_utils.convert_file_to_base64(example)
def rebuild_flagged(self, dir, msg):
"""
Default rebuild method to decode a base64 image
"""
im = preprocessing_utils.decode_base64_to_image(msg)
timestamp = datetime.datetime.now()
filename = f'input_{timestamp.strftime("%Y-%m-%d-%H-%M-%S")}.png'
im.save(f'{dir}/{filename}', 'PNG')
return filename
class Webcam(AbstractInput):
"""
@ -393,6 +403,16 @@ class Webcam(AbstractInput):
im, (self.image_width, self.image_height))
return np.array(im)
def rebuild_flagged(self, dir, msg):
"""
Default rebuild method to decode a base64 image
"""
im = preprocessing_utils.decode_base64_to_image(msg)
timestamp = datetime.datetime.now()
filename = f'input_{timestamp.strftime("%Y-%m-%d-%H-%M-%S")}.png'
im.save(f'{dir}/{filename}', 'PNG')
return filename
class Microphone(AbstractInput):
"""

View File

@ -48,7 +48,7 @@ class AbstractOutput(ABC):
"""
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
class Textbox(AbstractOutput):