RAGBOT / app.py
Rahatara's picture
Update app.py
2749c38 verified
raw
history blame
905 Bytes
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]
])
# Normalize input image to 0-1 range
input_img = input_img / 255.0
sepia_img = np.dot(input_img[...,:3], sepia_filter.T)
sepia_img = np.clip(sepia_img, 0, 1)
# Iterate to yield multiple sepia images
for _ in range(num_copies):
# Simulating a delay for demonstration, you might not need this
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()