gaur3009 commited on
Commit
04a6d22
·
verified ·
1 Parent(s): 69c49d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -68
app.py CHANGED
@@ -39,6 +39,7 @@ def infer(color_prompt, Phone_type_prompt, design_prompt):
39
  else:
40
  raise Exception(f"API Error: {response.status_code}")
41
 
 
42
  custom_css = """
43
  body {
44
  font-family: 'Poppins', sans-serif;
@@ -84,64 +85,23 @@ textarea.light-mode, input.light-mode {
84
  border-radius: 12px;
85
  margin-top: 20px;
86
  }
87
- /* Neon Button Styling */
88
- button {
89
- font-size: 1.2rem;
90
- padding: 10px 20px;
91
- border-radius: 5px;
92
- cursor: pointer;
93
- border: none;
94
- color: white;
95
- background: linear-gradient(90deg, red, orange, yellow, green, cyan, blue, violet);
96
- background-size: 400%;
97
- box-shadow: 0 0 10px rgba(255, 255, 255, 0.6),
98
- 0 0 20px rgba(255, 255, 255, 0.4),
99
- 0 0 40px rgba(255, 255, 255, 0.2);
100
- animation: neon-button 2s infinite;
101
- transition: transform 0.3s;
102
- }
103
- button:hover {
104
- transform: scale(1.1);
105
- box-shadow: 0 0 20px rgba(255, 255, 255, 0.8),
106
- 0 0 40px rgba(255, 255, 255, 0.6),
107
- 0 0 60px rgba(255, 255, 255, 0.4);
108
- }
109
- /* Neon Animation */
110
- @keyframes neon-button {
111
- 0% { background-position: 0%; }
112
- 100% { background-position: 400%; }
113
  }
114
- /* Loading Spinner */
115
- #loading-spinner {
116
- display: none;
117
- margin: 20px auto;
118
- border: 6px solid #f3f3f3;
119
- border-top: 6px solid #3498db;
120
  border-radius: 50%;
121
- width: 50px;
122
- height: 50px;
123
- animation: spin 1s linear infinite;
124
- }
125
- @keyframes spin {
126
- 0% { transform: rotate(0deg); }
127
- 100% { transform: rotate(360deg); }
128
- }
129
- @media screen and (max-width: 768px) {
130
- .gradio-container {
131
- padding: 10px;
132
  }
133
- textarea, input {
134
- font-size: 0.9rem;
135
- }
136
- button {
137
- font-size: 0.9rem;
138
- }
139
- }
140
- @media screen and (min-width: 769px) {
141
- .gradio-container {
142
- padding: 20px;
143
- max-width: 1200px;
144
- margin: auto;
145
  }
146
  }
147
  """
@@ -159,24 +119,29 @@ document.addEventListener('DOMContentLoaded', function () {
159
  document.body.prepend(toggleButton);
160
  document.body.classList.add('light-mode'); // Default to light mode
161
 
162
- // Dynamic Welcome Message
163
- const welcomeMessage = document.createElement('h2');
 
 
 
 
 
164
  const currentHour = new Date().getHours();
165
  let greeting = "Welcome!";
166
  if (currentHour < 12) greeting = "Good Morning!";
167
  else if (currentHour < 18) greeting = "Good Afternoon!";
168
  else greeting = "Good Evening!";
169
- welcomeMessage.textContent = greeting + " Customize your phone cover!";
170
- welcomeMessage.style.textAlign = "center";
171
  document.body.prepend(welcomeMessage);
172
 
173
- // Add spinner toggle on button click
174
- const generateButton = document.querySelector('button:contains("Generate Design")');
175
- const spinner = document.getElementById('loading-spinner');
176
- generateButton.onclick = () => {
177
- spinner.style.display = 'block';
178
- setTimeout(() => spinner.style.display = 'none', 5000); // Mock loading
179
- };
180
  });
181
  </script>
