smdbs commited on
Commit
3764f5d
·
1 Parent(s): 85f9386

chore: add start_server() in main and clean up code

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -30,7 +30,7 @@ MAX_IMAGE_SIZE = 1280
30
 
31
  # Make sure to set the environment variable HF_TOKEN to your Hugging Face token for using InferenceClient
32
  HF_TOKEN = os.environ.get("HF_TOKEN", "YOUR_HF_TOKEN")
33
- print(f"Using Hugging Face token: {HF_TOKEN}")
34
  model_name = "stabilityai/stable-diffusion-2-1-base"
35
  client = InferenceClient(model_name, token=HF_TOKEN)
36
 
@@ -68,6 +68,9 @@ def sd_2_1_base(
68
  generator = torch.Generator().manual_seed(seed)
69
 
70
  REQUEST_COUNTER.inc()
 
 
 
71
  with REQUEST_DURATION.time():
72
  try:
73
  if is_local:
@@ -204,7 +207,5 @@ with gr.Blocks() as ui:
204
  )
205
 
206
  if __name__ == "__main__":
207
- if scheduler is None or pipe is None:
208
- load_model()
209
-
210
  ui.launch()
 
30
 
31
  # Make sure to set the environment variable HF_TOKEN to your Hugging Face token for using InferenceClient
32
  HF_TOKEN = os.environ.get("HF_TOKEN", "YOUR_HF_TOKEN")
33
+ # print(f"Using Hugging Face token: {HF_TOKEN}")
34
  model_name = "stabilityai/stable-diffusion-2-1-base"
35
  client = InferenceClient(model_name, token=HF_TOKEN)
36
 
 
68
  generator = torch.Generator().manual_seed(seed)
69
 
70
  REQUEST_COUNTER.inc()
71
+ if not is_local and (scheduler is None or pipe is None):
72
+ load_model()
73
+
74
  with REQUEST_DURATION.time():
75
  try:
76
  if is_local:
 
207
  )
208
 
209
  if __name__ == "__main__":
210
+ start_http_server(8000)
 
 
211
  ui.launch()