sailormars18 commited on
Commit
0af08df
·
1 Parent(s): b014abf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -14,16 +14,14 @@ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
14
  def generate_text(prompt, length=100, theme=None, **kwargs):
15
 
16
  model_url = "https://huggingface.co/spaces/sailormars18/Yelp-reviews-usingGPT2/blob/main/pytorch_model.bin"
17
- config_name = "https://huggingface.co/spaces/sailormars18/Yelp-reviews-usingGPT2/blob/main/config.json"
18
- generation_config_name = "https://huggingface.co/spaces/sailormars18/Yelp-reviews-usingGPT2/blob/main/generation_config.json"
19
 
20
  # Load the model from the Hugging Face space
21
- model = transformers.GPT2LMHeadModel.from_pretrained(model_url, config_name=config_name,
22
- generation_config_name=generation_config_name).to(device)
23
 
24
  # Load the tokenizer from the Hugging Face space
25
- tokenizer = transformers.GPT2Tokenizer.from_pretrained(model_url, config_name=config_name,
26
- generation_config_name=generation_config_name)
27
 
28
  # If a theme is specified, add it to the prompt as a prefix for a special token
29
  if theme:
 
14
  def generate_text(prompt, length=100, theme=None, **kwargs):
15
 
16
  model_url = "https://huggingface.co/spaces/sailormars18/Yelp-reviews-usingGPT2/blob/main/pytorch_model.bin"
17
+ config_url = "https://huggingface.co/spaces/sailormars18/Yelp-reviews-usingGPT2/blob/main/config.json"
18
+ generation_config_url = "https://huggingface.co/spaces/sailormars18/Yelp-reviews-usingGPT2/blob/main/generation_config.json"
19
 
20
  # Load the model from the Hugging Face space
21
+ model = transformers.GPT2LMHeadModel.from_pretrained(model_url, config=config_url).to(device)
 
22
 
23
  # Load the tokenizer from the Hugging Face space
24
+ tokenizer = transformers.GPT2Tokenizer.from_pretrained(model_url, config=config_url)
 
25
 
26
  # If a theme is specified, add it to the prompt as a prefix for a special token
27
  if theme: