THEODOROS commited on
Commit
e2aff85
·
1 Parent(s): fe945ab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -15,6 +15,10 @@ from transformers import AutoTokenizer, AutoConfig, AutoModelForCausalLM
15
  finetuned = AutoModelForCausalLM.from_pretrained('model')
16
  tokenizer = AutoTokenizer.from_pretrained('gpt2')
17
 
 
 
 
 
18
  # Utility functions
19
 
20
  housegan_labels = {"living_room": 1, "kitchen": 2, "bedroom": 3, "bathroom": 4, "missing": 5, "closet": 6,
@@ -66,7 +70,7 @@ def prompt_to_layout(user_prompt, top_p, top_k, fpath=None):
66
 
67
  model_prompt = '[User prompt] {} [Layout]'.format(user_prompt)
68
  #print(model_prompt)
69
- input_ids = tokenizer(model_prompt, return_tensors='pt')
70
  output = finetuned.generate(**input_ids, do_sample=True, top_p=top_p, top_k=top_k, eos_token_id=50256, max_length=400)
71
  output = tokenizer.batch_decode(output, skip_special_tokens=True)
72
  #print(output)
 
15
  finetuned = AutoModelForCausalLM.from_pretrained('model')
16
  tokenizer = AutoTokenizer.from_pretrained('gpt2')
17
 
18
+ device = "cuda:0" if torch.cuda.is_available() else "cpu"
19
+ print(device)
20
+ finetuned = finetuned.to(device)
21
+
22
  # Utility functions
23
 
24
  housegan_labels = {"living_room": 1, "kitchen": 2, "bedroom": 3, "bathroom": 4, "missing": 5, "closet": 6,
 
70
 
71
  model_prompt = '[User prompt] {} [Layout]'.format(user_prompt)
72
  #print(model_prompt)
73
+ input_ids = tokenizer(model_prompt, return_tensors='pt').to(device)
74
  output = finetuned.generate(**input_ids, do_sample=True, top_p=top_p, top_k=top_k, eos_token_id=50256, max_length=400)
75
  output = tokenizer.batch_decode(output, skip_special_tokens=True)
76
  #print(output)