skenoo commited on
Commit
9feb1f1
·
verified ·
1 Parent(s): d318c7c

Upload 4 files

Browse files
Files changed (4) hide show
  1. README.md +39 -10
  2. app.py +362 -0
  3. requirements.txt +5 -0
  4. rosetta_animation.py +149 -0
README.md CHANGED
@@ -1,10 +1,39 @@
1
- ---
2
- title: README
3
- emoji: 👁
4
- colorFrom: blue
5
- colorTo: blue
6
- sdk: gradio
7
- pinned: false
8
- ---
9
-
10
- Edit this `README.md` markdown file to author your organization card.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SKENAI-RENO Event Processing Demo
2
+
3
+ This interactive demo showcases SKENAI-RENO's AI-powered event processing capabilities for gaming and enterprise applications.
4
+
5
+ ## What This Demo Shows
6
+
7
+ - How different types of events are processed and enriched with AI insights
8
+ - The serverless architecture in action (simulated)
9
+ - Integration of Hugging Face models for real-time analysis
10
+ - Key performance metrics and analytics
11
+
12
+ ## How to Use
13
+
14
+ 1. Select an event type from the dropdown
15
+ 2. Enter event content in the text box
16
+ 3. Submit to see how the SKENAI-RENO pipeline would process and enrich your event
17
+ 4. Explore the analytics tab to view performance metrics
18
+
19
+ ## Running Locally
20
+
21
+ To run this demo locally:
22
+
23
+ ```bash
24
+ pip install -r requirements.txt
25
+ python app.py
26
+ ```
27
+
28
+ ## Deploying to Hugging Face Spaces
29
+
30
+ 1. Create a new Space at [huggingface.co/new-space](https://huggingface.co/new-space)
31
+ 2. Select Gradio as the SDK
32
+ 3. Upload these files to your Space
33
+ 4. (Optional) Add your HF_API_KEY as a secret if you want to use actual model inference
34
+
35
+ ## About SKENAI-RENO
36
+
37
+ SKENAI-RENO is a fully serverless event processing pipeline designed for high-reliability, AI-enhanced insights, and seamless integration with existing systems.
38
+
39
+ Learn more about our enterprise solutions at [skenai-reno.com](https://skenai-reno.com)
app.py ADDED
@@ -0,0 +1,362 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ """
3
+ SKENAI-RENO Event Processing Demo
4
+ ---------------------------------
5
+ This Gradio app demonstrates how the SKENAI-RENO event processing pipeline
6
+ enriches events with AI insights using Hugging Face models.
7
+ """
8
+
9
+ import gradio as gr
10
+ import requests
11
+ import json
12
+ import os
13
+ import time
14
+ import numpy as np
15
+ import pandas as pd
16
+ import plotly.express as px
17
+ from datetime import datetime, timedelta
18
+
19
+ # Configure API access (in production, use Secrets)
20
+ API_KEY = os.environ.get("HF_API_KEY", "")
21
+ HF_ENDPOINT = "https://api-inference.huggingface.co/models/"
22
+
23
+ # Sample models to use for different event types
24
+ MODEL_MAPPING = {
25
+ "user_feedback": "distilbert-base-uncased-finetuned-sst-2-english",
26
+ "transaction": "bert-base-uncased",
27
+ "system_event": "gpt2",
28
+ "achievement": "roberta-base"
29
+ }
30
+
31
+ def process_event(event_type, event_content, user_id="user123", game_id="game456"):
32
+ """Process an event through the SKENAI-RENO pipeline with Hugging Face model."""
33
+
34
+ # Select model based on event type
35
+ model_id = MODEL_MAPPING.get(event_type, "distilbert-base-uncased-finetuned-sst-2-english")
36
+
37
+ # Prepare payload for Hugging Face model
38
+ payload = {
39
+ "inputs": event_content,
40
+ }
41
+
42
+ # For demo purposes, simulate API call if no key is provided
43
+ if not API_KEY:
44
+ # Simulate processing delay
45
+ time.sleep(1)
46
+
47
+ # Generate simulated AI insights based on event type
48
+ if event_type == "user_feedback":
49
+ ai_insights = [
50
+ {"label": "POSITIVE", "score": 0.92},
51
+ {"label": "NEGATIVE", "score": 0.08}
52
+ ]
53
+ elif event_type == "transaction":
54
+ ai_insights = {
55
+ "transaction_type": "purchase",
56
+ "value_assessment": "high",
57
+ "confidence": 0.87
58
+ }
59
+ elif event_type == "achievement":
60
+ ai_insights = {
61
+ "achievement_level": "significant",
62
+ "percentile": 85,
63
+ "engagement_impact": "positive"
64
+ }
65
+ else:
66
+ ai_insights = {
67
+ "classification": "routine",
68
+ "priority": "low",
69
+ "action_required": False
70
+ }
71
+ else:
72
+ # Call Hugging Face Inference API with actual key
73
+ try:
74
+ headers = {"Authorization": f"Bearer {API_KEY}"}
75
+ response = requests.post(
76
+ f"{HF_ENDPOINT}{model_id}",
77
+ headers=headers,
78
+ json=payload,
79
+ timeout=10
80
+ )
81
+ ai_insights = response.json()
82
+ except Exception as e:
83
+ ai_insights = {"error": str(e)}
84
+
85
+ # Current timestamp for the demo
86
+ current_time = datetime.now().isoformat()
87
+
88
+ # Format response as it would appear in the SKENAI-RENO pipeline
89
+ enriched_event = {
90
+ "event_id": f"evt-{int(time.time())}-{hash(event_content) % 10000}",
91
+ "type": event_type,
92
+ "content": event_content,
93
+ "user_id": user_id,
94
+ "game_id": game_id,
95
+ "timestamp": current_time,
96
+ "ai_enrichment": {
97
+ "model_id": model_id,
98
+ "insights": ai_insights,
99
+ "processed_timestamp": current_time
100
+ },
101
+ "processing": {
102
+ "lambda_execution_time_ms": 120,
103
+ "sqs_wait_time_ms": 15,
104
+ "dynamodb_write_time_ms": 8
105
+ }
106
+ }
107
+
108
+ # Add relevant additional fields based on event type
109
+ if event_type == "transaction":
110
+ enriched_event["transaction_details"] = {
111
+ "amount": 4.99,
112
+ "currency": "USD",
113
+ "item_id": "coins_500",
114
+ "payment_method": "app_store"
115
+ }
116
+ elif event_type == "achievement":
117
+ enriched_event["achievement_details"] = {
118
+ "achievement_id": "level_completion",
119
+ "level": 10,
120
+ "score": 95,
121
+ "completion_time_sec": 320
122
+ }
123
+
124
+ return json.dumps(enriched_event, indent=2)
125
+
126
+ def generate_metrics_visualization():
127
+ """Generate a sample visualization of event processing metrics."""
128
+ # Create sample data for the past 7 days
129
+ dates = [(datetime.now() - timedelta(days=i)).strftime('%Y-%m-%d') for i in range(7)]
130
+ dates.reverse()
131
+
132
+ # Sample event counts by type
133
+ event_types = ["user_feedback", "transaction", "system_event", "achievement"]
134
+ data = []
135
+
136
+ for date in dates:
137
+ for event_type in event_types:
138
+ # Generate some random data with trends
139
+ if event_type == "transaction":
140
+ # Transactions increasing over time
141
+ count = np.random.randint(800, 1200) + (dates.index(date) * 50)
142
+ elif event_type == "user_feedback":
143
+ # Feedback relatively stable
144
+ count = np.random.randint(400, 600)
145
+ elif event_type == "achievement":
146
+ # Achievements with weekly pattern (higher on weekends)
147
+ day_of_week = datetime.strptime(date, '%Y-%m-%d').weekday()
148
+ weekend_boost = 200 if day_of_week >= 5 else 0
149
+ count = np.random.randint(300, 500) + weekend_boost
150
+ else:
151
+ # System events decreasing (good sign, fewer errors)
152
+ count = np.random.randint(100, 300) - (dates.index(date) * 10)
153
+ count = max(count, 50) # Ensure not negative
154
+
155
+ data.append({
156
+ "Date": date,
157
+ "Event Type": event_type,
158
+ "Count": count
159
+ })
160
+
161
+ # Create DataFrame
162
+ df = pd.DataFrame(data)
163
+
164
+ # Create plot
165
+ fig = px.line(
166
+ df,
167
+ x="Date",
168
+ y="Count",
169
+ color="Event Type",
170
+ title="SKENAI-RENO: Event Processing Volume (Last 7 Days)",
171
+ markers=True
172
+ )
173
+
174
+ fig.update_layout(
175
+ xaxis_title="Date",
176
+ yaxis_title="Number of Events",
177
+ legend_title="Event Type",
178
+ template="plotly_white"
179
+ )
180
+
181
+ return fig
182
+
183
+ def create_processing_pipeline_visualization():
184
+ """Create a visual representation of the SKENAI-RENO event processing pipeline."""
185
+ # Sample data for pipeline stages and their performance metrics
186
+ stages = [
187
+ "Redpanda",
188
+ "Lambda Connector",
189
+ "SQS Queue",
190
+ "AI Processor Lambda",
191
+ "DynamoDB"
192
+ ]
193
+
194
+ avg_latency = [5, 25, 15, 120, 8]
195
+ error_rate = [0.01, 0.05, 0.001, 0.2, 0.02]
196
+
197
+ # Create DataFrame
198
+ df = pd.DataFrame({
199
+ "Stage": stages,
200
+ "Average Latency (ms)": avg_latency,
201
+ "Error Rate (%)": [e * 100 for e in error_rate]
202
+ })
203
+
204
+ # Create bar chart for latency
205
+ fig_latency = px.bar(
206
+ df,
207
+ x="Stage",
208
+ y="Average Latency (ms)",
209
+ title="Pipeline Stage Latency",
210
+ color="Average Latency (ms)",
211
+ color_continuous_scale="Viridis"
212
+ )
213
+
214
+ # Create bar chart for error rates
215
+ fig_errors = px.bar(
216
+ df,
217
+ x="Stage",
218
+ y="Error Rate (%)",
219
+ title="Pipeline Stage Error Rates",
220
+ color="Error Rate (%)",
221
+ color_continuous_scale="Reds"
222
+ )
223
+
224
+ return fig_latency, fig_errors
225
+
226
+ # Define the Gradio interface
227
+ with gr.Blocks(theme=gr.themes.Soft(primary_hue="indigo")) as demo:
228
+ gr.Markdown("# SKENAI-RENO Event Processing Demo")
229
+ gr.Markdown("""
230
+ Experience the power of AI-enriched event processing with SKENAI-RENO's serverless pipeline.
231
+ This demo simulates how events from gaming and enterprise applications are processed
232
+ and enriched with AI insights in real-time.
233
+ """)
234
+
235
+ with gr.Tabs():
236
+ with gr.TabItem("Event Processing Simulator"):
237
+ with gr.Row():
238
+ with gr.Column(scale=2):
239
+ gr.Markdown("### Input Event Details")
240
+ with gr.Row():
241
+ event_type = gr.Dropdown(
242
+ choices=["user_feedback", "transaction", "system_event", "achievement"],
243
+ value="user_feedback",
244
+ label="Event Type"
245
+ )
246
+ with gr.Row():
247
+ user_id = gr.Textbox(value="user123", label="User ID")
248
+ game_id = gr.Textbox(value="game456", label="Game/App ID")
249
+ with gr.Row():
250
+ event_content = gr.Textbox(
251
+ lines=5,
252
+ placeholder="Enter event content here...",
253
+ label="Event Content"
254
+ )
255
+ with gr.Row():
256
+ submit_btn = gr.Button("Process Event", variant="primary")
257
+
258
+ with gr.Column(scale=3):
259
+ gr.Markdown("### Enriched Event Output")
260
+ output = gr.JSON()
261
+
262
+ with gr.Row():
263
+ gr.Markdown("### Example Events")
264
+
265
+ with gr.Row():
266
+ example1 = gr.Button("User Feedback Example")
267
+ example2 = gr.Button("Transaction Example")
268
+ example3 = gr.Button("Achievement Example")
269
+
270
+ # Set up example event handlers
271
+ example1.click(
272
+ lambda: ["user_feedback", "user123", "game456", "I love this game! The new level design is amazing."],
273
+ outputs=[event_type, user_id, game_id, event_content]
274
+ )
275
+
276
+ example2.click(
277
+ lambda: ["transaction", "user789", "game456", "User purchased 500 coins for $4.99"],
278
+ outputs=[event_type, user_id, game_id, event_content]
279
+ )
280
+
281
+ example3.click(
282
+ lambda: ["achievement", "user456", "game789", "User completed level 10 with score 95/100"],
283
+ outputs=[event_type, user_id, game_id, event_content]
284
+ )
285
+
286
+ with gr.TabItem("System Analytics"):
287
+ gr.Markdown("### SKENAI-RENO Event Processing Analytics")
288
+ gr.Markdown("""
289
+ This dashboard shows sample analytics of the SKENAI-RENO event processing pipeline.
290
+ In a production environment, these metrics would be generated from real-time CloudWatch data.
291
+ """)
292
+
293
+ with gr.Row():
294
+ metrics_plot = gr.Plot()
295
+
296
+ with gr.Row():
297
+ with gr.Column():
298
+ latency_plot = gr.Plot()
299
+ with gr.Column():
300
+ error_plot = gr.Plot()
301
+
302
+ refresh_btn = gr.Button("Refresh Analytics")
303
+
304
+ with gr.TabItem("About SKENAI-RENO"):
305
+ gr.Markdown("""
306
+ # About SKENAI-RENO
307
+
308
+ SKENAI-RENO is a fully serverless event processing pipeline designed for high-reliability,
309
+ AI-enhanced insights, and seamless integration with existing systems.
310
+
311
+ ## Key Features
312
+
313
+ * **Serverless Architecture**: AWS Lambda, SQS, DynamoDB
314
+ * **AI Enrichment**: Hugging Face models integrated directly into the event pipeline
315
+ * **High Reliability**: Idempotent processing, dead-letter queues, comprehensive monitoring
316
+ * **Enterprise Ready**: Secure, scalable, and compliant
317
+
318
+ ## Technical Architecture
319
+
320
+ SKENAI-RENO uses a multi-stage serverless architecture:
321
+
322
+ 1. **Event Sources**: Capture events from various sources (gaming, web, mobile, IoT)
323
+ 2. **Redpanda**: High-performance event streaming platform
324
+ 3. **Lambda Connector**: Processes events from Redpanda and sends to SQS
325
+ 4. **SQS Queue**: Decouples components and provides buffering
326
+ 5. **AI Processor Lambda**: Enriches events with AI insights using Hugging Face models
327
+ 6. **DynamoDB**: Stores processed events for analysis and retrieval
328
+
329
+ ## Integration Options
330
+
331
+ * REST API for direct event submission
332
+ * SDK libraries for major platforms
333
+ * Webhook integrations
334
+ * Custom connectors for enterprise systems
335
+
336
+ ## Learn More
337
+
338
+ For enterprise solutions and partnership opportunities, visit [skenai-reno.com](https://skenai-reno.com)
339
+ """)
340
+
341
+ # Set up event handlers
342
+ submit_btn.click(
343
+ process_event,
344
+ inputs=[event_type, event_content, user_id, game_id],
345
+ outputs=output
346
+ )
347
+
348
+ # Initialize and refresh the analytics
349
+ refresh_btn.click(
350
+ lambda: [generate_metrics_visualization(), *create_processing_pipeline_visualization()],
351
+ outputs=[metrics_plot, latency_plot, error_plot]
352
+ )
353
+
354
+ # Initialize the analytics on page load
355
+ demo.load(
356
+ lambda: [generate_metrics_visualization(), *create_processing_pipeline_visualization()],
357
+ outputs=[metrics_plot, latency_plot, error_plot]
358
+ )
359
+
360
+ # Launch the app
361
+ if __name__ == "__main__":
362
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ gradio>=3.50.2
2
+ requests>=2.31.0
3
+ numpy>=1.24.0
4
+ pandas>=2.0.0
5
+ plotly>=5.14.0
rosetta_animation.py ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Rosetta Animation for Hugging Face Spaces Demo
3
+ ----------------------------------------------
4
+ This file contains a Gradio component that adapts the Rosetta animation
5
+ from your Next.js project for use in Hugging Face Spaces.
6
+ """
7
+
8
+ import gradio as gr
9
+ import base64
10
+ import os
11
+ from pathlib import Path
12
+
13
+ def create_rosetta_animation():
14
+ """Create HTML/CSS/JS for the Rosetta animation"""
15
+
16
+ # SVG content for light and dark mode
17
+ # These are embedded directly rather than loaded from files
18
+ light_svg_base64 = "PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTEyLjAwMDQgMjRDMTguNjI3OSAyNCAyNCAxOC42Mjc5IDI0IDEyLjAwMDRDMjQgNS4zNzI5MSAxOC42Mjc5IDAgMTIuMDAwNCAwQzUuMzcyOTEgMCAwIDUuMzcyOTEgMCAxMi4wMDA0QzAgMTguNjI3OSA1LjM3MjkxIDI0IDEyLjAwMDQgMjRaIiBmaWxsPSIjRkY2MTJDIi8+CjxwYXRoIGQ9Ik0xMi4wMDA0IDIxLjAzQzE3LjAwMDYgMjEuMDMgMjEuMDMgMTcuMDAwNiAyMS4wMyAxMi4wMDA0QzIxLjAzIDcuMDAwMjMgMTcuMDAwNiAyLjk3MSAxMi4wMDA0IDIuOTcxQzcuMDAwMjMgMi45NzEgMi45NzEgNy4wMDAyMyAyLjk3MSAxMi4wMDA0QzIuOTcxIDE3LjAwMDYgNy4wMDAyMyAyMS4wMyAxMi4wMDA0IDIxLjAzWiIgZmlsbD0iYmxhY2siLz4KPC9zdmc+"
19
+ dark_svg_base64 = "PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTEyLjAwMDQgMjRDMTguNjI3OSAyNCAyNCAxOC42Mjc5IDI0IDEyLjAwMDRDMjQgNS4zNzI5MSAxOC42Mjc5IDAgMTIuMDAwNCAwQzUuMzcyOTEgMCAwIDUuMzcyOTEgMCAxMi4wMDA0QzAgMTguNjI3OSA1LjM3MjkxIDI0IDEyLjAwMDQgMjRaIiBmaWxsPSIjRkY2MTJDIi8+CjxwYXRoIGQ9Ik0xMi4wMDA0IDIxLjAzQzE3LjAwMDYgMjEuMDMgMjEuMDMgMTcuMDAwNiAyMS4wMyAxMi4wMDA0QzIxLjAzIDcuMDAwMjMgMTcuMDAwNiAyLjk3MSAxMi4wMDA0IDIuOTcxQzcuMDAwMjMgMi45NzEgMi45NzEgNy4wMDAyMyAyLjk3MSAxMi4wMDA0QzIuOTcxIDE3LjAwMDYgNy4wMDAyMyAyMS4wMyAxMi4wMDA0IDIxLjAzWiIgZmlsbD0iYmxhY2siLz4KPC9zdmc+"
20
+
21
+ # HTML for the animation
22
+ html = f"""
23
+ <div class="rosetta-container">
24
+ <div class="rosetta-animation" id="rosetta">
25
+ <!-- Petals will be added via JavaScript -->
26
+ </div>
27
+ </div>
28
+
29
+ <style>
30
+ .rosetta-container {{
31
+ display: flex;
32
+ justify-content: center;
33
+ align-items: center;
34
+ padding: 20px;
35
+ }}
36
+
37
+ .rosetta-animation {{
38
+ position: relative;
39
+ width: 144px;
40
+ height: 144px;
41
+ transition: transform 0.3s;
42
+ }}
43
+
44
+ .rosetta-animation:hover {{
45
+ transform: scale(1.05);
46
+ }}
47
+
48
+ .petal-container {{
49
+ position: absolute;
50
+ top: 0;
51
+ left: 0;
52
+ width: 144px;
53
+ height: 144px;
54
+ }}
55
+
56
+ .petal {{
57
+ position: absolute;
58
+ left: 50%;
59
+ top: 50%;
60
+ width: 24px;
61
+ height: 24px;
62
+ }}
63
+
64
+ @keyframes selfAnimationRosetta {{
65
+ /* Cycle 1: Both Pauses Move Elements IN (0% -> 50% of 9s duration) */
66
+ 0% {{ transform: translate(-50%, -50%) translateY(-30px) rotate(90deg); opacity: 0.9; }}
67
+ 10% {{ transform: translate(-50%, -50%) translateY(-30px) rotate(90deg); opacity: 0.9; }}
68
+ 20% {{ transform: translate(-50%, -50%) translateY(-23px) rotate(180deg); opacity: 0.95;}}
69
+ 25% {{ transform: translate(-50%, -50%) translateY(-23px) rotate(180deg); opacity: 0.95;}}
70
+ 30% {{ transform: translate(-50%, -50%) translateY(-23px) rotate(270deg); opacity: 1.0; }}
71
+ 35% {{ transform: translate(-50%, -50%) translateY(-23px) rotate(270deg); opacity: 1.0; }}
72
+ 50% {{ transform: translate(-50%, -50%) translateY(-30px) rotate(450deg); opacity: 0.9; }}
73
+
74
+ /* Cycle 2: Skips Midpoint Pause (50% -> 100% of 9s duration) */
75
+ 50% {{ transform: translate(-50%, -50%) translateY(-30px) rotate(450deg); opacity: 0.9; }}
76
+ 60% {{ transform: translate(-50%, -50%) translateY(-30px) rotate(450deg); opacity: 0.9; }}
77
+ 80% {{ transform: translate(-50%, -50%) translateY(-23px) rotate(630deg); opacity: 1.0; }}
78
+ 85% {{ transform: translate(-50%, -50%) translateY(-23px) rotate(630deg); opacity: 1.0; }}
79
+ 100% {{ transform: translate(-50%, -50%) translateY(-30px) rotate(810deg); opacity: 0.9; }}
80
+ }}
81
+
82
+ @keyframes groupPulse {{
83
+ 0% {{ transform: scale(1) rotate(0deg); }}
84
+ 50% {{ transform: scale(0.98) rotate(180deg); }}
85
+ 100% {{ transform: scale(1) rotate(360deg); }}
86
+ }}
87
+ </style>
88
+
89
+ <script>
90
+ (function() {{
91
+ // Get container element
92
+ const container = document.getElementById('rosetta');
93
+
94
+ // Set animation for container
95
+ container.style.animation = 'groupPulse 8s ease-in-out infinite';
96
+
97
+ // SVG data as base64
98
+ const svgData = '{light_svg_base64}';
99
+ const svgDataDark = '{dark_svg_base64}';
100
+
101
+ // Determine which SVG to use based on color scheme preference
102
+ const prefersDarkScheme = window.matchMedia('(prefers-color-scheme: dark)').matches;
103
+ const currentSvg = prefersDarkScheme ? svgDataDark : svgData;
104
+
105
+ // Create petals
106
+ const petals = 5;
107
+ for (let i = 0; i < petals; i++) {{
108
+ // Create petal container
109
+ const petalContainer = document.createElement('div');
110
+ petalContainer.className = 'petal-container';
111
+ petalContainer.style.transform = `rotate(${{(360 / petals) * i}}deg)`;
112
+
113
+ // Create petal
114
+ const petal = document.createElement('div');
115
+ petal.className = 'petal';
116
+ petal.style.animation = 'selfAnimationRosetta 9s ease-in-out infinite';
117
+ petal.style.animationDelay = `${{i * 0.05}}s`;
118
+
119
+ // Create SVG image
120
+ const img = document.createElement('img');
121
+ img.src = `data:image/svg+xml;base64,${{currentSvg}}`;
122
+ img.alt = `Petal ${{i + 1}}`;
123
+ img.style.width = '100%';
124
+ img.style.height = '100%';
125
+
126
+ // Assemble components
127
+ petal.appendChild(img);
128
+ petalContainer.appendChild(petal);
129
+ container.appendChild(petalContainer);
130
+ }}
131
+ }})();
132
+ </script>
133
+ """
134
+
135
+ return html
136
+
137
+ def rosetta_logo():
138
+ """Create a Gradio HTML component with the Rosetta animation"""
139
+ html_content = create_rosetta_animation()
140
+ return gr.HTML(html_content)
141
+
142
+ # Example usage in a Gradio app:
143
+ if __name__ == "__main__":
144
+ with gr.Blocks() as demo:
145
+ gr.Markdown("# SKENAI-NET Rosetta Animation Demo")
146
+ rosetta_logo()
147
+ gr.Markdown("This animation demonstrates the Rosetta component adapted for Hugging Face Spaces.")
148
+
149
+ demo.launch()