Lord-Raven commited on
Commit
8ec27b2
·
1 Parent(s): 320ebd5

Messing with fastAPI.

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -36,7 +36,6 @@ classifier = pipeline(task="zero-shot-classification", model=model_name, tokeniz
36
  # classifier = pipeline(task="zero-shot-classification", model=model_name, tokenizer=tokenizer_name)
37
 
38
  def classify(data_string, request: gradio.Request):
39
- print(f"classify")
40
  if request:
41
  if request.headers["origin"] not in ["https://statosphere-3704059fdd7e.c5v4v4jx6pq5.win", "https://crunchatize-77a78ffcc6a6.c5v4v4jx6pq5.win", "https://crunchatize-2-2b4f5b1479a6.c5v4v4jx6pq5.win", "https://tamabotchi-2dba63df3bf1.c5v4v4jx6pq5.win", "https://ravenok-statosphere-backend.hf.space", "https://lord-raven.github.io"]:
42
  return "{}"
@@ -50,9 +49,7 @@ def classify(data_string, request: gradio.Request):
50
  # else:
51
  start_time = time.time()
52
  result = zero_shot_classification(data)
53
- end_time = time.time()
54
- elapsed_time = end_time - start_time
55
- print(f"classification took {elapsed_time}.")
56
  return json.dumps(result)
57
 
58
  @spaces.GPU(duration=3)
@@ -84,4 +81,6 @@ gradio_interface = gradio.Interface(
84
  outputs = gradio.Textbox()
85
  )
86
 
 
 
87
  gradio_interface.launch()
 
36
  # classifier = pipeline(task="zero-shot-classification", model=model_name, tokenizer=tokenizer_name)
37
 
38
  def classify(data_string, request: gradio.Request):
 
39
  if request:
40
  if request.headers["origin"] not in ["https://statosphere-3704059fdd7e.c5v4v4jx6pq5.win", "https://crunchatize-77a78ffcc6a6.c5v4v4jx6pq5.win", "https://crunchatize-2-2b4f5b1479a6.c5v4v4jx6pq5.win", "https://tamabotchi-2dba63df3bf1.c5v4v4jx6pq5.win", "https://ravenok-statosphere-backend.hf.space", "https://lord-raven.github.io"]:
41
  return "{}"
 
49
  # else:
50
  start_time = time.time()
51
  result = zero_shot_classification(data)
52
+ print(f"classification took {time.time() - start_time}.")
 
 
53
  return json.dumps(result)
54
 
55
  @spaces.GPU(duration=3)
 
81
  outputs = gradio.Textbox()
82
  )
83
 
84
+ app.mount("/gradio", gradio_interface)
85
+
86
  gradio_interface.launch()