File size: 834 Bytes
e24647c
01c5d03
2749c38
e24647c
2749c38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
01c5d03
71cc033
 
00df17e
71cc033
e24647c
2749c38
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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()],
                    outputs="image",
                    title="Sepia Tone Generator")

if __name__ == "__main__":
    demo.launch()