182
  """
@@ -196,11 +161,10 @@ with gr.Blocks(css=custom_css) as interface:
196
  Back_cover_prompt = gr.Textbox(label="Mobile type", placeholder="E.g., iPhone, Samsung", elem_id="component-2")
197
  design_prompt = gr.Textbox(label="Design Details", placeholder="E.g., Bold stripes with geometric patterns", elem_id="component-3")
198
  generate_button = gr.Button("Generate Design")
199
- spinner = gr.HTML('<div id="loading-spinner"></div>')
200
  with gr.Column(scale=1, min_width=300):
201
  output = gr.Image(label="Generated Design", elem_id="output-image")
202
 
203
  generate_button.click(infer, inputs=[color_prompt, Back_cover_prompt, design_prompt], outputs=output)
204
 
205
  # Launch the app
206
- interface.launch(debug=True)
 
39
  else:
40
  raise Exception(f"API Error: {response.status_code}")
41
 
42
+
43
  custom_css = """
44
  body {
45
  font-family: 'Poppins', sans-serif;
 
85
  border-radius: 12px;
86
  margin-top: 20px;
87
  }
88
+ .avatar-container {
89
+ text-align: center;
90
+ margin-bottom: 20px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  }
92
+ .avatar-container img {
 
 
 
 
 
93
  border-radius: 50%;
94
+ width: 150px;
95
+ height: 150px;
96
+ box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.3);
97
+ animation: bounce 2s infinite;
98
+ }
99
+ @keyframes bounce {
100
+ 0%, 100% {
101
+ transform: translateY(0);
 
 
 
102
  }
103
+ 50% {
104
+ transform: translateY(-10px);
 
 
 
 
 
 
 
 
 
 
105
  }
106
  }
107
  """
 
119
  document.body.prepend(toggleButton);
120
  document.body.classList.add('light-mode'); // Default to light mode
121
 
122
+ // Dynamic Welcome Message with AI avatar speech
123
+ const welcomeMessage = document.createElement('div');
124
+ welcomeMessage.classList.add('avatar-container');
125
+ const avatarImg = document.createElement('img');
126
+ avatarImg.src = 'https://i.postimg.cc/Qd9Gjc5Z/ai-girl-avatar.png'; // Replace with your AI girl avatar image
127
+ welcomeMessage.appendChild(avatarImg);
128
+ const messageText = document.createElement('h2');
129
  const currentHour = new Date().getHours();
130
  let greeting = "Welcome!";
131
  if (currentHour < 12) greeting = "Good Morning!";
132
  else if (currentHour < 18) greeting = "Good Afternoon!";
133
  else greeting = "Good Evening!";
134
+ messageText.textContent = greeting + " I'm your AI assistant. Let's design something amazing!";
135
+ welcomeMessage.appendChild(messageText);
136
  document.body.prepend(welcomeMessage);
137
 
138
+ // Speech synthesis
139
+ const speech = new SpeechSynthesisUtterance();
140
+ speech.text = messageText.textContent;
141
+ speech.pitch = 1;
142
+ speech.rate = 1;
143
+ speech.lang = 'en-US';
144
+ window.speechSynthesis.speak(speech);
145
  });
146
  </script>
147
  """
 
161
  Back_cover_prompt = gr.Textbox(label="Mobile type", placeholder="E.g., iPhone, Samsung", elem_id="component-2")
162
  design_prompt = gr.Textbox(label="Design Details", placeholder="E.g., Bold stripes with geometric patterns", elem_id="component-3")
163
  generate_button = gr.Button("Generate Design")
 
164
  with gr.Column(scale=1, min_width=300):
165
  output = gr.Image(label="Generated Design", elem_id="output-image")
166
 
167
  generate_button.click(infer, inputs=[color_prompt, Back_cover_prompt, design_prompt], outputs=output)
168
 
169
  # Launch the app
170
+ interface.launch(debug=True)