Danil commited on
Commit
e204e9a
β€’
1 Parent(s): 08ccc2c
Files changed (2) hide show
  1. app.py +1 -1
  2. server.py +2 -1
app.py CHANGED
@@ -7,7 +7,7 @@ def start_server():
7
  os.system("uvicorn server:app --port 8080 --host 0.0.0.0 --workers 1")
8
  os.environ["SSTART"] = "1"
9
 
10
- if os.environ.get('SSTART') is None:
11
  start_server()
12
 
13
  st.set_page_config(
 
7
  os.system("uvicorn server:app --port 8080 --host 0.0.0.0 --workers 1")
8
  os.environ["SSTART"] = "1"
9
 
10
+ if os.environ.get('SSTART') != "1":
11
  start_server()
12
 
13
  st.set_page_config(
server.py CHANGED
@@ -7,10 +7,11 @@ app = FastAPI()
7
  model_name = 'facebook/incoder-1B'
8
  tokenizer = AutoTokenizer.from_pretrained(model_name)
9
  model = AutoModelForCausalLM.from_pretrained(model_name, low_cpu_mem_usage=True)
 
10
 
11
  @app.get("/")
12
  def read_root(input_text, max_length, top_p, top_k, num_beams, temperature, repetition_penalty):
13
- inpt = model_name.encode(input_text, return_tensors="pt")
14
  out = model.generate(inpt, max_length=max_length, top_p=top_p, top_k=top_k, temperature=temperature, num_beams=num_beams, repetition_penalty=repetition_penalty)
15
  res = tokenizer.decode(out[0])
16
  return {res}
 
7
  model_name = 'facebook/incoder-1B'
8
  tokenizer = AutoTokenizer.from_pretrained(model_name)
9
  model = AutoModelForCausalLM.from_pretrained(model_name, low_cpu_mem_usage=True)
10
+ print('load ok')
11
 
12
  @app.get("/")
13
  def read_root(input_text, max_length, top_p, top_k, num_beams, temperature, repetition_penalty):
14
+ inpt = tokenizer.encode(input_text, return_tensors="pt")
15
  out = model.generate(inpt, max_length=max_length, top_p=top_p, top_k=top_k, temperature=temperature, num_beams=num_beams, repetition_penalty=repetition_penalty)
16
  res = tokenizer.decode(out[0])
17
  return {res}