Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,13 +6,14 @@ import torch
|
|
| 6 |
|
| 7 |
|
| 8 |
class ModelProcessor:
|
|
|
|
| 9 |
def __init__(self, repo_id="HuggingFaceTB/cosmo-1b"):
|
| 10 |
# Initialize the tokenizer
|
| 11 |
self.tokenizer = AutoTokenizer.from_pretrained(repo_id, use_fast=True)
|
| 12 |
|
| 13 |
# Initialize and configure the model
|
| 14 |
self.model = AutoModelForCausalLM.from_pretrained(
|
| 15 |
-
repo_id, torch_dtype=torch.float16, device_map="
|
| 16 |
)
|
| 17 |
self.model.eval() # Set the model to evaluation mode
|
| 18 |
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
class ModelProcessor:
|
| 9 |
+
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
| 10 |
def __init__(self, repo_id="HuggingFaceTB/cosmo-1b"):
|
| 11 |
# Initialize the tokenizer
|
| 12 |
self.tokenizer = AutoTokenizer.from_pretrained(repo_id, use_fast=True)
|
| 13 |
|
| 14 |
# Initialize and configure the model
|
| 15 |
self.model = AutoModelForCausalLM.from_pretrained(
|
| 16 |
+
repo_id, torch_dtype=torch.float16, device_map={"": device}, trust_remote_code=True
|
| 17 |
)
|
| 18 |
self.model.eval() # Set the model to evaluation mode
|
| 19 |
|