mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-21 02:19:59 +08:00
converted timestamps to number of seconds since epoch
This commit is contained in:
parent
422a8f7704
commit
c86edebe3f
@ -8,7 +8,7 @@ from abc import ABC, abstractmethod
|
|||||||
from gradio import preprocessing_utils, validation_data
|
from gradio import preprocessing_utils, validation_data
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from PIL import Image, ImageOps
|
from PIL import Image, ImageOps
|
||||||
import datetime
|
import time
|
||||||
import warnings
|
import warnings
|
||||||
import json
|
import json
|
||||||
|
|
||||||
@ -114,8 +114,8 @@ class Sketchpad(AbstractInput):
|
|||||||
"""
|
"""
|
||||||
inp = msg['data']['input']
|
inp = msg['data']['input']
|
||||||
im = preprocessing_utils.encoding_to_image(inp)
|
im = preprocessing_utils.encoding_to_image(inp)
|
||||||
timestamp = datetime.datetime.now()
|
timestamp = time.time()*1000
|
||||||
filename = f'input_{timestamp.strftime("%Y-%m-%d-%H-%M-%S")}.png'
|
filename = f'input_{timestamp}.png'
|
||||||
im.save(f'{dir}/{filename}', 'PNG')
|
im.save(f'{dir}/{filename}', 'PNG')
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
@ -149,8 +149,8 @@ class Webcam(AbstractInput):
|
|||||||
"""
|
"""
|
||||||
inp = msg['data']['input']
|
inp = msg['data']['input']
|
||||||
im = preprocessing_utils.encoding_to_image(inp)
|
im = preprocessing_utils.encoding_to_image(inp)
|
||||||
timestamp = datetime.datetime.now()
|
timestamp = time.time()*1000
|
||||||
filename = f'input_{timestamp.strftime("%Y-%m-%d-%H-%M-%S")}.png'
|
filename = f'input_{timestamp}.png'
|
||||||
im.save(f'{dir}/{filename}', 'PNG')
|
im.save(f'{dir}/{filename}', 'PNG')
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
@ -173,8 +173,8 @@ class Textbox(AbstractInput):
|
|||||||
Default rebuild method for text saves it .txt file
|
Default rebuild method for text saves it .txt file
|
||||||
"""
|
"""
|
||||||
inp = msg['data']['input']
|
inp = msg['data']['input']
|
||||||
timestamp = datetime.datetime.now()
|
timestamp = time.time()*1000
|
||||||
filename = f'input_{timestamp.strftime("%Y-%m-%d-%H-%M-%S")}.txt'
|
filename = f'input_{timestamp}.png'
|
||||||
with open(f'{dir}/{filename}.txt','w') as f:
|
with open(f'{dir}/{filename}.txt','w') as f:
|
||||||
f.write(inp)
|
f.write(inp)
|
||||||
return filename
|
return filename
|
||||||
@ -225,8 +225,8 @@ class ImageUpload(AbstractInput):
|
|||||||
"""
|
"""
|
||||||
inp = msg['data']['input']
|
inp = msg['data']['input']
|
||||||
im = preprocessing_utils.encoding_to_image(inp)
|
im = preprocessing_utils.encoding_to_image(inp)
|
||||||
timestamp = datetime.datetime.now()
|
timestamp = time.time()*1000
|
||||||
filename = f'input_{timestamp.strftime("%Y-%m-%d-%H-%M-%S")}.png'
|
filename = f'input_{timestamp}.png'
|
||||||
im.save(f'{dir}/{filename}', 'PNG')
|
im.save(f'{dir}/{filename}', 'PNG')
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
@ -234,8 +234,8 @@ class ImageUpload(AbstractInput):
|
|||||||
def save_to_file(self, dir, img):
|
def save_to_file(self, dir, img):
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
timestamp = datetime.datetime.now()
|
timestamp = time.time()*1000
|
||||||
filename = f'input_{timestamp.strftime("%Y-%m-%d-%H-%M-%S")}.png'
|
filename = f'input_{timestamp}.png'
|
||||||
img.save(f'{dir}/{filename}', 'PNG')
|
img.save(f'{dir}/{filename}', 'PNG')
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user