Spaces:
Runtime error
Runtime error
Made app.py cpu only for huggingface spaces
Browse files
app.py
CHANGED
@@ -10,15 +10,11 @@ css = """
|
|
10 |
flatten = lambda l: [item for sublist in l for item in sublist]
|
11 |
|
12 |
def to_data(x):
|
13 |
-
if torch.cuda.is_available():
|
14 |
-
x = x.cpu()
|
15 |
return x.data.numpy()
|
16 |
|
17 |
def to_var(x):
|
18 |
if not torch.is_tensor(x):
|
19 |
x = torch.Tensor(x)
|
20 |
-
if torch.cuda.is_available():
|
21 |
-
x = x.cuda()
|
22 |
return x
|
23 |
|
24 |
def clear():
|
@@ -42,7 +38,7 @@ class AI_Companion:
|
|
42 |
chatbot: Huggingface Conversational Model Card. Default: af1tang/personaGPT
|
43 |
"""
|
44 |
|
45 |
-
self.device = torch.device('
|
46 |
self.asr = pipeline("automatic-speech-recognition",model = asr,device= -1 if self.device == "cpu" else 0)
|
47 |
self.model = GPT2LMHeadModel.from_pretrained(chatbot).to(self.device)
|
48 |
self.tokenizer = GPT2Tokenizer.from_pretrained(chatbot)
|
|
|
10 |
flatten = lambda l: [item for sublist in l for item in sublist]
|
11 |
|
12 |
def to_data(x):
|
|
|
|
|
13 |
return x.data.numpy()
|
14 |
|
15 |
def to_var(x):
|
16 |
if not torch.is_tensor(x):
|
17 |
x = torch.Tensor(x)
|
|
|
|
|
18 |
return x
|
19 |
|
20 |
def clear():
|
|
|
38 |
chatbot: Huggingface Conversational Model Card. Default: af1tang/personaGPT
|
39 |
"""
|
40 |
|
41 |
+
self.device = torch.device('cpu')
|
42 |
self.asr = pipeline("automatic-speech-recognition",model = asr,device= -1 if self.device == "cpu" else 0)
|
43 |
self.model = GPT2LMHeadModel.from_pretrained(chatbot).to(self.device)
|
44 |
self.tokenizer = GPT2Tokenizer.from_pretrained(chatbot)
|