liamcripwell commited on
Commit
3c70d1e
·
1 Parent(s): 27f5b0b

allow for inclusion of example inputs

Browse files
Files changed (2) hide show
  1. Dockerfile +1 -0
  2. app.py +20 -2
Dockerfile CHANGED
@@ -39,6 +39,7 @@ RUN pip install --no-cache-dir --user gradio Pillow requests aiohttp
39
  COPY --chown=user numarkdown.svg $HOME/app/
40
  COPY --chown=user app.py $HOME/app/
41
  COPY --chown=user start.sh $HOME/app/
 
42
  RUN chmod +x $HOME/app/start.sh
43
 
44
  # Expose the Space UI port
 
39
  COPY --chown=user numarkdown.svg $HOME/app/
40
  COPY --chown=user app.py $HOME/app/
41
  COPY --chown=user start.sh $HOME/app/
42
+ COPY --chown=user example_images/ $HOME/app/example_images/
43
  RUN chmod +x $HOME/app/start.sh
44
 
45
  # Expose the Space UI port
app.py CHANGED
@@ -6,6 +6,16 @@ from io import BytesIO
6
 
7
  print("=== DEBUG: Starting app.py ===")
8
 
 
 
 
 
 
 
 
 
 
 
9
  def encode_image_to_base64(image: Image.Image) -> str:
10
  buffered = BytesIO()
11
  image.save(buffered, format="JPEG")
@@ -101,7 +111,7 @@ with gr.Blocks(title="NuMarkdown-8B-Thinking", theme=gr.themes.Soft(), css="""
101
 
102
  with gr.Row():
103
  with gr.Column(scale=2):
104
- temperature = gr.Slider(0.1, 1.5, value=0.6, step=0.1, label="Temperature")
105
  btn = gr.Button("Generate Response", variant="primary", size="lg")
106
  img_in = gr.Image(type="pil", label="Upload Image")
107
 
@@ -133,6 +143,14 @@ with gr.Blocks(title="NuMarkdown-8B-Thinking", theme=gr.themes.Soft(), css="""
133
  outputs=[thinking, raw_answer, output],
134
  )
135
 
 
 
 
 
 
 
 
 
136
  print("=== DEBUG: Gradio interface created ===")
137
 
138
  if __name__ == "__main__":
@@ -140,6 +158,6 @@ if __name__ == "__main__":
140
  demo.launch(
141
  server_name="0.0.0.0",
142
  server_port=7860,
143
- share=False
144
  )
145
  print("=== DEBUG: Gradio launched ===")
 
6
 
7
  print("=== DEBUG: Starting app.py ===")
8
 
9
+ # Get example images
10
+ import os
11
+ example_dir = "example_images" # Relative path since it's in the same directory
12
+ example_images = []
13
+ if os.path.exists(example_dir):
14
+ for filename in os.listdir(example_dir):
15
+ if filename.lower().endswith(('.png', '.jpg', '.jpeg', '.gif', '.bmp')):
16
+ example_images.append(os.path.join(example_dir, filename))
17
+ print(f"Found {len(example_images)} example images")
18
+
19
  def encode_image_to_base64(image: Image.Image) -> str:
20
  buffered = BytesIO()
21
  image.save(buffered, format="JPEG")
 
111
 
112
  with gr.Row():
113
  with gr.Column(scale=2):
114
+ temperature = gr.Slider(0.1, 1.5, value=0.4, step=0.1, label="Temperature")
115
  btn = gr.Button("Generate Response", variant="primary", size="lg")
116
  img_in = gr.Image(type="pil", label="Upload Image")
117
 
 
143
  outputs=[thinking, raw_answer, output],
144
  )
145
 
146
+ # Add examples if we have any
147
+ if example_images:
148
+ gr.Examples(
149
+ examples=example_images[:5], # Limit to 5 examples
150
+ inputs=img_in,
151
+ label="📸 Try these example images"
152
+ )
153
+
154
  print("=== DEBUG: Gradio interface created ===")
155
 
156
  if __name__ == "__main__":
 
158
  demo.launch(
159
  server_name="0.0.0.0",
160
  server_port=7860,
161
+ share=True
162
  )
163
  print("=== DEBUG: Gradio launched ===")