File size: 2,297 Bytes
93b3b80
 
 
 
 
 
 
 
 
 
 
 
 
 
3607d93
93b3b80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3607d93
 
 
 
 
 
 
 
 
 
 
 
93b3b80
 
 
 
 
3607d93
93b3b80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# *************************************************************************** #
#                                                                              #
#    app.py                                                                    #
#                                                                              #
#    By: Widium <ebennace@student.42lausanne.ch>                               #
#    Github : https://github.com/widium                                        #
#                                                                              #
#    Created: 2023/05/05 15:49:55 by Widium                                    #
#    Updated: 2023/05/05 15:49:55 by Widium                                    #
#                                                                              #
# **************************************************************************** #

import sys
import tensorflow as tf
import keras
import gradio as gr

from gradio import Interface

from functions.core import style_generation
from functions.system.devices import get_available_devices

get_available_devices()


print(f"Python : {sys.version}")
print(f"Gradio : {gr.__version__}")
print(f"Tensorflow : {tf.__version__}")
print(f"Keras : {keras.__version__}")

# **************************************************************************** #

def create_demo()->Interface:
    """
    Creates a Gradio demo interface for the Style recreation model.
    
    1. Defines input and output components for the interface.
    2. Specifies example images for the interface.
    3. Creates a Gradio Interface object with the specified components and examples.
    4. Returns the Gradio Interface object.
    
    Returns:
        gradio.Interface: The Gradio demo interface for the Style recreation model.
    """
    
    inputs_box = [
        gr.Image(label="Style Image", type="filepath"),
    ]

    outputs_box = [
        gr.Image(label="Style Recreation", type="pil"),
        gr.Number(label="Time to produce (sc)"),
    ]

    style_images = [
        "examples/waves.png",
    ]

    demo = Interface(
        fn=style_generation, 
        inputs=inputs_box, 
        outputs=outputs_box,
        examples=style_images,
    )
    
    return (demo)

demo = create_demo()
demo.launch()