mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-12 10:34:32 +08:00
improve image output format
This commit is contained in:
parent
6942d2e44d
commit
6fa11437c0
@ -4,6 +4,8 @@ class Component():
|
||||
"""
|
||||
|
||||
def __init__(self, label):
|
||||
if label is None:
|
||||
label = self.__class__.__name__
|
||||
self.label = label
|
||||
|
||||
def get_template_context(self):
|
||||
|
@ -175,8 +175,7 @@ class Image(OutputComponent):
|
||||
"""
|
||||
im = processing_utils.decode_base64_to_image(data)
|
||||
timestamp = datetime.datetime.now()
|
||||
filename = 'output_{}.png'.format(timestamp.
|
||||
strftime("%Y-%m-%d-%H-%M-%S"))
|
||||
filename = 'output_{}_{}.png'.format(self.label, timestamp.strftime("%Y-%m-%d-%H-%M-%S"))
|
||||
im.save('{}/{}'.format(dir, filename), 'PNG')
|
||||
return filename
|
||||
|
||||
|
@ -4,6 +4,8 @@ class Component():
|
||||
"""
|
||||
|
||||
def __init__(self, label):
|
||||
if label is None:
|
||||
label = self.__class__.__name__
|
||||
self.label = label
|
||||
|
||||
def get_template_context(self):
|
||||
|
@ -175,8 +175,7 @@ class Image(OutputComponent):
|
||||
"""
|
||||
im = processing_utils.decode_base64_to_image(data)
|
||||
timestamp = datetime.datetime.now()
|
||||
filename = 'output_{}.png'.format(timestamp.
|
||||
strftime("%Y-%m-%d-%H-%M-%S"))
|
||||
filename = 'output_{}_{}.png'.format(self.label, timestamp.strftime("%Y-%m-%d-%H-%M-%S"))
|
||||
im.save('{}/{}'.format(dir, filename), 'PNG')
|
||||
return filename
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user