collage2images / app.py
Weaita's picture
Update app.py
fef6a07
raw
history blame
670 Bytes
import gradio as gr
import numpy as np
import zipfile
from PIL import Image
import tempfile
def flip_image(image):
image = Image.fromarray(np.uint8(image))
# Create a temporary file
with tempfile.NamedTemporaryFile(suffix='.jpg') as temp:
# Save the image to the temporary file
image.save(temp.name)
# Create zip file
with zipfile.ZipFile("image.zip", 'w') as zip:
zip.write(temp.name)
return "image.zip"
gr.Interface(fn=flip_image,
inputs="image",
outputs="file",
title="Flip An Image Upside Down",
examples = ["example.jpg"]
).launch();