Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,7 +8,7 @@ from transformers import TextIteratorStreamer, AutoTokenizer, AutoModelForCausal
|
|
| 8 |
import subprocess
|
| 9 |
# subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
|
| 10 |
|
| 11 |
-
device = torch.device("
|
| 12 |
dtype = torch.float32
|
| 13 |
|
| 14 |
model_id = "vikhyatk/moondream2"
|
|
@@ -20,7 +20,7 @@ moondream = AutoModelForCausalLM.from_pretrained(
|
|
| 20 |
moondream.eval()
|
| 21 |
|
| 22 |
|
| 23 |
-
@spaces.
|
| 24 |
def answer_question(img, prompt):
|
| 25 |
image_embeds = moondream.encode_image(img)
|
| 26 |
streamer = TextIteratorStreamer(tokenizer, skip_special_tokens=True)
|
|
|
|
| 8 |
import subprocess
|
| 9 |
# subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
|
| 10 |
|
| 11 |
+
device = torch.device("cuda")
|
| 12 |
dtype = torch.float32
|
| 13 |
|
| 14 |
model_id = "vikhyatk/moondream2"
|
|
|
|
| 20 |
moondream.eval()
|
| 21 |
|
| 22 |
|
| 23 |
+
@spaces.GPU(duration=60)
|
| 24 |
def answer_question(img, prompt):
|
| 25 |
image_embeds = moondream.encode_image(img)
|
| 26 |
streamer = TextIteratorStreamer(tokenizer, skip_special_tokens=True)
|