Spaces:
Sleeping
Sleeping
File size: 414 Bytes
98fbcb1 b8786ad 98fbcb1 63e04ad 98fbcb1 63e04ad 98fbcb1 15cd051 e8b56d7 98fbcb1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import gradio as gr
from PIL import Image
binary_file_path = 'data.bin'
def i2b(a):
image = Image.fromarray(a, 'RGB')
binary_data = image.tobytes()
with open(binary_file_path, 'wb') as f:
f.write(binary_data)
return "", "data.bin"
with gr.Blocks() as demo:
with gr.Row():
img = gr.Image(type="pil")
out = gr.File()
img.upload(i2b, img, [img, out])
demo.launch() |