CGQN commited on
Commit
98a9e83
·
verified ·
1 Parent(s): c954c3d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -2,13 +2,9 @@ import time
2
  import gradio as gr
3
  from PIL import Image
4
 
5
- # MODIFIED: Added more placeholder responses to prevent an IndexError,
6
- # as the original function accesses indices 1, 2, and 3.
7
  PREWRITTEN_RESPONSES = [
8
- "This is a sample response about a chart. It seems to describe the growth of internet shopping over a four-year period, from 2018 to 2021. The sales figures and growth rates are mentioned, showing a clear upward trend. The text also speculates that the COVID-19 pandemic might have contributed to this shift in consumer behavior.",
9
- "Travel Advice: This is a placeholder for travel advice.",
10
- "Weather Analysis: This is a placeholder for a weather analysis.",
11
- "Photography Tips: This is a placeholder for photography tips."
12
  ]
13
 
14
  def fake_minicpm_infer(image: Image.Image, text: str):
@@ -33,9 +29,10 @@ def fake_minicpm_infer(image: Image.Image, text: str):
33
 
34
  # --- START OF MODIFICATIONS ---
35
 
36
- # Define custom CSS to increase the font size of our target textbox.
37
- # We target the <textarea> element inside the component with the ID 'output_textbox'.
38
  custom_css = """
 
39
  #output_textbox textarea {
40
  font-size: 18px !important;
41
  }
@@ -43,7 +40,7 @@ custom_css = """
43
 
44
  # Pass the custom CSS to the gr.Blocks constructor.
45
  with gr.Blocks(title="MiniCPM-V-4_5 Demo", css=custom_css) as demo:
46
-
47
  # --- END OF MODIFICATIONS ---
48
 
49
  gr.Markdown(
@@ -55,17 +52,20 @@ with gr.Blocks(title="MiniCPM-V-4_5 Demo", css=custom_css) as demo:
55
  with gr.Row():
56
  with gr.Column(scale=1):
57
  image_in = gr.Image(label="Input Image", type="pil")
 
 
 
58
  text_in = gr.Textbox(
59
  label="Input Question/Description",
60
  placeholder="e.g., What kind of landscape is this? or What should I be aware of when traveling?",
61
- lines=3
 
62
  )
 
63
  submit_btn = gr.Button("Submit", variant="primary")
64
 
65
  with gr.Column(scale=1):
66
  gr.Markdown("### Output")
67
- # --- MODIFICATION ---
68
- # Add a unique element ID to the output textbox so we can target it with CSS.
69
  output = gr.Textbox(label="Model Response", lines=8, elem_id="output_textbox")
70
 
71
  submit_btn.click(
 
2
  import gradio as gr
3
  from PIL import Image
4
 
5
+ # Added more placeholder responses to prevent an IndexError
 
6
  PREWRITTEN_RESPONSES = [
7
+ "When it comes to retailing industry, we often remind the both part of realistic store and internet shopping. Both of them are all have their pros and cons, but according to the picture, we can find out both of the internet sales counting and its profit are all growed up every year between twenty eighteen to twenty twenty one. The years () rate began with twenty eighteen only 10.3%, next year 14.1%, and the next 20.3%, finally finished in twenty twenty one up to 24.5%. The sales profit also began with twenty eighteen only 2517 (million), next year 2893, and the next 3456, finally finished in twenty twenty one up to 4303. Therefore, we can find out the internet shopping is growed up between the four years. Begun 2019, according my observed, () more of my friends change to internet shopping because of COVID-19. All above the results provided the picture is the realistic.\nIn my opinion, shopping on the internet can save many times to me, so I also do it when I"
 
 
 
8
  ]
9
 
10
  def fake_minicpm_infer(image: Image.Image, text: str):
 
29
 
30
  # --- START OF MODIFICATIONS ---
31
 
32
+ # MODIFIED: Updated CSS to target both the input and output textboxes.
33
+ # We use a comma to apply the same style to multiple selectors.
34
  custom_css = """
35
+ #input_textbox textarea,
36
  #output_textbox textarea {
37
  font-size: 18px !important;
38
  }
 
40
 
41
  # Pass the custom CSS to the gr.Blocks constructor.
42
  with gr.Blocks(title="MiniCPM-V-4_5 Demo", css=custom_css) as demo:
43
+
44
  # --- END OF MODIFICATIONS ---
45
 
46
  gr.Markdown(
 
52
  with gr.Row():
53
  with gr.Column(scale=1):
54
  image_in = gr.Image(label="Input Image", type="pil")
55
+
56
+ # --- MODIFICATION ---
57
+ # Add a unique element ID to the input textbox.
58
  text_in = gr.Textbox(
59
  label="Input Question/Description",
60
  placeholder="e.g., What kind of landscape is this? or What should I be aware of when traveling?",
61
+ lines=3,
62
+ elem_id="input_textbox"
63
  )
64
+
65
  submit_btn = gr.Button("Submit", variant="primary")
66
 
67
  with gr.Column(scale=1):
68
  gr.Markdown("### Output")
 
 
69
  output = gr.Textbox(label="Model Response", lines=8, elem_id="output_textbox")
70
 
71
  submit_btn.click(