Update app.py
Browse files
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 |
-
|
88 |
-
|
89 |
-
|
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 |
-
|
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:
|
122 |
-
height:
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
100% {
|
128 |
-
|
129 |
-
@media screen and (max-width: 768px) {
|
130 |
-
.gradio-container {
|
131 |
-
padding: 10px;
|
132 |
}
|
133 |
-
|
134 |
-
|
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('
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
170 |
-
welcomeMessage.
|
171 |
document.body.prepend(welcomeMessage);
|
172 |
|
173 |
-
//
|
174 |
-
const
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
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)
|