|
import gradio as gr |
|
import numpy as np |
|
import time |
|
|
|
def sepia(input_img, num_copies): |
|
sepia_filter = np.array([ |
|
[0.393, 0.769, 0.189], |
|
[0.349, 0.686, 0.168], |
|
[0.272, 0.534, 0.131] |
|
]) |
|
|
|
input_img = input_img / 255.0 |
|
sepia_img = np.dot(input_img[...,:3], sepia_filter.T) |
|
sepia_img = np.clip(sepia_img, 0, 1) |
|
|
|
|
|
for _ in range(num_copies): |
|
|
|
time.sleep(1) |
|
yield (sepia_img * 255).astype(np.uint8) |
|
|
|
demo = gr.Interface(fn=sepia, |
|
inputs=[gr.Image(), gr.Number(label="Number of Copies", default=1)], |
|
outputs=gr.Image(type="numpy", label="Sepia Image"), |
|
title="Sepia Tone Generator") |
|
|
|
if __name__ == "__main__": |
|
demo.launch() |
|
|