vikhyatk commited on
Commit
2ea650c
·
verified ·
1 Parent(s): 030edb2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -15
app.py CHANGED
@@ -169,24 +169,11 @@ def caption(img, mode):
169
  yield ""
170
  return
171
 
172
- streamer = TextIteratorStreamer(tokenizer, skip_special_tokens=True)
173
- thread = Thread(
174
- target=moondream.caption,
175
- kwargs={
176
- "images": [img],
177
- "length": "short" if mode == "Short" else None,
178
- "tokenizer": tokenizer,
179
- "streamer": streamer,
180
- },
181
- )
182
- thread.start()
183
-
184
  buffer = ""
185
- for new_text in streamer:
186
- buffer += new_text
187
  yield buffer.strip()
188
 
189
-
190
  @spaces.GPU(duration=10)
191
  def detect(img, object):
192
  if img is None:
 
169
  yield ""
170
  return
171
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  buffer = ""
173
+ for t in moondream.caption(length="short" if mode == "Short" else None, stream=True)["caption"]:
174
+ buffer += t
175
  yield buffer.strip()
176
 
 
177
  @spaces.GPU(duration=10)
178
  def detect(img, object):
179
  if img is None: