Spaces:
Sleeping
Sleeping
Commit
Β·
e0cf4f1
1
Parent(s):
c133cf6
better visualisation
Browse files
app.py
CHANGED
@@ -8,12 +8,11 @@ import torch
|
|
8 |
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
|
9 |
|
10 |
DESCRIPTION = """\
|
11 |
-
|
12 |
|
13 |
-
This is a demo of
|
14 |
-
For more details, please check [the post](https://huggingface.co/blog/gemma2).
|
15 |
|
16 |
-
π Looking for a larger and more powerful version? Try the 27B version in
|
17 |
"""
|
18 |
|
19 |
MAX_MAX_NEW_TOKENS = 2048
|
@@ -73,84 +72,98 @@ def generate(
|
|
73 |
yield "".join(outputs)
|
74 |
|
75 |
|
76 |
-
#
|
77 |
gemini_css = """
|
78 |
:root {
|
79 |
-
|
80 |
-
--gradient-
|
81 |
-
--gradient-end: #FFFFFF; /* White */
|
82 |
}
|
83 |
|
84 |
-
/* Overall page
|
85 |
html, body, .gradio-container {
|
86 |
margin: 0;
|
87 |
padding: 0;
|
88 |
background: linear-gradient(to bottom, var(--gradient-start), var(--gradient-end));
|
89 |
font-family: "Helvetica", sans-serif;
|
90 |
-
color: #
|
91 |
}
|
92 |
|
93 |
-
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
.gradio-container h1 {
|
|
|
|
|
95 |
text-align: center;
|
96 |
-
|
97 |
-
margin-bottom: 0.6em;
|
98 |
}
|
99 |
|
100 |
-
/* Chat
|
101 |
-
.chat-interface, .chat-interface .
|
102 |
-
background-color:
|
103 |
}
|
104 |
|
105 |
-
/*
|
|
|
|
|
|
|
|
|
|
|
106 |
.chat-message.user {
|
107 |
-
background-color: #
|
108 |
-
color: #FFFFFF;
|
109 |
border-radius: 8px;
|
110 |
padding: 8px 12px;
|
111 |
-
margin:
|
112 |
}
|
113 |
|
114 |
-
/* Bot message bubble */
|
115 |
.chat-message.bot {
|
116 |
-
background-color: #
|
117 |
-
color: #
|
118 |
border-radius: 8px;
|
119 |
padding: 8px 12px;
|
120 |
-
margin:
|
121 |
}
|
122 |
|
123 |
-
/* Chat input */
|
124 |
.chat-input textarea {
|
125 |
background-color: #FFFFFF;
|
126 |
-
color: #
|
127 |
-
border: 1px solid #
|
128 |
border-radius: 6px;
|
|
|
129 |
}
|
130 |
|
131 |
-
/*
|
132 |
form.sliders input[type="range"] {
|
133 |
-
accent-color: #
|
134 |
}
|
135 |
form.sliders label {
|
136 |
-
color: #
|
137 |
}
|
138 |
|
139 |
.gradio-button, .chat-send-btn {
|
140 |
-
background-color: #
|
141 |
-
color: #FFFFFF;
|
142 |
border-radius: 5px;
|
143 |
border: none;
|
144 |
cursor: pointer;
|
145 |
}
|
146 |
-
|
147 |
.gradio-button:hover, .chat-send-btn:hover {
|
148 |
-
background-color: #
|
149 |
}
|
150 |
|
151 |
-
/*
|
152 |
-
|
153 |
-
|
|
|
|
|
|
|
154 |
}
|
155 |
"""
|
156 |
|
@@ -204,7 +217,6 @@ demo = gr.ChatInterface(
|
|
204 |
cache_examples=False,
|
205 |
type="messages",
|
206 |
description=DESCRIPTION,
|
207 |
-
# Removing css_paths, replace with direct CSS:
|
208 |
css=gemini_css,
|
209 |
fill_height=True,
|
210 |
)
|
|
|
8 |
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
|
9 |
|
10 |
DESCRIPTION = """\
|
11 |
+
<h1 style="text-align: center;">Hi, I'm Gemma 2 (2B) π</h1>
|
12 |
|
13 |
+
This is a demo of <strong>google/gemma-2-2b-it</strong> fine-tuned for instruction following. For more details, please check <a href="https://huggingface.co/blog/gemma2" target="_blank">the post</a>.
|
|
|
14 |
|
15 |
+
π Looking for a larger and more powerful version? Try the 27B version in <a href="https://huggingface.co/chat/models/google/gemma-2-27b-it" target="_blank">HuggingChat</a> and the 9B version in <a href="https://huggingface.co/spaces/huggingface-projects/gemma-2-9b-it" target="_blank">this Space</a>.
|
16 |
"""
|
17 |
|
18 |
MAX_MAX_NEW_TOKENS = 2048
|
|
|
72 |
yield "".join(outputs)
|
73 |
|
74 |
|
75 |
+
# A revised Gemini-like CSS with smoother gradients and better contrast.
|
76 |
gemini_css = """
|
77 |
:root {
|
78 |
+
--gradient-start: #66AEEF; /* lighter top */
|
79 |
+
--gradient-end: #F0F8FF; /* very light at bottom */
|
|
|
80 |
}
|
81 |
|
82 |
+
/* Overall page & container background gradient */
|
83 |
html, body, .gradio-container {
|
84 |
margin: 0;
|
85 |
padding: 0;
|
86 |
background: linear-gradient(to bottom, var(--gradient-start), var(--gradient-end));
|
87 |
font-family: "Helvetica", sans-serif;
|
88 |
+
color: #333; /* dark gray for better contrast */
|
89 |
}
|
90 |
|
91 |
+
/* Make anchor (link) text a clearly visible dark blue */
|
92 |
+
a, a:visited {
|
93 |
+
color: #02497A !important;
|
94 |
+
text-decoration: underline;
|
95 |
+
}
|
96 |
+
|
97 |
+
/* Center the top headings in the description */
|
98 |
.gradio-container h1 {
|
99 |
+
margin-top: 0.8em;
|
100 |
+
margin-bottom: 0.5em;
|
101 |
text-align: center;
|
102 |
+
color: #fff; /* White text on top gradient for pop */
|
|
|
103 |
}
|
104 |
|
105 |
+
/* Chat container background: a very light blue so it's distinct from the outer gradient */
|
106 |
+
.chat-interface, .chat-interface .wrap {
|
107 |
+
background-color: #F8FDFF !important;
|
108 |
}
|
109 |
|
110 |
+
/* Remove harsh frames around chat messages */
|
111 |
+
.chat-message {
|
112 |
+
border: none !important;
|
113 |
+
}
|
114 |
+
|
115 |
+
/* User message bubble: a deeper blue with white text */
|
116 |
.chat-message.user {
|
117 |
+
background-color: #0284C7 !important;
|
118 |
+
color: #FFFFFF !important;
|
119 |
border-radius: 8px;
|
120 |
padding: 8px 12px;
|
121 |
+
margin: 6px 0;
|
122 |
}
|
123 |
|
124 |
+
/* Bot message bubble: very light blue with darker text */
|
125 |
.chat-message.bot {
|
126 |
+
background-color: #EFF8FF !important;
|
127 |
+
color: #333 !important;
|
128 |
border-radius: 8px;
|
129 |
padding: 8px 12px;
|
130 |
+
margin: 6px 0;
|
131 |
}
|
132 |
|
133 |
+
/* Chat input area */
|
134 |
.chat-input textarea {
|
135 |
background-color: #FFFFFF;
|
136 |
+
color: #333;
|
137 |
+
border: 1px solid #66AEEF;
|
138 |
border-radius: 6px;
|
139 |
+
padding: 8px;
|
140 |
}
|
141 |
|
142 |
+
/* Sliders & other controls */
|
143 |
form.sliders input[type="range"] {
|
144 |
+
accent-color: #66AEEF;
|
145 |
}
|
146 |
form.sliders label {
|
147 |
+
color: #333;
|
148 |
}
|
149 |
|
150 |
.gradio-button, .chat-send-btn {
|
151 |
+
background-color: #0284C7 !important;
|
152 |
+
color: #FFFFFF !important;
|
153 |
border-radius: 5px;
|
154 |
border: none;
|
155 |
cursor: pointer;
|
156 |
}
|
|
|
157 |
.gradio-button:hover, .chat-send-btn:hover {
|
158 |
+
background-color: #026FA6 !important;
|
159 |
}
|
160 |
|
161 |
+
/* Additional spacing / small tweaks */
|
162 |
+
#duplicate-button {
|
163 |
+
margin: auto;
|
164 |
+
background: #1565c0;
|
165 |
+
border-radius: 100vh;
|
166 |
+
color: #fff;
|
167 |
}
|
168 |
"""
|
169 |
|
|
|
217 |
cache_examples=False,
|
218 |
type="messages",
|
219 |
description=DESCRIPTION,
|
|
|
220 |
css=gemini_css,
|
221 |
fill_height=True,
|
222 |
)
|