akhaliq HF Staff commited on
Commit
8e31ec4
Β·
verified Β·
1 Parent(s): 8eb2595

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +83 -16
app.py CHANGED
@@ -142,15 +142,82 @@ def process_video_and_question(video, question, fps, force_packing, history):
142
  def clear_chat():
143
  return [], None, "", 3, 0
144
 
145
- # CSS for better styling
146
  css = """
147
  .chat-container {
148
  overflow-y: auto;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  }
150
  """
151
 
152
- # Create Gradio interface
153
- with gr.Blocks(css=css, title="Video Chat with MiniCPM-V") as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  gr.Markdown(
155
  """
156
  # πŸŽ₯ Video Chat with MiniCPM-V-4.5
@@ -186,13 +253,13 @@ with gr.Blocks(css=css, title="Video Chat with MiniCPM-V") as demo:
186
  lines=2,
187
  scale=4
188
  )
189
- submit_btn = gr.Button("Send", variant="primary", scale=1)
190
 
191
  with gr.Row():
192
- clear_btn = gr.Button("πŸ—‘οΈ Clear Chat")
193
- example_btn1 = gr.Button("πŸ“ Describe")
194
- example_btn2 = gr.Button("🎬 Action")
195
- example_btn3 = gr.Button("πŸ‘₯ People")
196
 
197
  with gr.Accordion("Advanced Settings", open=False):
198
  fps_slider = gr.Slider(
@@ -213,14 +280,14 @@ with gr.Blocks(css=css, title="Video Chat with MiniCPM-V") as demo:
213
  info=f"0 = auto, 1-{MAX_NUM_PACKING} = force specific packing number"
214
  )
215
 
216
- gr.Markdown(
217
- """
218
- ### Video Info
219
- - Max frames: 180 Γ— 3 packing = 540 frames
220
- - Temporal compression: 64 tokens per video
221
- - Supported formats: MP4, AVI, MOV, etc.
222
- """
223
- )
224
 
225
  # Example questions
226
  example_btn1.click(
 
142
  def clear_chat():
143
  return [], None, "", 3, 0
144
 
145
+ # CSS for better styling with Apple-inspired design
146
  css = """
147
  .chat-container {
148
  overflow-y: auto;
149
+ border-radius: 12px;
150
+ }
151
+
152
+ .gradio-container {
153
+ font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', sans-serif !important;
154
+ }
155
+
156
+ .gr-button {
157
+ font-weight: 500;
158
+ transition: all 0.2s ease;
159
+ }
160
+
161
+ .gr-button:active {
162
+ transform: scale(0.98);
163
+ }
164
+
165
+ .gr-input, .gr-textarea {
166
+ backdrop-filter: blur(10px);
167
+ }
168
+
169
+ .gr-box {
170
+ backdrop-filter: blur(20px);
171
+ background: rgba(255, 255, 255, 0.8) !important;
172
+ }
173
+
174
+ .dark .gr-box {
175
+ background: rgba(0, 0, 0, 0.6) !important;
176
+ }
177
+
178
+ /* Smooth transitions */
179
+ * {
180
+ transition: background-color 0.2s ease, border-color 0.2s ease;
181
  }
182
  """
183
 
184
+ # Create Gradio interface with Apple-style theme
185
+ theme = gr.themes.Soft(
186
+ primary_hue=gr.themes.colors.blue,
187
+ secondary_hue=gr.themes.colors.gray,
188
+ neutral_hue=gr.themes.colors.gray,
189
+ spacing_size="md",
190
+ radius_size="md",
191
+ text_size="md",
192
+ font=[gr.themes.GoogleFont("Inter"), "SF Pro Display", "-apple-system", "BlinkMacSystemFont", "sans-serif"],
193
+ font_mono=[gr.themes.GoogleFont("SF Mono"), "Monaco", "Menlo", "monospace"]
194
+ ).set(
195
+ body_background_fill="*neutral_50",
196
+ body_background_fill_dark="*neutral_950",
197
+ button_primary_background_fill="*primary_500",
198
+ button_primary_background_fill_hover="*primary_600",
199
+ button_primary_text_color="white",
200
+ button_primary_border_color="*primary_500",
201
+ block_background_fill="white",
202
+ block_background_fill_dark="*neutral_900",
203
+ block_border_width="1px",
204
+ block_border_color="*neutral_200",
205
+ block_border_color_dark="*neutral_800",
206
+ block_radius="*radius_lg",
207
+ block_shadow="0px 1px 3px 0px rgba(0, 0, 0, 0.02), 0px 0px 0px 1px rgba(0, 0, 0, 0.05)",
208
+ block_shadow_dark="0px 1px 3px 0px rgba(0, 0, 0, 0.1), 0px 0px 0px 1px rgba(255, 255, 255, 0.05)",
209
+ input_background_fill="*neutral_50",
210
+ input_background_fill_dark="*neutral_900",
211
+ input_border_color="*neutral_300",
212
+ input_border_color_dark="*neutral_700",
213
+ input_border_width="1px",
214
+ input_radius="*radius_md",
215
+ slider_color="*primary_500",
216
+ chatbot_code_background_color="*neutral_100",
217
+ chatbot_code_background_color_dark="*neutral_800",
218
+ )
219
+
220
+ with gr.Blocks(css=css, theme=theme, title="Video Chat with MiniCPM-V") as demo:
221
  gr.Markdown(
222
  """
223
  # πŸŽ₯ Video Chat with MiniCPM-V-4.5
 
253
  lines=2,
254
  scale=4
255
  )
256
+ submit_btn = gr.Button("Send", variant="primary", scale=1, icon="πŸš€")
257
 
258
  with gr.Row():
259
+ clear_btn = gr.Button("Clear Chat", variant="secondary", size="sm", icon="πŸ—‘οΈ")
260
+ example_btn1 = gr.Button("Describe", size="sm", icon="πŸ“")
261
+ example_btn2 = gr.Button("Action", size="sm", icon="🎬")
262
+ example_btn3 = gr.Button("People", size="sm", icon="πŸ‘₯")
263
 
264
  with gr.Accordion("Advanced Settings", open=False):
265
  fps_slider = gr.Slider(
 
280
  info=f"0 = auto, 1-{MAX_NUM_PACKING} = force specific packing number"
281
  )
282
 
283
+ with gr.Accordion("ℹ️ Video Info", open=False):
284
+ gr.Markdown(
285
+ """
286
+ - **Max frames:** 180 Γ— 3 packing = 540 frames
287
+ - **Temporal compression:** 64 tokens per video
288
+ - **Supported formats:** MP4, AVI, MOV, etc.
289
+ """
290
+ )
291
 
292
  # Example questions
293
  example_btn1.click(