Update app.py
Browse files
app.py
CHANGED
@@ -17,29 +17,20 @@ def sepia(input_img, num_copies):
|
|
17 |
sepia_imgs = [(sepia_img).astype(np.uint8) for _ in range(num_copies)]
|
18 |
return sepia_imgs
|
19 |
|
20 |
-
def zip_sepia_images(sepia_imgs):
|
21 |
-
temp_dir = tempfile.mkdtemp()
|
22 |
-
zip_path = os.path.join(temp_dir, "sepia_images.zip")
|
23 |
-
with ZipFile(zip_path, 'w') as zipf:
|
24 |
-
for i, img in enumerate(sepia_imgs):
|
25 |
-
img_path = os.path.join(temp_dir, f"sepia_image_{i}.png")
|
26 |
-
# gr.utils.save_image(img_path, img)
|
27 |
-
zipf.write(img_path, os.path.basename(img_path))
|
28 |
-
return zip_path
|
29 |
|
30 |
with gr.Blocks() as demo:
|
31 |
with gr.Row():
|
32 |
input_img = gr.Image()
|
33 |
num_copies = gr.Number(label="Number of Copies", value=1)
|
34 |
gallery = gr.Gallery(label="Sepia Images")
|
35 |
-
|
36 |
|
37 |
input_img.change(fn=lambda x: x, inputs=input_img, outputs=gallery)
|
38 |
num_copies.change(fn=lambda x: x, inputs=num_copies, outputs=gallery)
|
39 |
|
40 |
generate_btn = gr.Button("Generate Sepia Images")
|
41 |
generate_btn.click(fn=sepia, inputs=[input_img, num_copies], outputs=gallery)
|
42 |
-
|
43 |
|
44 |
if __name__ == "__main__":
|
45 |
demo.launch()
|
|
|
17 |
sepia_imgs = [(sepia_img).astype(np.uint8) for _ in range(num_copies)]
|
18 |
return sepia_imgs
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
with gr.Blocks() as demo:
|
22 |
with gr.Row():
|
23 |
input_img = gr.Image()
|
24 |
num_copies = gr.Number(label="Number of Copies", value=1)
|
25 |
gallery = gr.Gallery(label="Sepia Images")
|
26 |
+
|
27 |
|
28 |
input_img.change(fn=lambda x: x, inputs=input_img, outputs=gallery)
|
29 |
num_copies.change(fn=lambda x: x, inputs=num_copies, outputs=gallery)
|
30 |
|
31 |
generate_btn = gr.Button("Generate Sepia Images")
|
32 |
generate_btn.click(fn=sepia, inputs=[input_img, num_copies], outputs=gallery)
|
33 |
+
|
34 |
|
35 |
if __name__ == "__main__":
|
36 |
demo.launch()
|