File size: 4,230 Bytes
713d154
 
 
 
 
 
daf38be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f953898
daf38be
304fa0d
d53d001
088886a
43ec7c4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
088886a
 
 
43ec7c4
 
 
088886a
 
 
 
 
 
43ec7c4
 
 
f953898
088886a
729672c
088886a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
729672c
f953898
088886a
 
 
 
 
 
4271efc
088886a
0893164
088886a
b04c454
088886a
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import gradio as gr
import plotly.graph_objects as go
from gradio.themes.base import Base
from gradio.themes.utils import colors, fonts, sizes
from typing import Iterable

class CustomTheme(Base):
    def __init__(
        self,
        *,
        primary_hue: colors.Color | str = colors.green,
        secondary_hue: colors.Color | str = colors.purple,
        neutral_hue: colors.Color | str = colors.gray,
        spacing_size: sizes.Size | str = sizes.spacing_md,
        radius_size: sizes.Size | str = sizes.radius_md,
        text_size: sizes.Size | str = sizes.text_md,
        font: fonts.Font | str | Iterable[fonts.Font | str] = (
            fonts.GoogleFont("Nunito"),
            "ui-sans-serif",
            "sans-serif",
        ),
        font_mono: fonts.Font | str | Iterable[fonts.Font | str] = (
            fonts.GoogleFont("Nunito"),
            "ui-monospace",
            "monospace",
        ),
    ):
        super().__init__(
            primary_hue=primary_hue,
            secondary_hue=secondary_hue,
            neutral_hue=neutral_hue,
            spacing_size=spacing_size,
            radius_size=radius_size,
            text_size=text_size,
            font=font,
            font_mono=font_mono,
        )
        super().set(
            body_background_fill="radial-gradient(#32CD32 2px, transparent 2px), radial-gradient(#8A2BE2 4px, transparent 4px)",
            body_text_color="#282828",
            block_background_fill="#ffffff",
            block_title_text_color="#32CD32",
            block_label_text_color="#32CD32",
            button_primary_background_fill="#32CD32",
            button_primary_text_color="#FFFFFF",
        )

custom_theme = CustomTheme()

def analyze_video(file_path):
    # Dummy sentiment analysis result
    sentiments = {
        "Joy": 12,
        "Trust": 10,
        "Fear": 8,
        "Surprise": 5,
        "Sadness": 7,
        "Disgust": 4,
        "Anger": 6,
        "Anticipation": 9
    }
    
    labels = list(sentiments.keys())
    values = list(sentiments.values())
    
    fig = go.Figure(data=go.Scatterpolar(
      r=values + [values[0]],
      theta=labels + [labels[0]],
      fill='toself'
    ))

    fig.update_layout(
      polar=dict(
        radialaxis=dict(
          visible=True,
          range=[0, max(values) + 2]
        )),
      showlegend=False
    )

    return fig

# Custom CSS for additional styling
css = """
#video_upload {
    background-color: #ffffff;
    color: #282828;
    border: 2px solid #32CD32;
    border-radius: 10px;
    padding: 10px;
    margin: 10px 0;
}
#submit_button {
    background-color: #32CD32;
    color: #FFFFFF;
    border: 2px solid #FFFFFF;
    border-radius: 10px;
    padding: 10px;
    margin: 10px 0;
}
#submit_button:hover {
    background-color: #3BFF3B;
    color: #FFFFFF;
    border: 2px solid #FFFFFF;
}
label[for="video_upload"] {
    color: #32CD32 !important;
}
h1 {
    color: white;
    text-shadow: -1px -1px 0 #32CD32, 1px -1px 0 #32CD32, -1px 1px 0 #32CD32, 1px 1px 0 #32CD32;
    font-size: 3em !important;
    font-weight: bold;
    text-transform: uppercase;
}
h3 {
    color: #32CD32;
}
.centered-markdown {
    text-align: center;
    background-color: #ffffff;
    border: 2px solid #32CD32;
    border-radius: 10px;
    padding: 10px;
}
#zeitgeist-title {
    font-size: 3em !important;
    font-weight: bold;
    text-transform: uppercase;
    background: none !important;
}
"""

with gr.Blocks(theme=custom_theme, css=css) as demo:
    with gr.Column():
        #gr.Markdown("# Zeitgeist AI", elem_classes="centered-markdown", elem_id="zeitgeist-title")
        #gr.Markdown("### Discover the emotional impact of your videos.", elem_classes="centered-markdown")
        #gr.Markdown("**Upload your video file to get started.**", elem_classes="centered-markdown")
        with gr.Row():
            video_upload = gr.File(label="Upload Video File", type="filepath", elem_id="video_upload")
            output = gr.Plot(label="Sentiment Analysis Results", elem_id="output_plot")
        submit_button = gr.Button("Analyze Video", elem_id="submit_button")
        submit_button.click(fn=analyze_video, inputs=video_upload, outputs=output)

demo.launch()