vikhyatk commited on
Commit
ce916c7
·
verified ·
1 Parent(s): 05bc959

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -46,7 +46,6 @@ moondream = AutoModelForCausalLM.from_pretrained(
46
  device_map={"": "cuda"},
47
  revision=REVISION
48
  )
49
- moondream.use_flex_decoding = False
50
  moondream.eval()
51
 
52
 
@@ -116,6 +115,8 @@ def convert_to_entities(text, coords):
116
 
117
  @spaces.GPU(duration=30)
118
  def answer_question(img, prompt, reasoning):
 
 
119
  buffer = ""
120
  resp = moondream.query(img, prompt, stream=True, reasoning=reasoning)
121
  reasoning_text = resp["reasoning"]["text"] if reasoning else "[reasoning disabled]"
@@ -130,6 +131,8 @@ def answer_question(img, prompt, reasoning):
130
 
131
  @spaces.GPU(duration=10)
132
  def caption(img, mode):
 
 
133
  if img is None:
134
  yield ""
135
  return
@@ -147,6 +150,8 @@ def caption(img, mode):
147
 
148
  @spaces.GPU(duration=10)
149
  def detect(img, object, eos_bias):
 
 
150
  if img is None:
151
  yield "", gr.update(visible=False, value=None)
152
  return
@@ -175,6 +180,8 @@ def detect(img, object, eos_bias):
175
 
176
  @spaces.GPU(duration=10)
177
  def point(img, object):
 
 
178
  if img is None:
179
  yield "", gr.update(visible=False, value=None)
180
  return
@@ -200,6 +207,8 @@ def point(img, object):
200
 
201
  @spaces.GPU(duration=10)
202
  def localized_query(img, x, y, question):
 
 
203
  if img is None:
204
  yield "", {"text": "", "entities": []}, gr.update(visible=False, value=None)
205
  return
 
46
  device_map={"": "cuda"},
47
  revision=REVISION
48
  )
 
49
  moondream.eval()
50
 
51
 
 
115
 
116
  @spaces.GPU(duration=30)
117
  def answer_question(img, prompt, reasoning):
118
+ moondream.use_flex_decoding = False
119
+
120
  buffer = ""
121
  resp = moondream.query(img, prompt, stream=True, reasoning=reasoning)
122
  reasoning_text = resp["reasoning"]["text"] if reasoning else "[reasoning disabled]"
 
131
 
132
  @spaces.GPU(duration=10)
133
  def caption(img, mode):
134
+ moondream.use_flex_decoding = False
135
+
136
  if img is None:
137
  yield ""
138
  return
 
150
 
151
  @spaces.GPU(duration=10)
152
  def detect(img, object, eos_bias):
153
+ moondream.use_flex_decoding = False
154
+
155
  if img is None:
156
  yield "", gr.update(visible=False, value=None)
157
  return
 
180
 
181
  @spaces.GPU(duration=10)
182
  def point(img, object):
183
+ moondream.use_flex_decoding = False
184
+
185
  if img is None:
186
  yield "", gr.update(visible=False, value=None)
187
  return
 
207
 
208
  @spaces.GPU(duration=10)
209
  def localized_query(img, x, y, question):
210
+ moondream.use_flex_decoding = False
211
+
212
  if img is None:
213
  yield "", {"text": "", "entities": []}, gr.update(visible=False, value=None)
214
  return