SyntheticVis-Umut commited on
Commit
3e6a450
·
1 Parent(s): 90cb6f6

Switch to SDXL base model for better InferenceClient compatibility

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -8,8 +8,8 @@ from huggingface_hub import InferenceClient
8
  app = FastAPI(title="ImageGen API")
9
 
10
  # Choose a model that supports text->image via Inference API.
11
- # SDXL Turbo is fast; you can swap for other models later.
12
- MODEL_ID = os.getenv("MODEL_ID", "stabilityai/sdxl-turbo")
13
  HF_TOKEN = os.getenv("HF_TOKEN") # set in Space Secrets
14
  client = InferenceClient(model=MODEL_ID, token=HF_TOKEN)
15
 
@@ -33,7 +33,7 @@ def generate(req: GenReq):
33
  width=req.width,
34
  height=req.height,
35
  seed=req.seed,
36
- num_inference_steps=req.num_inference_steps or 1 # SDXL Turbo works best with 1 step
37
  )
38
  buf = io.BytesIO()
39
  img.save(buf, format="PNG")
 
8
  app = FastAPI(title="ImageGen API")
9
 
10
  # Choose a model that supports text->image via Inference API.
11
+ # Using a model that works well with InferenceClient
12
+ MODEL_ID = os.getenv("MODEL_ID", "stabilityai/stable-diffusion-xl-base-1.0")
13
  HF_TOKEN = os.getenv("HF_TOKEN") # set in Space Secrets
14
  client = InferenceClient(model=MODEL_ID, token=HF_TOKEN)
15
 
 
33
  width=req.width,
34
  height=req.height,
35
  seed=req.seed,
36
+ num_inference_steps=req.num_inference_steps or 20 # SDXL works well with 20 steps
37
  )
38
  buf = io.BytesIO()
39
  img.save(buf, format="PNG")