ThomasSimonini HF staff commited on
Commit
0be24e7
·
verified ·
1 Parent(s): d199475

Upload moondream.py

Browse files
Files changed (1) hide show
  1. moondream.py +3 -12
moondream.py CHANGED
@@ -62,7 +62,6 @@ class Moondream(PreTrainedModel):
62
  def get_input_embeddings(self):
63
  return self.text_model.get_input_embeddings()
64
 
65
-
66
  def generate(
67
  self,
68
  image_embeds,
@@ -85,17 +84,9 @@ class Moondream(PreTrainedModel):
85
  output_ids = self.text_model.generate(
86
  inputs_embeds=inputs_embeds, streamer=streamer, **generate_config
87
  )
 
88
 
89
- # Pull the generated text from the streamer, and update the model output.
90
- model_output = ""
91
- for new_text in streamer:
92
- model_output += new_text
93
- yield new_text
94
- return model_output
95
-
96
- #return tokenizer.batch_decode(output_ids, skip_special_tokens=True)
97
-
98
-
99
 
100
  def answer_question(
101
  self,
@@ -186,4 +177,4 @@ class Moondream(PreTrainedModel):
186
  return [
187
  x.strip()
188
  for x in tokenizer.batch_decode(output_ids, skip_special_tokens=True)
189
- ]
 
62
  def get_input_embeddings(self):
63
  return self.text_model.get_input_embeddings()
64
 
 
65
  def generate(
66
  self,
67
  image_embeds,
 
84
  output_ids = self.text_model.generate(
85
  inputs_embeds=inputs_embeds, streamer=streamer, **generate_config
86
  )
87
+ print("FINISHED")
88
 
89
+ return tokenizer.batch_decode(output_ids, skip_special_tokens=True)
 
 
 
 
 
 
 
 
 
90
 
91
  def answer_question(
92
  self,
 
177
  return [
178
  x.strip()
179
  for x in tokenizer.batch_decode(output_ids, skip_special_tokens=True)
180
+ ]