Spaces:
Build error
Build error
Celine commited on
Commit ·
efb52f3
1
Parent(s): 7884c4a
@spaces.GPU decorator added
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import gradio as gr
|
|
| 2 |
import torch
|
| 3 |
import numpy
|
| 4 |
from huggingface_hub import login
|
|
|
|
| 5 |
import os
|
| 6 |
login(os.getenv('LOGIN_TOKEN'))
|
| 7 |
|
|
@@ -15,6 +16,7 @@ gemma_model = AutoModelForCausalLM.from_pretrained(
|
|
| 15 |
torch_dtype=torch.bfloat16
|
| 16 |
)
|
| 17 |
|
|
|
|
| 18 |
def promptGemma2(textprompt, max_tokens=20):
|
| 19 |
input_ids = gemma_tokenizer(textprompt, return_tensors="pt")#.to("cuda")
|
| 20 |
outputs = gemma_model.generate(**input_ids, max_new_tokens=max_tokens)
|
|
|
|
| 2 |
import torch
|
| 3 |
import numpy
|
| 4 |
from huggingface_hub import login
|
| 5 |
+
import spaces
|
| 6 |
import os
|
| 7 |
login(os.getenv('LOGIN_TOKEN'))
|
| 8 |
|
|
|
|
| 16 |
torch_dtype=torch.bfloat16
|
| 17 |
)
|
| 18 |
|
| 19 |
+
@spaces.GPU
|
| 20 |
def promptGemma2(textprompt, max_tokens=20):
|
| 21 |
input_ids = gemma_tokenizer(textprompt, return_tensors="pt")#.to("cuda")
|
| 22 |
outputs = gemma_model.generate(**input_ids, max_new_tokens=max_tokens)
|