mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-06 10:25:17 +08:00
fixed permission issue in windows
This commit is contained in:
parent
9847fb087b
commit
5bf6486198
@ -645,7 +645,7 @@ class Image(InputComponent):
|
||||
elif self.type == "numpy":
|
||||
return np.array(im)
|
||||
elif self.type == "file":
|
||||
file_obj = tempfile.NamedTemporaryFile(suffix=("."+fmt.lower() if fmt is not None else ".png"))
|
||||
file_obj = tempfile.NamedTemporaryFile(delete=False, suffix=("."+fmt.lower() if fmt is not None else ".png"))
|
||||
im.save(file_obj.name)
|
||||
return file_obj
|
||||
else:
|
||||
@ -789,7 +789,7 @@ class Audio(InputComponent):
|
||||
leave_one_out_data = np.copy(data)
|
||||
start, stop = boundaries[index], boundaries[index + 1]
|
||||
leave_one_out_data[start:stop] = 0
|
||||
file = tempfile.NamedTemporaryFile()
|
||||
file = tempfile.NamedTemporaryFile(delete=False)
|
||||
scipy.io.wavfile.write(file, sample_rate, leave_one_out_data)
|
||||
out_data = processing_utils.encode_file_to_base64(file.name, type="audio", ext="wav")
|
||||
leave_one_out_sets.append(out_data)
|
||||
|
@ -286,7 +286,7 @@ class Audio(OutputComponent):
|
||||
def postprocess(self, y):
|
||||
if self.type in ["numpy", "file", "auto"]:
|
||||
if self.type == "numpy" or (self.type == "auto" and isinstance(y, tuple)):
|
||||
file = tempfile.NamedTemporaryFile()
|
||||
file = tempfile.NamedTemporaryFile(delete=False)
|
||||
scipy.io.wavfile.write(file, y[0], y[1])
|
||||
y = file.name
|
||||
return processing_utils.encode_file_to_base64(y, type="audio", ext="wav")
|
||||
|
@ -73,7 +73,7 @@ def decode_base64_to_binary(encoding):
|
||||
|
||||
|
||||
def decode_base64_to_file(encoding):
|
||||
file_obj = tempfile.NamedTemporaryFile()
|
||||
file_obj = tempfile.NamedTemporaryFile(delete=False)
|
||||
file_obj.write(decode_base64_to_binary(encoding))
|
||||
file_obj.flush()
|
||||
return file_obj
|
||||
|
Loading…
Reference in New Issue
Block a user