English
yeswondwerr commited on
Commit
8e9df48
1 Parent(s): 9c897db

Update __main__.py

Browse files
Files changed (1) hide show
  1. __main__.py +10 -9
__main__.py CHANGED
@@ -126,13 +126,13 @@ def answer_question(
126
  tokenizer.eos_token = "<|eot_id|>"
127
 
128
  try:
129
- inp = input("user: ")
130
  except EOFError:
131
- inp = ""
132
- if not inp:
133
- print("exit...")
134
 
135
- question = "<image>" + inp
136
 
137
  prompt = f"<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\n{question}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"
138
 
@@ -179,6 +179,7 @@ def answer_question(
179
  "max_new_tokens": 2000,
180
  "use_cache": True,
181
  "streamer": streamer,
 
182
  }
183
 
184
  while True:
@@ -188,11 +189,11 @@ def answer_question(
188
 
189
  generated_text = tokenizer.decode(generated_ids, skip_special_tokens=False)
190
  try:
191
- inp = input("user: ")
192
  except EOFError:
193
- inp = ""
194
- if not inp:
195
- print("exit...")
196
 
197
  new_text = (
198
  generated_text
 
126
  tokenizer.eos_token = "<|eot_id|>"
127
 
128
  try:
129
+ q = input("user: ")
130
  except EOFError:
131
+ q = ""
132
+ if not q:
133
+ print("no input detected. exiting.")
134
 
135
+ question = "<image>" + q
136
 
137
  prompt = f"<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\n{question}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"
138
 
 
179
  "max_new_tokens": 2000,
180
  "use_cache": True,
181
  "streamer": streamer,
182
+ "pad_token_id": tokenizer.eos_token_id
183
  }
184
 
185
  while True:
 
189
 
190
  generated_text = tokenizer.decode(generated_ids, skip_special_tokens=False)
191
  try:
192
+ q = input("user: ")
193
  except EOFError:
194
+ q = ""
195
+ if not q:
196
+ print("no input detected. exiting.")
197
 
198
  new_text = (
199
  generated_text