yeswondwerr
commited on
Commit
•
8e9df48
1
Parent(s):
9c897db
Update __main__.py
Browse files- __main__.py +10 -9
__main__.py
CHANGED
@@ -126,13 +126,13 @@ def answer_question(
|
|
126 |
tokenizer.eos_token = "<|eot_id|>"
|
127 |
|
128 |
try:
|
129 |
-
|
130 |
except EOFError:
|
131 |
-
|
132 |
-
if not
|
133 |
-
print("
|
134 |
|
135 |
-
question = "<image>" +
|
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 |
-
|
192 |
except EOFError:
|
193 |
-
|
194 |
-
if not
|
195 |
-
print("
|
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
|