justinj92 commited on
Commit
e0f9a39
1 Parent(s): 8ca1753

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -78
app.py CHANGED
@@ -98,9 +98,10 @@ prompt_suffix = "\n"
98
 
99
  # Vision model tab function
100
  @spaces.GPU()
101
- def stream_vision(image, text_input=None, model_id="justinj92/phi-35-vision-burberry"):
102
  model = models[model_id]
103
  processor = processors[model_id]
 
104
 
105
  # Prepare the image list and corresponding tags
106
  images = [Image.fromarray(image).convert("RGB")]
@@ -128,7 +129,7 @@ def stream_vision(image, text_input=None, model_id="justinj92/phi-35-vision-burb
128
 
129
  # Generation parameters
130
  generation_args = {
131
- "max_new_tokens": 1000,
132
  "temperature": 0.0,
133
  "do_sample": False,
134
  }
@@ -165,18 +166,12 @@ h3 {
165
  }
166
  """
167
 
168
- PLACEHOLDER = """
169
- <center>
170
- <p>Hi! I'm your assistant. Feel free to ask your questions</p>
171
- </center>
172
- """
173
-
174
- TITLE = "<h1><center>Phi-3.5 Fine-Tuned Vision Bot using Burberry Dataset </center></h1>"
175
 
176
  EXPLANATION = """
177
  <div style="text-align: center; margin-top: 20px;">
178
- <p>This app supports microsoft/Phi-3.5-vision-instruct model for multimodal model.</p>
179
- <p>This Fine-Tuned version is built using open Burberry Product dataset.</p>
180
  </div>
181
  """
182
 
@@ -192,82 +187,19 @@ footer = """
192
  with gr.Blocks(css=CSS, theme="small_and_pretty") as demo:
193
  gr.HTML(TITLE)
194
  gr.HTML(EXPLANATION)
195
- gr.DuplicateButton(value="Duplicate Space for private use", elem_classes="duplicate-button")
196
- # with gr.Tab("Chatbot"):
197
- # chatbot = gr.Chatbot(height=600, placeholder=PLACEHOLDER)
198
- # gr.ChatInterface(
199
- # fn=stream_chat,
200
- # chatbot=chatbot,
201
- # fill_height=True,
202
- # additional_inputs_accordion=gr.Accordion(label="⚙️ Parameters", open=False, render=False),
203
- # additional_inputs=[
204
- # gr.Textbox(
205
- # value="You are a helpful assistant",
206
- # label="System Prompt",
207
- # render=False,
208
- # ),
209
- # gr.Slider(
210
- # minimum=0,
211
- # maximum=1,
212
- # step=0.1,
213
- # value=0.8,
214
- # label="Temperature",
215
- # render=False,
216
- # ),
217
- # gr.Slider(
218
- # minimum=128,
219
- # maximum=8192,
220
- # step=1,
221
- # value=1024,
222
- # label="Max new tokens",
223
- # render=False,
224
- # ),
225
- # gr.Slider(
226
- # minimum=0.0,
227
- # maximum=1.0,
228
- # step=0.1,
229
- # value=1.0,
230
- # label="top_p",
231
- # render=False,
232
- # ),
233
- # gr.Slider(
234
- # minimum=1,
235
- # maximum=20,
236
- # step=1,
237
- # value=20,
238
- # label="top_k",
239
- # render=False,
240
- # ),
241
- # gr.Slider(
242
- # minimum=0.0,
243
- # maximum=2.0,
244
- # step=0.1,
245
- # value=1.2,
246
- # label="Repetition penalty",
247
- # render=False,
248
- # ),
249
- # ],
250
- # examples=[
251
- # ["How to make a self-driving car?"],
252
- # ["Give me a creative idea to establish a startup"],
253
- # ["How can I improve my programming skills?"],
254
- # ["Show me a code snippet of a website's sticky header in CSS and JavaScript."],
255
- # ],
256
- # cache_examples=False,
257
- # )
258
- with gr.Tab("Vision"):
259
  with gr.Row():
260
  input_img = gr.Image(label="Input Picture")
261
  with gr.Row():
262
  model_selector = gr.Dropdown(choices=list(models.keys()), label="Model", value="justinj92/phi-35-vision-burberry")
263
- with gr.Row():
264
- text_input = gr.Textbox(label="Question")
265
  with gr.Row():
266
  submit_btn = gr.Button(value="Submit")
267
  with gr.Row():
268
  output_text = gr.Textbox(label="Output Text")
269
 
270
- submit_btn.click(stream_vision, [input_img, text_input, model_selector], [output_text])
271
 
272
  gr.HTML(footer)
273
 
 
98
 
99
  # Vision model tab function
100
  @spaces.GPU()
101
+ def stream_vision(image, model_id="justinj92/phi-35-vision-burberry"):
102
  model = models[model_id]
103
  processor = processors[model_id]
104
+ text_input="What is shown in this image?"
105
 
106
  # Prepare the image list and corresponding tags
107
  images = [Image.fromarray(image).convert("RGB")]
 
129
 
130
  # Generation parameters
131
  generation_args = {
132
+ "max_new_tokens": 2000,
133
  "temperature": 0.0,
134
  "do_sample": False,
135
  }
 
166
  }
167
  """
168
 
169
+ TITLE = "<h1><center>Burberry Product Categorizer</center></h1>"
 
 
 
 
 
 
170
 
171
  EXPLANATION = """
172
  <div style="text-align: center; margin-top: 20px;">
173
+ <p>App uses Microsoft Phi 3.5 Vision Model</p>
174
+ <p>Fine-Tuned version is built using open Burberry Product dataset.</p>
175
  </div>
176
  """
177
 
 
187
  with gr.Blocks(css=CSS, theme="small_and_pretty") as demo:
188
  gr.HTML(TITLE)
189
  gr.HTML(EXPLANATION)
190
+ with gr.Tab("Burberry Vision"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
  with gr.Row():
192
  input_img = gr.Image(label="Input Picture")
193
  with gr.Row():
194
  model_selector = gr.Dropdown(choices=list(models.keys()), label="Model", value="justinj92/phi-35-vision-burberry")
195
+ # with gr.Row():
196
+ # text_input = gr.Textbox(label="Question")
197
  with gr.Row():
198
  submit_btn = gr.Button(value="Submit")
199
  with gr.Row():
200
  output_text = gr.Textbox(label="Output Text")
201
 
202
+ submit_btn.click(stream_vision, [input_img, model_selector], [output_text])
203
 
204
  gr.HTML(footer)
205