mattyhew commited on
Commit
fa7fb50
·
verified ·
1 Parent(s): b348ae4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import gdown
2
  import torch
3
  import torch.nn as nn
@@ -14,7 +15,9 @@ itos = {i: ch for i, ch in enumerate(chars)}
14
 
15
  # Load the model
16
  gdown.download('https://drive.usercontent.google.com/download?id=14k2xUrvJ32trhLCzV2_O7klreBBA3dUu&authuser=0&confirm=t', 'model.pth', quiet=False)
17
- model = torch.load('model.pth')
 
 
18
 
19
  # Function for generating text
20
  def generate_text(prompt, max_length=50):
@@ -33,4 +36,3 @@ if __name__ == "__main__":
33
  prompt = "Enter your prompt here" # Replace with actual input
34
  generated = generate_text(prompt)
35
  print(generated)
36
-
 
1
+
2
  import gdown
3
  import torch
4
  import torch.nn as nn
 
15
 
16
  # Load the model
17
  gdown.download('https://drive.usercontent.google.com/download?id=14k2xUrvJ32trhLCzV2_O7klreBBA3dUu&authuser=0&confirm=t', 'model.pth', quiet=False)
18
+
19
+ # Load the model with CPU mapping
20
+ model = torch.load('model.pth', map_location=torch.device('cpu'))
21
 
22
  # Function for generating text
23
  def generate_text(prompt, max_length=50):
 
36
  prompt = "Enter your prompt here" # Replace with actual input
37
  generated = generate_text(prompt)
38
  print(generated)