saa231 commited on
Commit
3f58745
·
verified ·
1 Parent(s): 5c2f968

Update project_model.py

Browse files
Files changed (1) hide show
  1. project_model.py +13 -10
project_model.py CHANGED
@@ -208,21 +208,24 @@ def process_inputs(
208
  # "text": question + " " + session.visual_context # Question and visual context combined as text
209
  #}
210
 
211
- gemma_input = {
212
- "images": session.current_image, # Image context
213
- "text": question + " This is the shared visual context: " + session.visual_context # Question and visual context combined as text
214
- }
215
 
216
  # Process the input through Gemma
217
- gemma_output = gemma_pipe(gemma_input)
 
 
 
218
 
219
  # Handle the output from Gemma model safely
220
  if isinstance(gemma_output, list) and len(gemma_output) > 0:
221
- gemma_text = gemma_output[0]["generated_text"][-1]["content"]
222
- if isinstance(gemma_text, str):
223
- answer = gemma_text
224
- else:
225
- answer = "No valid generated text found."
226
  else:
227
  answer = "No valid output from Gemma model."
228
 
 
208
  # "text": question + " " + session.visual_context # Question and visual context combined as text
209
  #}
210
 
211
+ #gemma_input = {
212
+ # "images": session.current_image, # Image context
213
+ # "text": question + " This is the shared visual context: " + session.visual_context # Question and visual context combined as text
214
+ # }
215
 
216
  # Process the input through Gemma
217
+ gemma_output = gemma_pipe(
218
+ images=session.current_image,
219
+ text=question + " This is the shared visual context: " + session.visual_context
220
+ )
221
 
222
  # Handle the output from Gemma model safely
223
  if isinstance(gemma_output, list) and len(gemma_output) > 0:
224
+ gemma_text = gemma_output[0]["generated_text"]
225
+ if isinstance(gemma_text, str):
226
+ answer = gemma_text
227
+ else:
228
+ answer = "No valid generated text found."
229
  else:
230
  answer = "No valid output from Gemma model."
231