mjbuehler commited on
Commit
40f0c03
1 Parent(s): a43169a

Update README.md

Browse files

Update inference example

Files changed (1) hide show
  1. README.md +9 -2
README.md CHANGED
@@ -132,8 +132,15 @@ The curves show an increasing trend of stress with strain, indicating that the m
132
  Next we provide a convenience function for inference. This function takes the model, processor, question, and images, along with messages and images objects for repeated chat-like interactions with the model.
133
 
134
  ```python
 
 
 
 
 
 
 
135
  def ask_about_image (model, processor, question, images_input=[], verbatim=False,temperature=0.1,show_image=False,
136
- system="You are a materials scientist. ", init_instr = "", show_conversation=True,
137
  max_new_tokens=256, messages=[], images=[], use_Markdown=False):
138
 
139
  images_input=ensure_list(images_input)
@@ -141,7 +148,7 @@ def ask_about_image (model, processor, question, images_input=[], verbatim=Fals
141
  if len (images_input)>0:
142
  for image in tqdm (images_input) :
143
  if is_url(image):
144
- image= load_image(image)
145
  images.append (image)
146
 
147
  if show_image:
 
132
  Next we provide a convenience function for inference. This function takes the model, processor, question, and images, along with messages and images objects for repeated chat-like interactions with the model.
133
 
134
  ```python
135
+ from transformers.image_utils import load_image
136
+
137
+ def is_url_or_filename(val) -> bool:
138
+ # Check if it's a URL
139
+ if isinstance(val, str):
140
+ return True
141
+
142
  def ask_about_image (model, processor, question, images_input=[], verbatim=False,temperature=0.1,show_image=False,
143
+ system="You are a materials scientist. ", show_conversation=True,
144
  max_new_tokens=256, messages=[], images=[], use_Markdown=False):
145
 
146
  images_input=ensure_list(images_input)
 
148
  if len (images_input)>0:
149
  for image in tqdm (images_input) :
150
  if is_url(image):
151
+ is_url_or_filename= load_image(image)
152
  images.append (image)
153
 
154
  if show_image: